aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorschrieveslaach <schrieveslaach@online.de>2017-08-13 19:58:45 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-13 10:58:45 -0700
commit2845ab59769709cbc250aa4ac116efbdcdf3412b (patch)
tree753b0a066a463962cad3f05f99e2f61ece62a3df /src/Text/Pandoc/Readers
parent8f65590ce9fc84452b22a3914190a8d9bc4ceda2 (diff)
downloadpandoc-2845ab59769709cbc250aa4ac116efbdcdf3412b.tar.gz
Put content of \ref, \label commands into span… (#3639)
* Put content of `\ref` and `\label` commands into Span elements so they can be used in filters. * Add support for `\eqref`
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 284dce2bc..498e97b8c 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1165,11 +1165,13 @@ inlineCommands = M.fromList $
, ("dots", lit "…")
, ("mdots", lit "…")
, ("sim", lit "~")
- , ("label", rawInlineOr "label" (inBrackets <$> tok))
- , ("ref", rawInlineOr "ref" (inBrackets <$> tok))
, ("textgreek", tok)
, ("sep", lit ",")
- , ("cref", rawInlineOr "cref" (inBrackets <$> tok)) -- from cleveref.sty
+ , ("label", rawInlineOr "label" dolabel)
+ , ("ref", rawInlineOr "ref" $ doref "ref")
+ , ("cref", rawInlineOr "cref" $ doref "ref") -- from cleveref.sty
+ , ("vref", rawInlineOr "vref" $ doref "ref+page") -- from varioref.sty
+ , ("eqref", rawInlineOr "eqref" $ doref "eqref") -- from amsmath.sty
, ("(", mathInline . toksToString <$> manyTill anyTok (controlSeq ")"))
, ("[", mathDisplay . toksToString <$> manyTill anyTok (controlSeq "]"))
, ("ensuremath", mathInline . toksToString <$> braced)
@@ -1443,6 +1445,18 @@ treatAsInline = Set.fromList
, "pagebreak"
]
+dolabel :: PandocMonad m => LP m Inlines
+dolabel = do
+ v <- braced
+ return $ spanWith ("",[],[("label", toksToString v)])
+ $ inBrackets $ str $ toksToString v
+
+doref :: PandocMonad m => String -> LP m Inlines
+doref cls = do
+ v <- braced
+ return $ spanWith ("",[],[("reference-type", cls), ("reference", toksToString v)])
+ $ inBrackets $ str $ toksToString v
+
lookupListDefault :: (Show k, Ord k) => v -> [k] -> M.Map k v -> v
lookupListDefault d = (fromMaybe d .) . lookupList
where lookupList l m = msum $ map (`M.lookup` m) l