Skip to content
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

LaTeX reader: RN and Rn, from biblatex #3854

Merged
merged 2 commits into from
Aug 24, 2017
Merged

LaTeX reader: RN and Rn, from biblatex #3854

merged 2 commits into from
Aug 24, 2017

Conversation

bucklereed
Copy link
Contributor

@bucklereed bucklereed commented Aug 20, 2017

This is not bug-for-bug compatible: it barfs on weird input, whereas biblatex will accept just about anything that starts with a digit and several things that don't. Is that acceptable?

I had a go at bug-for-bug compatibility, but the implementation was getting a little bit silly. Here are the test cases that I cut out when I gave up:

          , "internal spaces" =:
            "\\RN{ 2 3 }" =?>
            para (str "II3")
          , "internal spaces many words" =:
            "\\RN{5 hello there}" =?>
            para (str "V" <> str "HELLO" <> space <> "THERE")
          , "newlines" =:
            "\\RN{\n15\n17\n}" =?>
            para (str "XV17")
          , "number then space then non-number" =:
            "\\Rn{5 HELLO}" =?>
            para (str "vHELLO")
          , "number then non-number, non-number gets upcased by RN" =:
            "\\RN{4hello}" =?>
            para (str "IVHELLO")
          , "internal command" =:
            "\\Rn{4\\textit{8}}" =?>
            para (str "iv" <> emph (str "8"))
          , "dotted" =:
            "\\RN{3.8}" =?>
            para (str "III.8")
          , "negative" =:
            "\\RN{-3}" =?>
            (mempty :: Blocks)
          , "double negative" =:
            "\\RN{--3}" =?>
            para (str "III")
          , "triple negative" =:
            "\\RN{---3 2}" =?>
            para (str "2")
          , "quadruple negative" =:
            "\\RN{----3 2}" =?>
            para (str "III2")
          , "negative zero" =:
            "\\RN{-0}" =?>
            (mempty :: Blocks)
          , "spaced negative" =:
            "\\RN{- 3 5}" =?>
            para (str "5")
          , "spaced double negative" =:
            "\\Rn{- - 3 5}" =?>
            para (str "iii5")
          , "internal hyphen" =:
            "\\RN{3-5}" =?>
            para (str "III-5")
          , "space then unbraced argument" =:
            "\\RN 7 ok" =?>
            para (str "VII" <> space <> str "ok")
          , "space then unbraced argument with trailing nondigits" =:
            "\\RN 7ok" =?>
            para (str "VIIok")
          , "multiple zeroes" =:
            "\\Rn{0 0 3}" =?>
            para (str "0" <> space <> str "3")
          -- The next cases cause errors when processed by LaTeX, but we would rather produce wonky output than fail.
          -- Other things that make biblatex error, and hence which we don't mind if they don't work:
          -- - "\\RN{hello}"
          -- - "\\RN\n\n"
          , "argument in textit" =:
            "\\RN{\\textit{8}}" =?>
            para (emph (str "8"))
          , "leading dot" =:
            "\\Rn{.3}" =?>
            para (str ".3")
          , "empty brace" =:
            "\\RN{}" =?>
            (mempty :: Blocks)

More things that don't work:

  • "\RN{{3}}"
  • "\Rn \bgroup 13 \egroup"

@bucklereed
Copy link
Contributor Author

Oops, I think I've just found a better implementation anyway. It's funny how that always seems to happen after the pull request, and not before...

@bucklereed
Copy link
Contributor Author

👍 Travis is complaining, but that looks like more HEAD breakage (I didn't even touch that module) and it's green on newer GHCs.

@jgm
Copy link
Owner

jgm commented Aug 24, 2017

"\RN{{3}}"
"\Rn \bgroup 13 \egroup"

Have you looked at using grouped?

@bucklereed
Copy link
Contributor Author

Sorry, I wasn't clear there: those don't work in LaTeX, and the current implementation reflects that.

@jgm jgm merged commit c80e26f into jgm:master Aug 24, 2017
@jgm
Copy link
Owner

jgm commented Aug 24, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants