aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Török <[email protected]>2023-12-18 23:20:22 +0000
committerJohn MacFarlane <[email protected]>2023-12-18 17:15:03 -0800
commitc5780857e5ebe54246d3066e7aa95424309bd05c (patch)
treee6ef50194252e247c2cfbc7069a98a72931dd4c7
parent3e360f5a3e52852e349361d83280a3d21f051e04 (diff)
fix(docx): fix OOXMLValidator error on KeywordTok output
xmllint doesn't warn about this (maybe because the tag is empty?), but the order doesn't match wml.xsd: ``` <w:rPr> <w:color w:val="007020"/> <w:b/> </w:rPr> ``` And OOXMLValidatorCLI does warn about it: ``` { "Description": "The element has unexpected child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:b'.", "Path": { "NamespacesDefinitions": [ "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"" ], "Namespaces": { }, "XPath": "/w:styles[1]/w:style[40]/w:rPr[1]", "PartUri": "/word/styles.xml" }, "Id": "Sch_UnexpectedElementContentExpectingComplex", "ErrorType": "Schema" } ``` Signed-off-by: Edwin Török <[email protected]>
-rw-r--r--src/Text/Pandoc/Writers/Docx.hs8
-rw-r--r--test/docx/golden/block_quotes.docxbin9987 -> 9986 bytes
-rw-r--r--test/docx/golden/codeblock.docxbin9802 -> 9801 bytes
-rw-r--r--test/docx/golden/comments.docxbin10135 -> 10134 bytes
-rw-r--r--test/docx/golden/custom_style_no_reference.docxbin9902 -> 9901 bytes
-rw-r--r--test/docx/golden/custom_style_preserve.docxbin10532 -> 10532 bytes
-rw-r--r--test/docx/golden/definition_list.docxbin9802 -> 9801 bytes
-rw-r--r--test/docx/golden/document-properties-short-desc.docxbin9808 -> 9808 bytes
-rw-r--r--test/docx/golden/document-properties.docxbin10294 -> 10293 bytes
-rw-r--r--test/docx/golden/headers.docxbin9941 -> 9940 bytes
-rw-r--r--test/docx/golden/image.docxbin26683 -> 26682 bytes
-rw-r--r--test/docx/golden/inline_code.docxbin9741 -> 9740 bytes
-rw-r--r--test/docx/golden/inline_formatting.docxbin9921 -> 9920 bytes
-rw-r--r--test/docx/golden/inline_images.docxbin26681 -> 26680 bytes
-rw-r--r--test/docx/golden/link_in_notes.docxbin9963 -> 9962 bytes
-rw-r--r--test/docx/golden/links.docxbin10134 -> 10133 bytes
-rw-r--r--test/docx/golden/lists.docxbin10205 -> 10204 bytes
-rw-r--r--test/docx/golden/lists_continuing.docxbin9997 -> 9996 bytes
-rw-r--r--test/docx/golden/lists_div_bullets.docxbin9851 -> 9850 bytes
-rw-r--r--test/docx/golden/lists_multiple_initial.docxbin10082 -> 10081 bytes
-rw-r--r--test/docx/golden/lists_restarting.docxbin9995 -> 9994 bytes
-rw-r--r--test/docx/golden/nested_anchors_in_header.docxbin10134 -> 10133 bytes
-rw-r--r--test/docx/golden/notes.docxbin9910 -> 9909 bytes
-rw-r--r--test/docx/golden/raw-blocks.docxbin9842 -> 9841 bytes
-rw-r--r--test/docx/golden/raw-bookmarks.docxbin9976 -> 9975 bytes
-rw-r--r--test/docx/golden/table_one_row.docxbin9831 -> 9830 bytes
-rw-r--r--test/docx/golden/table_with_list_cell.docxbin10152 -> 10151 bytes
-rw-r--r--test/docx/golden/tables-default-widths.docxbin10177 -> 10176 bytes
-rw-r--r--test/docx/golden/tables.docxbin10192 -> 10191 bytes
-rw-r--r--test/docx/golden/tables_separated_with_rawblock.docxbin9829 -> 9828 bytes
-rw-r--r--test/docx/golden/track_changes_deletion.docxbin9785 -> 9784 bytes
-rw-r--r--test/docx/golden/track_changes_insertion.docxbin9768 -> 9767 bytes
-rw-r--r--test/docx/golden/track_changes_move.docxbin9802 -> 9801 bytes
-rw-r--r--test/docx/golden/track_changes_scrubbed_metadata.docxbin9911 -> 9910 bytes
-rw-r--r--test/docx/golden/unicode.docxbin9727 -> 9726 bytes
-rw-r--r--test/docx/golden/verbatim_subsuper.docxbin9774 -> 9773 bytes
-rw-r--r--tools/validate-docx2.sh25
37 files changed, 4 insertions, 29 deletions
diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs
index b8f8cf58a..7db854187 100644
--- a/src/Text/Pandoc/Writers/Docx.hs
+++ b/src/Text/Pandoc/Writers/Docx.hs
@@ -679,14 +679,14 @@ styleToOpenXml sm style =
[ mknode "w:name" [("w:val", tshow toktype)] ()
, mknode "w:basedOn" [("w:val","VerbatimChar")] ()
, mknode "w:rPr" [] $
+ [ mknode "w:b" [] () | tokFeature tokenBold toktype ] ++
+ [ mknode "w:i" [] () | tokFeature tokenItalic toktype ] ++
[ mknode "w:color" [("w:val", tokCol toktype)] ()
| tokCol toktype /= "auto" ] ++
+ [ mknode "w:u" [] () | tokFeature tokenUnderline toktype ] ++
[ mknode "w:shd" [("w:val","clear")
,("w:fill",tokBg toktype)] ()
- | tokBg toktype /= "auto" ] ++
- [ mknode "w:b" [] () | tokFeature tokenBold toktype ] ++
- [ mknode "w:i" [] () | tokFeature tokenItalic toktype ] ++
- [ mknode "w:u" [] () | tokFeature tokenUnderline toktype ]
+ | tokBg toktype /= "auto" ]
]
tokStyles = tokenStyles style
tokFeature f toktype = maybe False f $ M.lookup toktype tokStyles
diff --git a/test/docx/golden/block_quotes.docx b/test/docx/golden/block_quotes.docx
index 22f384be3..c7f6cf1fe 100644
--- a/test/docx/golden/block_quotes.docx
+++ b/test/docx/golden/block_quotes.docx
Binary files differ
diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx
index 20440b585..900d29f87 100644
--- a/test/docx/golden/codeblock.docx
+++ b/test/docx/golden/codeblock.docx
Binary files differ
diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx
index 341a5dba0..55af60d75 100644
--- a/test/docx/golden/comments.docx
+++ b/test/docx/golden/comments.docx
Binary files differ
diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx
index a2a72a262..bb556cc42 100644
--- a/test/docx/golden/custom_style_no_reference.docx
+++ b/test/docx/golden/custom_style_no_reference.docx
Binary files differ
diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx
index da7eabc0e..1a23653ad 100644
--- a/test/docx/golden/custom_style_preserve.docx
+++ b/test/docx/golden/custom_style_preserve.docx
Binary files differ
diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx
index 9b907e9cb..2a2a1b374 100644
--- a/test/docx/golden/definition_list.docx
+++ b/test/docx/golden/definition_list.docx
Binary files differ
diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx
index 25f6ec2c6..f6a2a2b9a 100644
--- a/test/docx/golden/document-properties-short-desc.docx
+++ b/test/docx/golden/document-properties-short-desc.docx
Binary files differ
diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx
index ff5dbdd73..278bf0a31 100644
--- a/test/docx/golden/document-properties.docx
+++ b/test/docx/golden/document-properties.docx
Binary files differ
diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx
index 4ec9da199..ea1fafef0 100644
--- a/test/docx/golden/headers.docx
+++ b/test/docx/golden/headers.docx
Binary files differ
diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx
index 335b2a2ee..93c699936 100644
--- a/test/docx/golden/image.docx
+++ b/test/docx/golden/image.docx
Binary files differ
diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx
index ea0e933d9..3810f2e05 100644
--- a/test/docx/golden/inline_code.docx
+++ b/test/docx/golden/inline_code.docx
Binary files differ
diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx
index 9805887c6..008828954 100644
--- a/test/docx/golden/inline_formatting.docx
+++ b/test/docx/golden/inline_formatting.docx
Binary files differ
diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx
index cb3500440..1146ef700 100644
--- a/test/docx/golden/inline_images.docx
+++ b/test/docx/golden/inline_images.docx
Binary files differ
diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx
index f758afcb4..18cc0325c 100644
--- a/test/docx/golden/link_in_notes.docx
+++ b/test/docx/golden/link_in_notes.docx
Binary files differ
diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx
index 5b5c03a24..483c87e7d 100644
--- a/test/docx/golden/links.docx
+++ b/test/docx/golden/links.docx
Binary files differ
diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx
index c9ab6ce7d..ab2f3736b 100644
--- a/test/docx/golden/lists.docx
+++ b/test/docx/golden/lists.docx
Binary files differ
diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx
index 587bc1305..8f530bf9a 100644
--- a/test/docx/golden/lists_continuing.docx
+++ b/test/docx/golden/lists_continuing.docx
Binary files differ
diff --git a/test/docx/golden/lists_div_bullets.docx b/test/docx/golden/lists_div_bullets.docx
index 03eb51c09..9710cb78f 100644
--- a/test/docx/golden/lists_div_bullets.docx
+++ b/test/docx/golden/lists_div_bullets.docx
Binary files differ
diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx
index 5ff15f96b..e80d5eff0 100644
--- a/test/docx/golden/lists_multiple_initial.docx
+++ b/test/docx/golden/lists_multiple_initial.docx
Binary files differ
diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx
index 2e34b46fa..8052a24d1 100644
--- a/test/docx/golden/lists_restarting.docx
+++ b/test/docx/golden/lists_restarting.docx
Binary files differ
diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx
index 076a8a831..105b0ea8d 100644
--- a/test/docx/golden/nested_anchors_in_header.docx
+++ b/test/docx/golden/nested_anchors_in_header.docx
Binary files differ
diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx
index b452ecd0f..8dde3112b 100644
--- a/test/docx/golden/notes.docx
+++ b/test/docx/golden/notes.docx
Binary files differ
diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx
index 1540d42b7..9b5fa56b0 100644
--- a/test/docx/golden/raw-blocks.docx
+++ b/test/docx/golden/raw-blocks.docx
Binary files differ
diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx
index e9c8dd42b..866823e3c 100644
--- a/test/docx/golden/raw-bookmarks.docx
+++ b/test/docx/golden/raw-bookmarks.docx
Binary files differ
diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx
index f8fd455a0..0904fff26 100644
--- a/test/docx/golden/table_one_row.docx
+++ b/test/docx/golden/table_one_row.docx
Binary files differ
diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx
index 55064a6d2..a987bc495 100644
--- a/test/docx/golden/table_with_list_cell.docx
+++ b/test/docx/golden/table_with_list_cell.docx
Binary files differ
diff --git a/test/docx/golden/tables-default-widths.docx b/test/docx/golden/tables-default-widths.docx
index 84aba6fcb..a86abc542 100644
--- a/test/docx/golden/tables-default-widths.docx
+++ b/test/docx/golden/tables-default-widths.docx
Binary files differ
diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx
index ef3844b3c..b14b228c5 100644
--- a/test/docx/golden/tables.docx
+++ b/test/docx/golden/tables.docx
Binary files differ
diff --git a/test/docx/golden/tables_separated_with_rawblock.docx b/test/docx/golden/tables_separated_with_rawblock.docx
index 6327ab59d..d616a55a3 100644
--- a/test/docx/golden/tables_separated_with_rawblock.docx
+++ b/test/docx/golden/tables_separated_with_rawblock.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx
index d374c62a1..4a0f0d40b 100644
--- a/test/docx/golden/track_changes_deletion.docx
+++ b/test/docx/golden/track_changes_deletion.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx
index a6cd14604..d7e90d21b 100644
--- a/test/docx/golden/track_changes_insertion.docx
+++ b/test/docx/golden/track_changes_insertion.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx
index 3150d64f8..f98d6de26 100644
--- a/test/docx/golden/track_changes_move.docx
+++ b/test/docx/golden/track_changes_move.docx
Binary files differ
diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx
index 68eda70b7..c0d51b620 100644
--- a/test/docx/golden/track_changes_scrubbed_metadata.docx
+++ b/test/docx/golden/track_changes_scrubbed_metadata.docx
Binary files differ
diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx
index 8eb2296f6..064775ea6 100644
--- a/test/docx/golden/unicode.docx
+++ b/test/docx/golden/unicode.docx
Binary files differ
diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx
index 3a169c69b..8eaf6f503 100644
--- a/test/docx/golden/verbatim_subsuper.docx
+++ b/test/docx/golden/verbatim_subsuper.docx
Binary files differ
diff --git a/tools/validate-docx2.sh b/tools/validate-docx2.sh
deleted file mode 100644
index 7b43c62a0..000000000
--- a/tools/validate-docx2.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-# based on validate-docx.sh, and adapted for OOXMLValidatorCLI
-# Modified by edwintorok from https://github.com/devoidfury/docx-validator
-# to look at more files than just document.xml.
-# Further modified by jgm for portability.
-
-tmpdir=$(mktemp -d)
-error_files=""
-errors=0
-VALIDATOR=OOXML-Validator/bin/Release/*/OOXMLValidatorCLI
-
-for file in "$@"; do
- file_errors=0
- echo "*** Checking $file"
- dotnet $(VALIDATOR) "${file}" 2>&1 || file_errors=1
- if [ $file_errors -gt 0 ]; then
- errors=$((file_errors + errors))
- error_files="$error_files\n$file"
- fi
-done
-if [ $errors -gt 0 ]; then
- echo "These files failed validation:$error_files"
-fi
-exit $errors