"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Text/Pandoc/Readers/Markdown.hs" between
pandoc-2.11.1.1.tar.gz and pandoc-2.11.2.tar.gz

About: Pandoc converts files from one markup format into another.

Markdown.hs  (pandoc-2.11.1.1):Markdown.hs  (pandoc-2.11.2)
skipping to change at line 1535 skipping to change at line 1535
' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space
_ -> return $ return $ B.str $ T.singleton result _ -> return $ return $ B.str $ T.singleton result
ltSign :: PandocMonad m => MarkdownParser m (F Inlines) ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
ltSign = do ltSign = do
guardDisabled Ext_raw_html guardDisabled Ext_raw_html
<|> (notFollowedByHtmlCloser >> notFollowedBy' (htmlTag isBlockTag)) <|> (notFollowedByHtmlCloser >> notFollowedBy' (htmlTag isBlockTag))
char '<' char '<'
return $ return $ B.str "<" return $ return $ B.str "<"
-- Note that if the citations extension is enabled, example refs will be
-- parsed as citations, and handled by a clause in the parser for citations,
-- since we won't know whether we have an example ref until the
-- whole document has been parsed. But we need this parser
-- here in case citations is disabled.
exampleRef :: PandocMonad m => MarkdownParser m (F Inlines) exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
exampleRef = try $ do exampleRef = try $ do
guardEnabled Ext_example_lists guardEnabled Ext_example_lists
char '@' char '@'
lab <- many1Char (alphaNum <|> oneOf "-_") lab <- mconcat . map T.pack <$>
many (many1 alphaNum <|>
try (do c <- char '_' <|> char '-'
cs <- many1 alphaNum
return (c:cs)))
return $ do return $ do
st <- askF st <- askF
return $ case M.lookup lab (stateExamples st) of return $ case M.lookup lab (stateExamples st) of
Just n -> B.str $ tshow n Just n -> B.str $ tshow n
Nothing -> B.str $ "@" <> lab Nothing -> B.str $ "@" <> lab
symbol :: PandocMonad m => MarkdownParser m (F Inlines) symbol :: PandocMonad m => MarkdownParser m (F Inlines)
symbol = do symbol = do
result <- noneOf "<\\\n\t " result <- noneOf "<\\\n\t "
<|> try (do lookAhead $ char '\\' <|> try (do lookAhead $ char '\\'
skipping to change at line 2066 skipping to change at line 2075
inNote <- stateInNote <$> getState inNote <- stateInNote <$> getState
unless inNote $ unless inNote $
updateState $ \st -> st{ stateNoteNumber = stateNoteNumber st + 1 } updateState $ \st -> st{ stateNoteNumber = stateNoteNumber st + 1 }
textualCite textualCite
<|> do (cs, raw) <- withRaw normalCite <|> do (cs, raw) <- withRaw normalCite
return $ flip B.cite (B.text raw) <$> cs return $ flip B.cite (B.text raw) <$> cs
textualCite :: PandocMonad m => MarkdownParser m (F Inlines) textualCite :: PandocMonad m => MarkdownParser m (F Inlines)
textualCite = try $ do textualCite = try $ do
(suppressAuthor, key) <- citeKey (suppressAuthor, key) <- citeKey
-- If this is a reference to an earlier example list item,
-- then don't parse it as a citation. If the example list
-- item comes later, we'll parse it here and figure out in
-- the runF stage if it's a citation. But it helps with
-- issue #6836 to filter out known example list references
-- at this stage, so that we don't increment stateNoteNumber.
getState >>= guard . isNothing . M.lookup key . stateExamples
noteNum <- stateNoteNumber <$> getState noteNum <- stateNoteNumber <$> getState
let first = Citation{ citationId = key let first = Citation{ citationId = key
, citationPrefix = [] , citationPrefix = []
, citationSuffix = [] , citationSuffix = []
, citationMode = if suppressAuthor , citationMode = if suppressAuthor
then SuppressAuthor then SuppressAuthor
else AuthorInText else AuthorInText
, citationNoteNum = noteNum , citationNoteNum = noteNum
, citationHash = 0 , citationHash = 0
} }
mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite (do -- parse [braced] material after author-in-text cite
case mbrest of (cs, raw) <- withRaw $
Just (rest, raw) -> (fmap (first:) <$> try (spnl *> normalCite))
return $ flip B.cite (B.text $ "@" <> key <> " " <> raw) . (first:) <|> bareloc first
<$> rest let (spaces',raw') = T.span isSpace raw
Nothing -> spc | T.null spaces' = mempty
(do | otherwise = B.space
(cs, raw) <- withRaw $ bareloc first lab <- parseFromString' inlines $ dropBrackets raw'
let (spaces',raw') = T.span isSpace raw fallback <- referenceLink B.linkWith (lab,raw')
spc | T.null spaces' = mempty -- undo any incrementing of stateNoteNumber from last step:
| otherwise = B.space updateState $ \st -> st{ stateNoteNumber = noteNum }
lab <- parseFromString' inlines $ dropBrackets raw' return $ do
fallback <- referenceLink B.linkWith (lab,raw') fallback' <- fallback
return $ do cs' <- cs
fallback' <- fallback return $
cs' <- cs case B.toList fallback' of
return $ Link{}:_ -> B.cite [first] (B.str $ "@" <> key) <> spc <> fallback'
case B.toList fallback' of _ -> B.cite cs' (B.text $ "@" <> key <> " " <> raw))
Link{}:_ -> B.cite [first] (B.str $ "@" <> key) <> spc <> fallba <|> -- no braced material
ck' return (do st <- askF
_ -> B.cite cs' (B.text $ "@" <> key <> " " <> raw)) return $ case M.lookup key (stateExamples st) of
<|> return (do st <- askF Just n -> B.str $ tshow n
return $ case M.lookup key (stateExamples st) of _ -> B.cite [first] $ B.str $ "@" <> key)
Just n -> B.str $ tshow n
_ -> B.cite [first] $ B.str $ "@" <> key)
bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation]) bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation])
bareloc c = try $ do bareloc c = try $ do
spnl spnl
char '[' char '['
notFollowedBy $ char '^' notFollowedBy $ char '^'
suff <- suffix suff <- suffix
rest <- option (return []) $ try $ char ';' >> citeList rest <- option (return []) $ try $ char ';' >> spnl >> citeList
spnl spnl
char ']' char ']'
notFollowedBy $ oneOf "[(" notFollowedBy $ oneOf "[("
return $ do return $ do
suff' <- suff suff' <- suff
rest' <- rest rest' <- rest
return $ c{ citationSuffix = B.toList suff' } : rest' return $ c{ citationSuffix = B.toList suff' } : rest'
normalCite :: PandocMonad m => MarkdownParser m (F [Citation]) normalCite :: PandocMonad m => MarkdownParser m (F [Citation])
normalCite = try $ do normalCite = try $ do
skipping to change at line 2136 skipping to change at line 2151
suffix = try $ do suffix = try $ do
hasSpace <- option False (notFollowedBy nonspaceChar >> return True) hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
spnl spnl
rest <- trimInlinesF . mconcat <$> many (notFollowedBy (oneOf ";]") >> inline) rest <- trimInlinesF . mconcat <$> many (notFollowedBy (oneOf ";]") >> inline)
return $ if hasSpace return $ if hasSpace
then (B.space <>) <$> rest then (B.space <>) <$> rest
else rest else rest
prefix :: PandocMonad m => MarkdownParser m (F Inlines) prefix :: PandocMonad m => MarkdownParser m (F Inlines)
prefix = trimInlinesF . mconcat <$> prefix = trimInlinesF . mconcat <$>
manyTill inline (char ']' <|> fmap (const ']') (lookAhead citeKey)) manyTill inline (char ']'
<|> lookAhead
(try $ do optional (try (char ';' >> spnl))
citeKey
return ']'))
citeList :: PandocMonad m => MarkdownParser m (F [Citation]) citeList :: PandocMonad m => MarkdownParser m (F [Citation])
citeList = fmap sequence $ sepBy1 citation (try $ char ';' >> spnl) citeList = fmap sequence $ sepBy1 citation (try $ char ';' >> spnl)
citation :: PandocMonad m => MarkdownParser m (F Citation) citation :: PandocMonad m => MarkdownParser m (F Citation)
citation = try $ do citation = try $ do
pref <- prefix pref <- prefix
(suppress_author, key) <- citeKey (suppress_author, key) <- citeKey
suff <- suffix suff <- suffix
noteNum <- stateNoteNumber <$> getState noteNum <- stateNoteNumber <$> getState
 End of changes. 6 change blocks. 
28 lines changed or deleted 46 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)