Skip to content

Add element.sourceline (lxml) #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SimonSapin opened this issue Jul 22, 2013 · 4 comments
Open

Add element.sourceline (lxml) #97

SimonSapin opened this issue Jul 22, 2013 · 4 comments

Comments

@SimonSapin
Copy link
Contributor

Elements in lxml have a sourceline attribute, but it is always None in trees parsed with html5lib.

html5lib also appears to keep track of source line numbers for error messages.

I’d like to connect the two so that WeasyPrint can do its own error reporting based on line numbers of HTML elements. It seems like the attribute should be set in etree_lxml.py, but I don’t know how to access the input stream from there.

Suggestions?

@SimonSapin
Copy link
Contributor Author

This could be opt-in if it degrades performance noticeably.

@gsnedders
Copy link
Member

See also #87.

@tahajahangir
Copy link
Contributor

Previously was requested in http://code.google.com/p/html5lib/issues/detail?id=213

@SimonSapin
Copy link
Contributor Author

In http://code.google.com/p/html5lib/issues/detail?id=213 :

Off-hand, I believe there is no API to set sourceline, so we cannot (even if we had the data) expose it in such a way.

I believe that the API to set sourceline is:

element.sourceline = integer_value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants