New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal support for SIRange in LaTeX reader #6418
Conversation
Add support for \SIRange{firstnumber}{secondnumber}{unit} provided by siunitx. Support is implemented by new doSIRange function in src/Text/Pandoc/Readers/LaTeX.hs, which simply extends the existing dosiunitx function. Unit tests for doSIRange are in test/command/3587.md Example ------- Input (LaTeX): Something important happens \SIRange{100}{200}{\ms} after the event. Result (Markdown): Something important happens 100 ms to 200 ms after the event.
Thanks, this generally looks good!
|
Thanks for the input @jgm! I tried to implement the Translations fix but got a bit stuck. I tried inserting If it's too much trouble, I might just fall back to the en-dash fix myself. |
Hoogle is great: https://www.stackage.org/lts-15.15/hoogle?q=Text+-%3E+Inlines ah, I see you already found
P.S. back when I was learning this, I really liked learnyouahaskell.com |
Use an en-dash instead of "to" in doSIRange to support languages other than English.
Try to get a locale-based separator SI units in doSIRange ("to" in English) and fall back to an en-dash if one is not found. Currently, unit tests are only available for English using "to" as a separator.
Thanks everyone for your feedback! I ended up implementing both versions in separate commits.
The locale-based version might be a bit more brittle for a couple of reasons
Let me know if you have any ideas for how to address these issues, or whether you think it's ok as-is. Otherwise, I can always revert to the en-dash version. |
@jgm just wanted to flag that I implemented your suggestion in bdc370c: localTo <- translateTerm Translations.To
let separator = (if localTo /= ""
then text $ T.toLower localTo
else "\8211") This means that in an English locale we get the following translation, which is covered by unit tests. Something important happens \SIRange{100}{200}{\ms} after the event. Something important happens 100 ms to 200 ms after the event. If the translation can't be fetched, we get |
So I guess you're asking which branch should be preferred? |
Thanks for the comments @jgm! I think you're right that the en-dash is more robust, so I reverted to that version. Good catch about the spaces around the separator. I've removed them to be consistent with the native behaviour of SIRange. Let me know if there's anything else I can do to improve this PR! |
Excellent, thanks for contributing to pandoc! |
Hi @efharkin. Thanks a lot for going through the trouble of implementing this addition. I have had some trouble making it work for my conversions since the |
Oops, thanks for catching that @pauliacomi! That's what I get for implementing that feature on a different machine than my usual latex setup. Will submit a fix later today, just triple-checking that everything works first. |
This patch adds minimal support for
\SIRange{firstnumber}{secondnumber}{unit}
(provided by siunitx) consistent with existing support for\SI{value}{unit}
. Implementation is an extension of the existingdosiunitx
function in the LaTeX reader. Added unit tests for SIRange intest/command/3587.md
.Code passes all new and existing unit tests and compiles without warnings*.
This PR implements a fix for issue #6417.
Example
LaTeX input
Markdown output
*As far as I can tell... I don't see any warning messages when I compile normally. I'm completely new to haskell and
cabal build -Wall
andcabal test -Wall
both raise errors about unrecognized options, so it's possible there's something I've missed. If there's something different I should be doing please let me know.