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
105 stars 101 forks source link

- Added extension ent2uni, a postprocessor which maps HTML entities to unicode #22

Closed jxxcarlson closed 2 years ago

jxxcarlson commented 9 years ago

The post processor maps HTML entities to their unicode equivalents.

This was needed to sanitize output from the Asciidoctor LaTeX backend before running it through xelatex, but it is perhaps useful for other things as well.

Current workflow for .adoc to .tex using the normal math convention $ a^2 + b^2 = c^2 $ is

$ a2l foo.adoc

where

alias a2l="$adb/asciidoctor -r $pre -r $post -r $lco -b latex"

and where $pre, $post, and $lco point to tex-preprocessor.rb, ent2uni.rb, and asciidoctor-latex/converter.rb.

mojavelinux commented 9 years ago

This is similar to the following extension: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/undo-replacements-postprocessor.rb We should align the two since they are trying to accomplish the same goal.

jxxcarlson commented 9 years ago

Agreed!

One difference is that ent2uni replaces a class of things, whereas undo-replacements works from a pair of lists. One could switch between the two with an option.

A question. Is there a way of feeding the two lists to the UndoReplacementsPostprocessor? If so, the current setup could be the default, and so not need to be fed with args. Or one could feed it with arbitrary lists, or with a pair of symbols, e.g,

:html_entity, :unicode

in which case the effect would be that of ent2uni. This approach would be versatile, unified, and extensible — for instance one could add other symbol pairs for other tasks if needed.

On Nov 9, 2014, at 10:06 AM, Dan Allen notifications@github.com wrote:

This is similar to the following extension: https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/undo-replacements-postprocessor.rb https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/undo-replacements-postprocessor.rb We should align the two since they are trying to accomplish the same goal.

— Reply to this email directly or view it on GitHub https://github.com/asciidoctor/asciidoctor-extensions-lab/pull/22#issuecomment-62287661.

mojavelinux commented 9 years ago

Is there a way of feeding the two lists to the UndoReplacementsPostprocessor?

We could certainly design it that way. This is all very much in the prototype and design phase, atm.