From db715ca84797c8fc945392b61c1642434e8fb2b1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 16 Aug 2017 10:46:56 -0700 Subject: LaTeX reader: use Link instead of Span for `\ref`. This makes more sense semantically and avoids unnecessary Span [Link] nestings when references are resolved. --- src/Text/Pandoc/Readers/LaTeX.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') 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 -- cgit v1.2.3