diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2024-02-13 19:30:14 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2024-02-13 19:32:12 -0800 |
| commit | cf847b0138e07f8e0f009d7eb3f21a0e18d8708b (patch) | |
| tree | 37fb3958e15db6fe9c8961d62c7ed2db2734d8c6 /src/Text | |
| parent | 02b6483b7c4a671a2c4d86ef7f292dbe0b2d4b23 (diff) | |
LaTeX reader: improve treatment of cref, Cref.
Associate with `\cref` and `\Cref` the reference-type `ref+label` and
`ref+Label`. So far we don't do anything fancy with these.
Also, associate with `\vref` `ref` instead of `ref+page`.
See #7463.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Inline.hs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index e35912adc..05f0e9891 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -114,9 +114,9 @@ parseLaTeX = do resolveRefs :: M.Map Text [Inline] -> Inline -> Inline resolveRefs labels x@(Link (ident,classes,kvs) _ _) = - case (lookup "reference-type" kvs, + case (T.takeWhile (/='+') <$> lookup "reference-type" kvs, lookup "reference" kvs) of - (Just "ref", Just lab) -> + (Just "ref", Just lab) -> -- TODO special treatment of ref+label case M.lookup lab labels of Just txt -> Link (ident,classes,kvs) txt ("#" <> lab, "") Nothing -> x diff --git a/src/Text/Pandoc/Readers/LaTeX/Inline.hs b/src/Text/Pandoc/Readers/LaTeX/Inline.hs index 3fc004524..757d0931b 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Inline.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Inline.hs @@ -337,11 +337,11 @@ refCommands :: PandocMonad m => M.Map Text (LP m Inlines) refCommands = M.fromList [ ("label", rawInlineOr "label" dolabel) , ("ref", rawInlineOr "ref" $ doref "ref") - , ("cref", rawInlineOr "cref" $ doref "ref") -- from cleveref.sty - , ("Cref", rawInlineOr "Cref" $ doref "ref") -- from cleveref.sty - , ("vref", rawInlineOr "vref" $ doref "ref+page") -- from varioref.sty + , ("cref", rawInlineOr "cref" $ doref "ref+label") -- from cleveref.sty + , ("Cref", rawInlineOr "Cref" $ doref "ref+Label") -- from cleveref.sty + , ("vref", rawInlineOr "vref" $ doref "ref") -- from varioref.sty , ("eqref", rawInlineOr "eqref" $ doref "eqref") -- from amsmath.sty - , ("autoref", rawInlineOr "autoref" $ doref "autoref") -- from hyperref.sty + , ("autoref", rawInlineOr "autoref" $ doref "ref+label") -- from hyperref.sty ] acronymCommands :: PandocMonad m => M.Map Text (LP m Inlines) |
