asciidoctor / asciimath

Asciimath parser
MIT License
24 stars 16 forks source link

Request normal font shift #53

Closed opoudjis closed 3 years ago

opoudjis commented 3 years ago

We are using AsciiMath to enter expressions with units, https://github.com/metanorma/bipm-si-brochure/issues/54, and that requires the option of a font shift to normal, upright font.

This is not present in most instances of Asciimath, but as I found in https://github.com/asciidoctor/asciimath/issues/7, https://runarberg.github.io/ascii2mathml/ (now offline) had rm (taken from TeX, although it properly refers to serifed font, not upright style).

The option to force upright font is necessary, we feel, and we request rm as an addition to this gem's Asciimath:

asciimath/lib/asciimath/parser.rb :

b.add('sfbi', :normal, :unary)

asciimath/lib/asciimath/latex.rb :

:normal => "\\mathrm", (or: \\mathup)

asciimath/lib/asciimath/markup.rb :

b.add(:sans_serif_bold_italic, :normal, :font)

davidfarmer commented 3 years ago

Instead of a shift in font, how about a way to indicate that certain characters represent units?

That has the advantage of being semantic. The work to implement it is the same, but the mindset of the person writing the formula is different.

On Mon, 23 Nov 2020, Nick Nicholas wrote:

We are using AsciiMath to enter expressions with units, metanorma/bipm-si-brochure#54, and that requires the option of a font shift to normal, upright font.

This is not present in most instances of Asciimath, but as I found in #7, https://runarberg.github.io/ascii2mathml/ (now offline) had rm (taken from TeX, although it properly refers to serifed font, not upright style).

The option to force upright font is necessary, we feel, and we request rm as an addition to this gem's Asciimath:

asciimath/lib/asciimath/parser.rb :

b.add('sfbi', :normal, :unary)

asciimath/lib/asciimath/latex.rb :

:normal => "\mathrm", (or: \mathup)

asciimath/lib/asciimath/markup.rb :

b.add(:sans_serif_bold_italic, :normal, :font)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULG7TYSAOABVAXFQF33SRJIE7A5CNFSM4T7NMNGKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33N NVSW45C7NFSM4LFBE7DA.gif]

opoudjis commented 3 years ago

We will be doing that in a month or so; but this is a genuine gap in Asciimath coverage anyway, and should be filled whatever we end up doing. if fonts shfits are allowed over non-text, they should not ignore upright/normal font as an option. If it is legal to say ii(xyz), we should also be able to say rm(xyz).

pepijnve commented 3 years ago

@opoudjis I think 685fd2f does what you're asking for. Regarding the original issue, wouldn't using text rather than an identifier, as the poster asked, have worked as well?

pepijnve commented 3 years ago

BTW, I did not change the semantics of sfbi as you suggest in your description. Was that a typo?

opoudjis commented 3 years ago

Yes, typo.

We're trying to generate MathML compatible with the UnitsML proposed spec, which uses MathML <mi mathvariant="normal"> for units. While mtext will work, mi is what we'd prefer to do, and of course either mtext or mi will require the normal font shift anyway. (And yes, in the longer term, we will look at a Units/Asciimath hybrid markup, but we're not there yet.)

And yes, your update is what we were after, thank you!

opoudjis commented 3 years ago

@pepijnve, would it be possible to release asciimath soon? We're about to give a document to an external party using this functionality.

pepijnve commented 3 years ago

Sorry Nick, I kind of forgot about this one. I'll make a new release right away.

pepijnve commented 3 years ago

Fix is in https://rubygems.org/gems/asciimath/versions/2.0.2