diff options
author | Ben Steinberg <bsteinberg@law.harvard.edu> | 2019-09-21 01:13:29 -0400 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-09-20 22:13:29 -0700 |
commit | 7389919bb491b78373ea2197800988b3a61cf0ce (patch) | |
tree | 1f8dbcae39a7d60b9c4e1f7761d1cce767068025 /test | |
parent | 5ebd5105ad13d0c969a5894963e79e88033114c5 (diff) | |
download | pandoc-7389919bb491b78373ea2197800988b3a61cf0ce.tar.gz |
Preserve built-in styles in DOCX with custom style (#5670)
This commit prevents custom styles on divs and spans from overriding
styles on certain elements inside them, like headings, blockquotes,
and links. On those elements, the "native" style is required for the
element to display correctly. This change also allows nesting of
custom styles; in order to do so, it removes the default "Compact"
style applied to Plain blocks, except when inside a table.
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Writers/Docx.hs | 4 | ||||
-rw-r--r-- | test/docx/custom-style-preserve.native | 15 | ||||
-rw-r--r-- | test/docx/golden/custom_style_preserve.docx | bin | 0 -> 10595 bytes | |||
-rw-r--r-- | test/docx/golden/document-properties.docx | bin | 10358 -> 10350 bytes |
4 files changed, 19 insertions, 0 deletions
diff --git a/test/Tests/Writers/Docx.hs b/test/Tests/Writers/Docx.hs index c958ddf7d..9e1414c40 100644 --- a/test/Tests/Writers/Docx.hs +++ b/test/Tests/Writers/Docx.hs @@ -155,6 +155,10 @@ tests = [ testGroup "inlines" def{writerReferenceDoc = Just "docx/custom-style-reference.docx"} "docx/custom_style.native" "docx/golden/custom_style_reference.docx" + , docxTest "suppress custom style for headers and blockquotes" + def + "docx/custom-style-preserve.native" + "docx/golden/custom_style_preserve.docx" ] , testGroup "metadata" [ docxTest "document properties (core, custom)" diff --git a/test/docx/custom-style-preserve.native b/test/docx/custom-style-preserve.native new file mode 100644 index 000000000..859f71c20 --- /dev/null +++ b/test/docx/custom-style-preserve.native @@ -0,0 +1,15 @@ +[Para [Span ("",[],[("custom-style","MyStyle")]) [Str "This",Space,Str "span",Note [Para [Str "Neither",Space,Str "footnote",Space,Str "nor",Space,Str "footnote",Space,Str "reference",Space,Str "should",Space,Str "get",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "from",Space,Str "its",Space,Str "span."]],Space,Str "should",Space,Str "have",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "(",Link ("",[],[]) [Str "link"] ("http://example.com/",""),Str "),"],Space,Str "but",Space,Str "the",Space,Str "text",Space,Str "after",Space,Str "the",Space,Str "comma",Space,Str "shouldn\8217t,",Space,Str "nor",Space,Str "should",Space,Str "the",Space,Str "link."] +,Div ("",[],[("custom-style","MyOtherStyle")]) + [Para [Str "The",Space,Str "contents",Space,Str "of",Space,Str "this",Space,Str "div",Space,Str "should",Space,Str "have",Space,Str "a",Space,Str "custom",Space,Str "style,",Space,Str "but",Space,Link ("",[],[]) [Str "this",Space,Str "link",Space,Str "should",Space,Str "not"] ("http://example.com/",""),Str "."] + ,Header 2 ("this-header-should-not-have-the-divs-custom-style",[],[]) [Str "This",Space,Str "header",Space,Str "should",Space,Str "not",Space,Str "have",Space,Str "the",Space,Str "div\8217s",Space,Str "custom",Space,Str "style"] + ,BlockQuote + [Para [Str "This",Space,Str "blockquote",Space,Str "should",Space,Str "not."]] + ,CodeBlock ("",[],[]) "# This code block should not." + ,Para [Str "But",Space,Str "this",Space,Str "paragraph",Space,Str "should.",Note [Para [Str "Neither",Space,Str "footnote",Space,Str "nor",Space,Str "footnote",Space,Str "reference",Space,Str "should",Space,Str "get",Space,Str "a",Space,Str "custom",Space,Str "style",Space,Str "from",Space,Str "its",Space,Str "div."]]]] +,Div ("",[],[("custom-style","MyOuterStyle")]) + [Div ("",[],[("custom-style","MyInnerStyle")]) + [Para [Str "This",Space,Str "should",Space,Str "have",Space,Str "MyInnerStyle."] + ,Header 3 ("this-heading-should-not",[],[]) [Str "This",Space,Str "heading",Space,Str "should",Space,Str "not"]] + ,Para [Str "This",Space,Str "should",Space,Str "have",Space,Str "MyOuterStyle,",Space,Str "but",Space,Str "the",Space,Str "following",Space,Str "elision",Space,Str "should",Space,Str "have",Space,Str "its",SoftBreak,Str "own",Space,Str "style.",Space,Span ("",[],[("custom-style","Elision")]) [Str "..."]] + ,BlockQuote + [Para [Str "This",Space,Str "blockquote",Space,Str "should",Space,Str "include",Space,Strong [Str "bold",Space,Str "text",Space,Str "with",Space,Str "an",Space,Str "elision:",SoftBreak,Span ("",[],[("custom-style","Elision")]) [Str "..."]]]]]] diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx Binary files differnew file mode 100644 index 000000000..06371d51e --- /dev/null +++ b/test/docx/golden/custom_style_preserve.docx diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx Binary files differindex 00c78bc0f..8bb498e02 100644 --- a/test/docx/golden/document-properties.docx +++ b/test/docx/golden/document-properties.docx |