Title: Add position information for text nodes · Issue #533 · html5lib/html5lib-python · GitHub
Open Graph Title: Add position information for text nodes · Issue #533 · html5lib/html5lib-python
X Title: Add position information for text nodes · Issue #533 · html5lib/html5lib-python
Description: Would it be possible to add position information, i.e. line+column to text nodes? Or, at least make this information available to the tree builder? I implemented a very minimal proof of concept to add the information to each token and pa...
Open Graph Description: Would it be possible to add position information, i.e. line+column to text nodes? Or, at least make this information available to the tree builder? I implemented a very minimal proof of concept to ...
X Description: Would it be possible to add position information, i.e. line+column to text nodes? Or, at least make this information available to the tree builder? I implemented a very minimal proof of concept to ...
Opengraph URL: https://github.com/html5lib/html5lib-python/issues/533
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add position information for text nodes","articleBody":"Would it be possible to add position information, i.e. line+column to text nodes? Or, at least make this information available to the tree builder? I implemented a very minimal proof of concept to add the information to each token and pass that along to the dom tree builder and obtain the following result:\r\n\r\n```\r\nimport html5lib\r\n\r\nhtml = '\u003cdiv\u003e\u0026amp;\u003cp\u003eb\u003cspan\u003ec\u003c/span\u003e\u003c/p\u003e cab\u003c/div\u003e'\r\n\r\nparser = html5lib.HTMLParser(tree=html5lib.getTreeBuilder(\"dom\"))\r\n\r\ndoc = parser.parse(html)\r\ndef parse(n):\r\n for c in n.childNodes:\r\n if hasattr(c, 'sourcepos'):\r\n print(c.sourcepos, c)\r\n parse(c)\r\n\r\nparse(doc)\r\n```\r\n\r\n```\r\nNone \u003cDOM Element: head at 0x10bbed0d0\u003e\r\nNone \u003cDOM Element: body at 0x10bbed1f0\u003e\r\n(1, 5) \u003cDOM Element: div at 0x10bbfb790\u003e\r\n(1, 10) \u003cDOM Text node \"'\u0026'\"\u003e\r\n(1, 13) \u003cDOM Element: p at 0x10bbfb820\u003e\r\n(1, 14) \u003cDOM Text node \"'b'\"\u003e\r\n(1, 20) \u003cDOM Element: span at 0x10bbfb8b0\u003e\r\n(1, 21) \u003cDOM Text node \"'c'\"\u003e\r\n(1, 33) \u003cDOM Text node \"' '\"\u003e\r\n(1, 36) \u003cDOM Text node \"'cab'\"\u003e\r\n```\r\n\r\nI would be willing to implement it.","author":{"url":"https://github.com/corynezin","@type":"Person","name":"corynezin"},"datePublished":"2021-04-16T15:33:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/533/html5lib-python/issues/533"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b336bc01-c60f-4a24-498b-5e445a4f8bf0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFD0:67903:11258:178C1:696FF5A6 |
| html-safe-nonce | 81c73b82e5416c347b2d7224e56f9fc87399dc300feeb8b8f746096925c24660 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkQwOjY3OTAzOjExMjU4OjE3OEMxOjY5NkZGNUE2IiwidmlzaXRvcl9pZCI6IjY2MjgyMjI1MjM0MzI0OTg1OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a4f1ef35a0b455ec90cb24c6c9c3e35d3ccd03b66fac2542704505a241f51110 |
| hovercard-subject-tag | issue:859929123 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/html5lib/html5lib-python/533/issue_layout |
| twitter:image | https://opengraph.githubassets.com/081c8b518743ec9c452f660fe81d6ed6b5051a87aacbc262d9f717b01ce7c33d/html5lib/html5lib-python/issues/533 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/081c8b518743ec9c452f660fe81d6ed6b5051a87aacbc262d9f717b01ce7c33d/html5lib/html5lib-python/issues/533 |
| og:image:alt | Would it be possible to add position information, i.e. line+column to text nodes? Or, at least make this information available to the tree builder? I implemented a very minimal proof of concept to ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | corynezin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 61db99bbb6a7517db80567029869280bdefa9fa883092d6c2aa07ec4ea15f359 |
| turbo-cache-control | no-preview |
| go-import | github.com/html5lib/html5lib-python git https://github.com/html5lib/html5lib-python.git |
| octolytics-dimension-user_id | 4092973 |
| octolytics-dimension-user_login | html5lib |
| octolytics-dimension-repository_id | 9322649 |
| octolytics-dimension-repository_nwo | html5lib/html5lib-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 9322649 |
| octolytics-dimension-repository_network_root_nwo | html5lib/html5lib-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 91ceb31fcdebd150222e05551caf4a28f9532341 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width