summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-08-14 10:07:14 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-08-14 10:07:14 -0700
commit6067e477acd933316ba23a1838aafffad872f627 (patch)
treeff3a3cb99c9052a9bd7803298a29b8e7b9b7898e
parent948567f200ddaf59c87d0155bb0d652930601a61 (diff)
Docx reader: Avoid spurious block quotes in list items.
The docx reader was overzealous in detecting indented paragraphs as block quotes, leading to list items sometimes being put in block quotes (especially in docx created by Google Docs). Closes #8836.
-rw-r--r--src/Text/Pandoc/Readers/Docx.hs8
-rw-r--r--test/docx/lists_level_override.native303
2 files changed, 270 insertions, 41 deletions
diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs
index c1dd3dff4..4ab40f5a6 100644
--- a/src/Text/Pandoc/Readers/Docx.hs
+++ b/src/Text/Pandoc/Readers/Docx.hs
@@ -624,10 +624,10 @@ extraAttr s = ("", [], [("custom-style", fromStyleName $ getStyleName s)])
paragraphStyleToTransform :: PandocMonad m => ParagraphStyle -> DocxContext m (Blocks -> Blocks)
paragraphStyleToTransform pPr =
- let stylenames = map getStyleName (pStyle pPr)
- transform = if (`elem` listParagraphStyles) `any` stylenames || relativeIndent pPr <= 0
- then id
- else blockQuote
+ let transform = if relativeIndent pPr > 0 && not (numbered pPr) &&
+ not (any ((`elem` listParagraphStyles) . getStyleName) (pStyle pPr))
+ then blockQuote
+ else id
in do
extStylesEnabled <- asks (isEnabled Ext_styles . docxOptions)
return $ foldr (\parStyle transform' ->
diff --git a/test/docx/lists_level_override.native b/test/docx/lists_level_override.native
index 6919e6c8d..1f33bf621 100644
--- a/test/docx/lists_level_override.native
+++ b/test/docx/lists_level_override.native
@@ -1,37 +1,266 @@
-[Para [Str "For",Space,Str "each",Space,Str "initiative",Space,Str "below",Space,Str "is",Space,Str "outlined",Space,Str "the",Space,Str "goals,",Space,Str "an",Space,Str "approximate",Space,Str "roadmap",Space,Str "which",Space,Str "will",Space,Str "likely",Space,Str "change",Space,Str "as",Space,Str "we",Space,Str "iterate,",Space,Str "signals/metrics",Space,Str "to",Space,Str "measure",Space,Str "success,",Space,Str "and",Space,Str "initial",Space,Str "workitems",Space,Str "with",Space,Str "a",Space,Str "rough",Space,Strong [Str "schedule"],Space,Str "and",Space,Str "contacts",Space,Str "where",Space,Str "available:"]
-,Para [Str "\160"]
-,OrderedList (1,Decimal,Period)
- [[BlockQuote
- [Para [Str "State",Space,Str "of",Space,Str "Documentation"]]]]
-,BlockQuote
- [Para [Strong [Str "Goal:",Space,Str "Baseline",Space,Str "and",Space,Str "ongoing",Space,Str "metrics",Space,Str "tracking",Space,Str "doc",Space,Str "usefulness",Space,Str "and",Space,Str "completeness."]]
- ,Para [Str "\160"]]
-,OrderedList (2,Decimal,Period)
- [[BlockQuote
- [Para [Str "Content",Space,Str "Migration"]]]]
-,BlockQuote
- [Para [Str "Goal:",Space,Str "Content",Space,Str "is",Space,Str "accessible",Space,Str "to",Space,Str "new",Space,Str "employees",Space,Str "and",Space,Str "is",Space,Str "better",Space,Str "organized/archived."]
- ,Para [Str "\160"]]
-,OrderedList (3,Decimal,Period)
- [[BlockQuote
- [Para [Str "Wiki",Space,Str "(xl)"]]]]
-,BlockQuote
- [Para [Strong [Str "Goal:",Space,Str "Useful",Space,Str "documentation",Space,Str "that",Space,Str "is",Space,Str "archived,",Space,Str "searchable",Space,Str "and",Space,Str "easy",Space,Str "to",Space,Str "create"]]
- ,Para [Str "\160\160"]]
-,OrderedList (4,Decimal,Period)
- [[BlockQuote
- [Para [Str "XL",Space,Str "Code",Space,Str "Autoreview",Space,Str "Bot",Space,Str "(XLCRBot)."]]]]
-,BlockQuote
- [Para [Strong [Str "Goal:",Space,Str "Feedback",Space,Str "on",Space,Str "basic",Space,Str "violations",Space,Str "in",Space,Str "seconds",Space,Str "or",Space,Str "minutes",Space,Str "at",Space,Str "most",Space,Str "in",Space,Str "either",Space,Str "VS",Space,Str "or",Space,Str "Codeflow."]]]
-,OrderedList (5,Decimal,Period)
- [[BlockQuote
- [Para [Str "Code",Space,Str "documentation"]]]]
-,BlockQuote
- [Para [Strong [Str "Goal:",Space,Str "Useful,",Space,Str "consistent,",Space,Str "tool",Space,Str "supported",Space,Str "comments"]]]
-,Para [Strong [Str "\160"],Str "\160"]
-,OrderedList (6,Decimal,Period)
- [[BlockQuote
- [Para [Str "Education",Space,Str "efforts"]]]]
-,BlockQuote
- [Para [Strong [Str "Goal:",Space,Str "Broad,",Space,Str "discoverable",Space,Str "channels",Space,Str "for",Space,Str "updates",Space,Str "and",Space,Str "news"]]]
-,Para [Strong [Str "\160"]]]
+Pandoc
+ Meta { unMeta = fromList [] }
+ [ Para
+ [ Str "For"
+ , Space
+ , Str "each"
+ , Space
+ , Str "initiative"
+ , Space
+ , Str "below"
+ , Space
+ , Str "is"
+ , Space
+ , Str "outlined"
+ , Space
+ , Str "the"
+ , Space
+ , Str "goals,"
+ , Space
+ , Str "an"
+ , Space
+ , Str "approximate"
+ , Space
+ , Str "roadmap"
+ , Space
+ , Str "which"
+ , Space
+ , Str "will"
+ , Space
+ , Str "likely"
+ , Space
+ , Str "change"
+ , Space
+ , Str "as"
+ , Space
+ , Str "we"
+ , Space
+ , Str "iterate,"
+ , Space
+ , Str "signals/metrics"
+ , Space
+ , Str "to"
+ , Space
+ , Str "measure"
+ , Space
+ , Str "success,"
+ , Space
+ , Str "and"
+ , Space
+ , Str "initial"
+ , Space
+ , Str "workitems"
+ , Space
+ , Str "with"
+ , Space
+ , Str "a"
+ , Space
+ , Str "rough"
+ , Space
+ , Strong [ Str "schedule" ]
+ , Space
+ , Str "and"
+ , Space
+ , Str "contacts"
+ , Space
+ , Str "where"
+ , Space
+ , Str "available:"
+ ]
+ , Para [ Str "\160" ]
+ , OrderedList
+ ( 1 , Decimal , Period )
+ [ [ Para
+ [ Str "State"
+ , Space
+ , Str "of"
+ , Space
+ , Str "Documentation"
+ ]
+ ]
+ ]
+ , BlockQuote
+ [ Para
+ [ Strong
+ [ Str "Goal:"
+ , Space
+ , Str "Baseline"
+ , Space
+ , Str "and"
+ , Space
+ , Str "ongoing"
+ , Space
+ , Str "metrics"
+ , Space
+ , Str "tracking"
+ , Space
+ , Str "doc"
+ , Space
+ , Str "usefulness"
+ , Space
+ , Str "and"
+ , Space
+ , Str "completeness."
+ ]
+ ]
+ , Para [ Str "\160" ]
+ ]
+ , OrderedList
+ ( 2 , Decimal , Period )
+ [ [ Para [ Str "Content" , Space , Str "Migration" ] ] ]
+ , BlockQuote
+ [ Para
+ [ Str "Goal:"
+ , Space
+ , Str "Content"
+ , Space
+ , Str "is"
+ , Space
+ , Str "accessible"
+ , Space
+ , Str "to"
+ , Space
+ , Str "new"
+ , Space
+ , Str "employees"
+ , Space
+ , Str "and"
+ , Space
+ , Str "is"
+ , Space
+ , Str "better"
+ , Space
+ , Str "organized/archived."
+ ]
+ , Para [ Str "\160" ]
+ ]
+ , OrderedList
+ ( 3 , Decimal , Period )
+ [ [ Para [ Str "Wiki" , Space , Str "(xl)" ] ] ]
+ , BlockQuote
+ [ Para
+ [ Strong
+ [ Str "Goal:"
+ , Space
+ , Str "Useful"
+ , Space
+ , Str "documentation"
+ , Space
+ , Str "that"
+ , Space
+ , Str "is"
+ , Space
+ , Str "archived,"
+ , Space
+ , Str "searchable"
+ , Space
+ , Str "and"
+ , Space
+ , Str "easy"
+ , Space
+ , Str "to"
+ , Space
+ , Str "create"
+ ]
+ ]
+ , Para [ Str "\160\160" ]
+ ]
+ , OrderedList
+ ( 4 , Decimal , Period )
+ [ [ Para
+ [ Str "XL"
+ , Space
+ , Str "Code"
+ , Space
+ , Str "Autoreview"
+ , Space
+ , Str "Bot"
+ , Space
+ , Str "(XLCRBot)."
+ ]
+ ]
+ ]
+ , BlockQuote
+ [ Para
+ [ Strong
+ [ Str "Goal:"
+ , Space
+ , Str "Feedback"
+ , Space
+ , Str "on"
+ , Space
+ , Str "basic"
+ , Space
+ , Str "violations"
+ , Space
+ , Str "in"
+ , Space
+ , Str "seconds"
+ , Space
+ , Str "or"
+ , Space
+ , Str "minutes"
+ , Space
+ , Str "at"
+ , Space
+ , Str "most"
+ , Space
+ , Str "in"
+ , Space
+ , Str "either"
+ , Space
+ , Str "VS"
+ , Space
+ , Str "or"
+ , Space
+ , Str "Codeflow."
+ ]
+ ]
+ ]
+ , OrderedList
+ ( 5 , Decimal , Period )
+ [ [ Para [ Str "Code" , Space , Str "documentation" ] ] ]
+ , BlockQuote
+ [ Para
+ [ Strong
+ [ Str "Goal:"
+ , Space
+ , Str "Useful,"
+ , Space
+ , Str "consistent,"
+ , Space
+ , Str "tool"
+ , Space
+ , Str "supported"
+ , Space
+ , Str "comments"
+ ]
+ ]
+ ]
+ , Para [ Strong [ Str "\160" ] , Str "\160" ]
+ , OrderedList
+ ( 6 , Decimal , Period )
+ [ [ Para [ Str "Education" , Space , Str "efforts" ] ] ]
+ , BlockQuote
+ [ Para
+ [ Strong
+ [ Str "Goal:"
+ , Space
+ , Str "Broad,"
+ , Space
+ , Str "discoverable"
+ , Space
+ , Str "channels"
+ , Space
+ , Str "for"
+ , Space
+ , Str "updates"
+ , Space
+ , Str "and"
+ , Space
+ , Str "news"
+ ]
+ ]
+ ]
+ , Para [ Strong [ Str "\160" ] ]
+ ]