diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-08-16 10:46:56 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-08-16 10:56:12 -0700 |
commit | db715ca84797c8fc945392b61c1642434e8fb2b1 (patch) | |
tree | dff15b9544e3c8af1a14a1785f50c7e5cd581454 /src/Text/Pandoc | |
parent | c6ec189a966c100a7992cc633d88efdd176c2a46 (diff) | |
download | pandoc-db715ca84797c8fc945392b61c1642434e8fb2b1.tar.gz |
LaTeX reader: use Link instead of Span for `\ref`.
This makes more sense semantically and avoids unnecessary
Span [Link] nestings when references are resolved.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 5627e4ee1..6b96460e8 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -111,13 +111,12 @@ parseLaTeX = do return $ Pandoc meta bs' resolveRefs :: M.Map String [Inline] -> Inline -> Inline -resolveRefs labels x@(Span (ident,classes,kvs) _) = +resolveRefs labels x@(Link (ident,classes,kvs) _ _) = case (lookup "reference-type" kvs, lookup "reference" kvs) of (Just "ref", Just lab) -> case M.lookup lab labels of - Just txt -> Span (ident,classes,kvs) - [Link nullAttr txt ('#':lab, "")] + Just txt -> Link (ident,classes,kvs) txt ('#':lab, "") Nothing -> x _ -> x resolveRefs _ x = x @@ -1538,9 +1537,11 @@ doref :: PandocMonad m => String -> LP m Inlines doref cls = do v <- braced let refstr = toksToString v - return $ spanWith ("",[],[ ("reference-type", cls) + return $ linkWith ("",[],[ ("reference-type", cls) , ("reference", refstr)]) - $ inBrackets $ str refstr + ('#':refstr) + "" + (inBrackets $ str refstr) lookupListDefault :: (Show k, Ord k) => v -> [k] -> M.Map k v -> v lookupListDefault d = (fromMaybe d .) . lookupList |