diff --git a/pandoc.cabal b/pandoc.cabal index e4e3694b2..c0b37526a 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -281,6 +281,9 @@ extra-source-files: test/command/11486/scroll.revealjs test/command/11498.png test/command/11301-styles.opendocument + test/command/11888/section1/lab.md + test/command/11888/section2/lab.md + test/command/11888/section3/lab.md test/asciidoc-reader.adoc test/asciidoc-reader.native test/asciidoc-reader-include.rb diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 7c3573a32..c5153f6dc 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -815,6 +815,7 @@ emailBlockQuote = try $ do blockQuote :: PandocMonad m => MarkdownParser m (F Blocks) blockQuote = do + pos <- getPosition raw <- emailBlockQuote (mbAlert, raw') <- (do guardEnabled Ext_alerts @@ -830,7 +831,8 @@ blockQuote = do _ -> pure (Nothing, raw)) <|> pure (Nothing, raw) -- parse the extracted block, which may contain various block elements: - contents <- parseFromString' parseBlocks $ T.intercalate "\n" raw' <> "\n\n" + contents <- parseFromString' (setPosition pos >> parseBlocks) + $ T.intercalate "\n" raw' <> "\n\n" return $ case mbAlert of Nothing -> B.blockQuote <$> contents @@ -972,11 +974,12 @@ listItem fourSpaceRule start = try $ do state <- getState let oldContext = stateParserContext state setState $ state {stateParserContext = ListItemState} + pos <- getPosition (first, continuationIndent) <- rawListItem fourSpaceRule start continuations <- many (listContinuation continuationIndent) -- parse the extracted block, which may contain various block elements: let raw = T.concat (first:continuations) - contents <- parseFromString' parseBlocks raw + contents <- parseFromString' (setPosition pos >> parseBlocks) raw updateState (\st -> st {stateParserContext = oldContext}) exts <- getOption readerExtensions return $ B.fromList . taskListItemFromAscii exts . B.toList <$> contents @@ -1017,8 +1020,9 @@ defListStart = do definitionListItem :: PandocMonad m => MarkdownParser m (F (Inlines, [Blocks])) definitionListItem = try $ do + pos <- getPosition rawLine' <- anyLine - term <- parseFromString' (trimInlinesF <$> inlines) rawLine' + term <- parseFromString' (setPosition pos >> (trimInlinesF <$> inlines)) rawLine' isTight <- (False <$ blanklines) <|> pure True fourSpaceRule <- (True <$ guardEnabled Ext_four_space_rule) <|> pure False contents <- many1 $ listItem fourSpaceRule defListStart @@ -1224,8 +1228,9 @@ lineBlock :: PandocMonad m => MarkdownParser m (F Blocks) lineBlock = do guardEnabled Ext_line_blocks try $ do + pos <- getPosition lines' <- lineBlockLines >>= - mapM (parseFromString' (trimInlinesF <$> inlines)) + mapM (parseFromString' (setPosition pos >> (trimInlinesF <$> inlines))) return $ B.lineBlock <$> sequence lines' -- @@ -1312,8 +1317,9 @@ rawTableLine indices = do tableLine :: PandocMonad m => [Int] -> MarkdownParser m (F [Blocks]) -tableLine indices = rawTableLine indices >>= - fmap sequence . mapM (parseFromString' (mconcat <$> many plain)) +tableLine indices = do + raw <- rawTableLine indices + sequence <$> mapM (parseFromString' (mconcat <$> many plain)) raw -- Parse a multiline table row and return a list of blocks (columns). multilineRow :: PandocMonad m @@ -1398,7 +1404,7 @@ multilineTableHeader headless = try $ do then [] else map (T.unlines . map trim) rawHeadsList heads <- fmap sequence $ - mapM (parseFromString' (mconcat <$> many plain).trim) rawHeads + mapM (parseFromString' (mconcat <$> many plain) . trim) rawHeads return (fmap (:[]) heads, aligns, indices') -- Parse a grid table: starts with row of '-' on top, then header diff --git a/test/command/11888.md b/test/command/11888.md new file mode 100644 index 000000000..93b4960bc --- /dev/null +++ b/test/command/11888.md @@ -0,0 +1,46 @@ +``` +% pandoc -f markdown+rebase_relative_paths command/11888/section1/lab.md command/11888/section2/lab.md command/11888/section3/lab.md +^D +

Heading 1

+
+pic 1 + +
+
+

a blockquote

+
+pic 2 + +
+

with an image reference

+
+pic 3 + +
+
+

Heading 2

+
+pic 3 + +
+
    +
  1. A list

    +
    +pic 4 + +
  2. +
+

Heading 3

+
+pic 5 + +
+
    +
  1. A list

    +
    +pic 6 + +
  2. +
+ +``` diff --git a/test/command/11888/section1/lab.md b/test/command/11888/section1/lab.md new file mode 100644 index 000000000..f0cccd2b8 --- /dev/null +++ b/test/command/11888/section1/lab.md @@ -0,0 +1,11 @@ +# Heading 1 + +![pic 1](media/Pic1_1.png) + +> a blockquote +> +> ![pic 2](media/Pic1_2.png) +> +> with an image reference +> +> ![pic 3](media/Pic1_3.png) \ No newline at end of file diff --git a/test/command/11888/section2/lab.md b/test/command/11888/section2/lab.md new file mode 100644 index 000000000..b3ae52b75 --- /dev/null +++ b/test/command/11888/section2/lab.md @@ -0,0 +1,8 @@ +# Heading 2 + +![pic 3](media/Pic2_1.png) + +1. A list + + ![pic 4](media/Pic2_2.png) + diff --git a/test/command/11888/section3/lab.md b/test/command/11888/section3/lab.md new file mode 100644 index 000000000..e19e111e6 --- /dev/null +++ b/test/command/11888/section3/lab.md @@ -0,0 +1,7 @@ +# Heading 3 + +![pic 5](media/Pic3_1.png) + +1. A list + + ![pic 6](media/Pic3_2.png) \ No newline at end of file diff --git a/test/command/9635.md b/test/command/9635.md index 088a5b6d2..5b5ca7950 100644 --- a/test/command/9635.md +++ b/test/command/9635.md @@ -6,7 +6,7 @@ okay ^D -2> [WARNING] Div at _chunk line 1 column 1 unclosed at _chunk line 5 column 1, closing implicitly. +2> [WARNING] Div at line 1 column 1 unclosed at line 5 column 1, closing implicitly.

that is not closed