Coder Social home page Coder Social logo

asciidoc-named-char-refs's People

Contributors

clbarnes avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

fhaefemeier

asciidoc-named-char-refs's Issues

An alternative way to achieve the same result

Hi, I followed your comment from asciidoctor/asciidoctor-pdf#969

I too struggle to see why the PDF output cannot handle XHTML and HTML5 character entities. If it does for HTML output it is confounding that it does not for PDF. The XML argument against it is dubious as argued by the many commentators in the thread; especially the obvious one, i.e., that "pound" is a lot easier to read than "#163" and asciidoc touts its readability.

After some hair pulling, I found this seems to be an alternative solution:

In asciidoctor.rb under INTRINSIC_ATTRIBUTES you can add all of the entities you like, e.g.:

    'iexcl' => '¡',
    'cent' => '¢',
    'pound' => '£',
    'curren' => '¤',

I have put the entire XHTML set in there and PDF output was mostly fine (the font inadequacies aside). The only thing that failed was case insensitivity, so Agrave and agrave both rendered as the lowercase version. I did not really understand that because, although I know almost nothing about Ruby, I read that its hashes are case sensitive, which I tested interactively...that was confusing. However, just changing the one line in substitutors.rb from elsif doc_attrs.key?(key = $2.downcase) to elsif doc_attrs.key?(key = $2) resolves that (without any obvious side effects that I have seen so far anyway).

The net result is that {iexcl}, {cent}, {Agrave} and {agrave}, etc., work for both HTML and PDF outputs (the only two I tried).

Example output showing these in the last column
examplePage.pdf

And an example line from the input .asciidoc file:
|\Ù |Ù |\Ù |Ù |U+000D9 |latin capital letter U with grave|{Ugrave}ΒΆ

Capitalisation: replace enclosing underscores with leading underscores?

Currently, enclosing underscores leads to more characters for names which use capitals for distinguishing words (e.g. CapitalDifferentialD -> _C_apital_D_ifferential_D_), and require escaping when the first and last letters are both capitalised.

The alternative would be to prepend an underscore to any letter which should be capitalised, which may not require escaping, requires fewer keypresses for the example above, but feels less asciidoc-y, and is worse for names like ETH (_ETH_ vs _E_T_H).

Lastly, might including the convenient lower-case alternative (e.g. capitaldifferentiald) possibly threaten forwards-compatibility, if W3C eventually release a new spec where those all-lower names mean some other unicode character?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.