View Single Post
Old 10-31-2015, 08:47 PM   #9
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Question re: container.href_to_name(href, name)

If I run a query something like this to find links which point somewhere within the book rather than to an external location
Code:
for name in list_of_html_names:
    for a in root.xpath('//*[local-name()="a" and @href]'):
        ahref = a.get('href')
        linkto_name = container.href_to_name(ahref, name)
        if linkto_name is not None:
            do_stuff ...
I would have expected container.href_to_name('#someid', name) to return 'current name' rather than 'None'. Am I using the wrong function or maybe the right function but incorrectly?

For the moment I've just used this instead:
Code:
linkto_name = name if ahref.startswith('#') else container.href_to_name(ahref, name)

Last edited by jackie_w; 10-31-2015 at 09:00 PM.
jackie_w is offline   Reply With Quote