aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 27c018e73..20a2db76b 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -390,8 +390,8 @@ inlineCommands = M.unions
unescapeURL .
removeDoubleQuotes $ untokenize src)
-- hyperref
- , ("url", (\url -> link url "" (str url)) . unescapeURL . untokenize <$>
- bracedUrl)
+ , ("url", (\url -> linkWith ("",["uri"],[]) url "" (str url))
+ . unescapeURL . untokenize <$> bracedUrl)
, ("nolinkurl", code . unescapeURL . untokenize <$> bracedUrl)
, ("href", do url <- bracedUrl
sp
@@ -893,7 +893,7 @@ blockCommands = M.fromList
addMeta "bibliography" . splitBibs . untokenize))
, ("addbibresource", mempty <$ (skipopts *> braced >>=
addMeta "bibliography" . splitBibs . untokenize))
- , ("endinput", mempty <$ skipMany anyTok)
+ , ("endinput", mempty <$ skipSameFileToks)
-- includes
, ("lstinputlisting", inputListing)
, ("inputminted", inputMinted)
@@ -924,6 +924,10 @@ blockCommands = M.fromList
, ("epigraph", epigraph)
]
+skipSameFileToks :: PandocMonad m => LP m ()
+skipSameFileToks = do
+ pos <- getPosition
+ skipMany $ infile (sourceName pos)
environments :: PandocMonad m => M.Map Text (LP m Blocks)
environments = M.union (tableEnvironments blocks inline) $
@@ -970,6 +974,7 @@ environments = M.union (tableEnvironments blocks inline) $
, ("toggletrue", braced >>= setToggle True)
, ("togglefalse", braced >>= setToggle False)
, ("iftoggle", try $ ifToggle >> block)
+ , ("CSLReferences", braced >> braced >> env "CSLReferences" blocks)
]
filecontents :: PandocMonad m => LP m Blocks
@@ -1109,24 +1114,28 @@ figure = try $ do
addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
addImageCaption = walkM go
- where go (Image attr@(_, cls, kvs) alt (src,tit))
+ where go p@(Para [Image attr@(_, cls, kvs) _ (src, tit)])
| not ("fig:" `T.isPrefixOf` tit) = do
st <- getState
- let (alt', tit') = case sCaption st of
- Just ils -> (toList ils, "fig:" <> tit)
- Nothing -> (alt, tit)
- attr' = case sLastLabel st of
- Just lab -> (lab, cls, kvs)
- Nothing -> attr
- case attr' of
- ("", _, _) -> return ()
- (ident, _, _) -> do
- num <- getNextNumber sLastFigureNum
- setState
- st{ sLastFigureNum = num
- , sLabels = M.insert ident
- [Str (renderDottedNum num)] (sLabels st) }
- return $ Image attr' alt' (src, tit')
+ case sCaption st of
+ Nothing -> return p
+ Just figureCaption -> do
+ let mblabel = sLastLabel st
+ let attr' = case mblabel of
+ Just lab -> (lab, cls, kvs)
+ Nothing -> attr
+ case attr' of
+ ("", _, _) -> return ()
+ (ident, _, _) -> do
+ num <- getNextNumber sLastFigureNum
+ setState
+ st{ sLastFigureNum = num
+ , sLabels = M.insert ident
+ [Str (renderDottedNum num)] (sLabels st) }
+
+ return $ SimpleFigure attr'
+ (maybe id removeLabel mblabel (B.toList figureCaption))
+ (src, tit)
go x = return x
coloredBlock :: PandocMonad m => Text -> LP m Blocks