From 0f98cbff4b61b8e79f386f77d18b3218f1214b25 Mon Sep 17 00:00:00 2001 From: Milan Bracke Date: Fri, 1 Oct 2021 11:34:14 +0200 Subject: Avoid blockquote when parent style has more indent When a paragraph has an indentation different from the parent (named) style, it used to be considered a blockquote. But this only makes sense when the paragraph has more indentation. So this commit adds a check for the indentation of the parent style. --- test/docx/relative_indentation_blockquotes.native | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/docx/relative_indentation_blockquotes.native (limited to 'test/docx/relative_indentation_blockquotes.native') diff --git a/test/docx/relative_indentation_blockquotes.native b/test/docx/relative_indentation_blockquotes.native new file mode 100644 index 000000000..37806f289 --- /dev/null +++ b/test/docx/relative_indentation_blockquotes.native @@ -0,0 +1,4 @@ +[Header 1 ("indentation-blockquotes",[],[]) [Str "Indentation",Space,Str "blockquotes"] +,Para [Str "Normal",Space,Str "list",Space,Str "paragraph"] +,Para [Str "List",Space,Str "paragraph",Space,Str "with",Space,Str "less",Space,Str "indent"] +,BlockQuote [Para [Str "List",Space,Str "paragraph",Space,Str "with",Space,Str "more",Space,Str "indent"]]] -- cgit v1.2.3 From 938d55784486f42d80cc4c2fcfe6ae905be382cd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 2 Nov 2021 14:02:24 -0700 Subject: Docx reader: don't let first line indents trigger block quotes. This fixes a regression introduced in pandoc 2.15 by PR #7606. Closes #7655. --- src/Text/Pandoc/Readers/Docx/Parse/Styles.hs | 5 ++--- test/docx/relative_indentation_blockquotes.docx | Bin 12492 -> 12655 bytes test/docx/relative_indentation_blockquotes.native | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'test/docx/relative_indentation_blockquotes.native') diff --git a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs index bb28b3009..df942579a 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse/Styles.hs @@ -310,9 +310,8 @@ getIndentation ns el = do , rightParIndent = findAttrByName ns "w" "right" indElement <|> findAttrByName ns "w" "end" indElement >>= stringToInteger - , hangingParIndent = (findAttrByName ns "w" "hanging" indElement >>= stringToInteger) <|> - fmap negate - (findAttrByName ns "w" "firstLine" indElement >>= stringToInteger) + , hangingParIndent = findAttrByName ns "w" "hanging" indElement >>= + stringToInteger } getElementStyleName :: Coercible T.Text a => NameSpaces -> Element -> Maybe a diff --git a/test/docx/relative_indentation_blockquotes.docx b/test/docx/relative_indentation_blockquotes.docx index f318a8509..fe252280e 100644 Binary files a/test/docx/relative_indentation_blockquotes.docx and b/test/docx/relative_indentation_blockquotes.docx differ diff --git a/test/docx/relative_indentation_blockquotes.native b/test/docx/relative_indentation_blockquotes.native index 37806f289..6a70aece8 100644 --- a/test/docx/relative_indentation_blockquotes.native +++ b/test/docx/relative_indentation_blockquotes.native @@ -1,4 +1,6 @@ [Header 1 ("indentation-blockquotes",[],[]) [Str "Indentation",Space,Str "blockquotes"] +,Para [Str "Foobar"] +,Para [Str "First",Space,Str "line",Space,Str "indented."] ,Para [Str "Normal",Space,Str "list",Space,Str "paragraph"] ,Para [Str "List",Space,Str "paragraph",Space,Str "with",Space,Str "less",Space,Str "indent"] ,BlockQuote [Para [Str "List",Space,Str "paragraph",Space,Str "with",Space,Str "more",Space,Str "indent"]]] -- cgit v1.2.3