asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104 stars 101 forks source link

Line number treeprocessor #85

Closed danyill closed 2 years ago

danyill commented 6 years ago

I wanted to provide an example of how to extract line number information using role (the "easy" way) and also how to undertake a more semantically correct way of extracting the file and line number and adding to html attributes.

Mainly because I'd synchronisation and includes to work beautifully in editor extensions (e.g. see https://github.com/joaompinto/asciidoctor-vscode/issues/59)

I guess the use of a template might be outside the scope of the extensions lab.

I don't think there's an easier way to do this than to override the html converter (It would be neat if we could say "add the line number as an attribute to each div element" but I think Asciidoctor doesn't offer this kind of abstraction/interface at the moment). I'd be very happy to be corrected :smile_cat:

mojavelinux commented 9 months ago

I do think this is interesting. My worry is that the line information in Asciidoctor is not always perfectly accurate and this could lead to confusion if people start relying on it. On the other hand, it's what most IDE plugins are doing right now anyway. Some I'm a bit torn on this one.

There is a way to override the converter without introducing a template. If that change were made, I might be more inclined to accept it. See https://docs.asciidoctor.org/asciidoctor/latest/convert/custom/#extend-and-replace-a-registered-converter