diff options
| author | Edwin Török <[email protected]> | 2023-12-18 23:20:22 +0000 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2023-12-18 17:15:03 -0800 |
| commit | c5780857e5ebe54246d3066e7aa95424309bd05c (patch) | |
| tree | e6ef50194252e247c2cfbc7069a98a72931dd4c7 | |
| parent | 3e360f5a3e52852e349361d83280a3d21f051e04 (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]>
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 Binary files differindex 22f384be3..c7f6cf1fe 100644 --- a/test/docx/golden/block_quotes.docx +++ b/test/docx/golden/block_quotes.docx diff --git a/test/docx/golden/codeblock.docx b/test/docx/golden/codeblock.docx Binary files differindex 20440b585..900d29f87 100644 --- a/test/docx/golden/codeblock.docx +++ b/test/docx/golden/codeblock.docx diff --git a/test/docx/golden/comments.docx b/test/docx/golden/comments.docx Binary files differindex 341a5dba0..55af60d75 100644 --- a/test/docx/golden/comments.docx +++ b/test/docx/golden/comments.docx diff --git a/test/docx/golden/custom_style_no_reference.docx b/test/docx/golden/custom_style_no_reference.docx Binary files differindex a2a72a262..bb556cc42 100644 --- a/test/docx/golden/custom_style_no_reference.docx +++ b/test/docx/golden/custom_style_no_reference.docx diff --git a/test/docx/golden/custom_style_preserve.docx b/test/docx/golden/custom_style_preserve.docx Binary files differindex da7eabc0e..1a23653ad 100644 --- a/test/docx/golden/custom_style_preserve.docx +++ b/test/docx/golden/custom_style_preserve.docx diff --git a/test/docx/golden/definition_list.docx b/test/docx/golden/definition_list.docx Binary files differindex 9b907e9cb..2a2a1b374 100644 --- a/test/docx/golden/definition_list.docx +++ b/test/docx/golden/definition_list.docx diff --git a/test/docx/golden/document-properties-short-desc.docx b/test/docx/golden/document-properties-short-desc.docx Binary files differindex 25f6ec2c6..f6a2a2b9a 100644 --- a/test/docx/golden/document-properties-short-desc.docx +++ b/test/docx/golden/document-properties-short-desc.docx diff --git a/test/docx/golden/document-properties.docx b/test/docx/golden/document-properties.docx Binary files differindex ff5dbdd73..278bf0a31 100644 --- a/test/docx/golden/document-properties.docx +++ b/test/docx/golden/document-properties.docx diff --git a/test/docx/golden/headers.docx b/test/docx/golden/headers.docx Binary files differindex 4ec9da199..ea1fafef0 100644 --- a/test/docx/golden/headers.docx +++ b/test/docx/golden/headers.docx diff --git a/test/docx/golden/image.docx b/test/docx/golden/image.docx Binary files differindex 335b2a2ee..93c699936 100644 --- a/test/docx/golden/image.docx +++ b/test/docx/golden/image.docx diff --git a/test/docx/golden/inline_code.docx b/test/docx/golden/inline_code.docx Binary files differindex ea0e933d9..3810f2e05 100644 --- a/test/docx/golden/inline_code.docx +++ b/test/docx/golden/inline_code.docx diff --git a/test/docx/golden/inline_formatting.docx b/test/docx/golden/inline_formatting.docx Binary files differindex 9805887c6..008828954 100644 --- a/test/docx/golden/inline_formatting.docx +++ b/test/docx/golden/inline_formatting.docx diff --git a/test/docx/golden/inline_images.docx b/test/docx/golden/inline_images.docx Binary files differindex cb3500440..1146ef700 100644 --- a/test/docx/golden/inline_images.docx +++ b/test/docx/golden/inline_images.docx diff --git a/test/docx/golden/link_in_notes.docx b/test/docx/golden/link_in_notes.docx Binary files differindex f758afcb4..18cc0325c 100644 --- a/test/docx/golden/link_in_notes.docx +++ b/test/docx/golden/link_in_notes.docx diff --git a/test/docx/golden/links.docx b/test/docx/golden/links.docx Binary files differindex 5b5c03a24..483c87e7d 100644 --- a/test/docx/golden/links.docx +++ b/test/docx/golden/links.docx diff --git a/test/docx/golden/lists.docx b/test/docx/golden/lists.docx Binary files differindex c9ab6ce7d..ab2f3736b 100644 --- a/test/docx/golden/lists.docx +++ b/test/docx/golden/lists.docx diff --git a/test/docx/golden/lists_continuing.docx b/test/docx/golden/lists_continuing.docx Binary files differindex 587bc1305..8f530bf9a 100644 --- a/test/docx/golden/lists_continuing.docx +++ b/test/docx/golden/lists_continuing.docx diff --git a/test/docx/golden/lists_div_bullets.docx b/test/docx/golden/lists_div_bullets.docx Binary files differindex 03eb51c09..9710cb78f 100644 --- a/test/docx/golden/lists_div_bullets.docx +++ b/test/docx/golden/lists_div_bullets.docx diff --git a/test/docx/golden/lists_multiple_initial.docx b/test/docx/golden/lists_multiple_initial.docx Binary files differindex 5ff15f96b..e80d5eff0 100644 --- a/test/docx/golden/lists_multiple_initial.docx +++ b/test/docx/golden/lists_multiple_initial.docx diff --git a/test/docx/golden/lists_restarting.docx b/test/docx/golden/lists_restarting.docx Binary files differindex 2e34b46fa..8052a24d1 100644 --- a/test/docx/golden/lists_restarting.docx +++ b/test/docx/golden/lists_restarting.docx diff --git a/test/docx/golden/nested_anchors_in_header.docx b/test/docx/golden/nested_anchors_in_header.docx Binary files differindex 076a8a831..105b0ea8d 100644 --- a/test/docx/golden/nested_anchors_in_header.docx +++ b/test/docx/golden/nested_anchors_in_header.docx diff --git a/test/docx/golden/notes.docx b/test/docx/golden/notes.docx Binary files differindex b452ecd0f..8dde3112b 100644 --- a/test/docx/golden/notes.docx +++ b/test/docx/golden/notes.docx diff --git a/test/docx/golden/raw-blocks.docx b/test/docx/golden/raw-blocks.docx Binary files differindex 1540d42b7..9b5fa56b0 100644 --- a/test/docx/golden/raw-blocks.docx +++ b/test/docx/golden/raw-blocks.docx diff --git a/test/docx/golden/raw-bookmarks.docx b/test/docx/golden/raw-bookmarks.docx Binary files differindex e9c8dd42b..866823e3c 100644 --- a/test/docx/golden/raw-bookmarks.docx +++ b/test/docx/golden/raw-bookmarks.docx diff --git a/test/docx/golden/table_one_row.docx b/test/docx/golden/table_one_row.docx Binary files differindex f8fd455a0..0904fff26 100644 --- a/test/docx/golden/table_one_row.docx +++ b/test/docx/golden/table_one_row.docx diff --git a/test/docx/golden/table_with_list_cell.docx b/test/docx/golden/table_with_list_cell.docx Binary files differindex 55064a6d2..a987bc495 100644 --- a/test/docx/golden/table_with_list_cell.docx +++ b/test/docx/golden/table_with_list_cell.docx diff --git a/test/docx/golden/tables-default-widths.docx b/test/docx/golden/tables-default-widths.docx Binary files differindex 84aba6fcb..a86abc542 100644 --- a/test/docx/golden/tables-default-widths.docx +++ b/test/docx/golden/tables-default-widths.docx diff --git a/test/docx/golden/tables.docx b/test/docx/golden/tables.docx Binary files differindex ef3844b3c..b14b228c5 100644 --- a/test/docx/golden/tables.docx +++ b/test/docx/golden/tables.docx diff --git a/test/docx/golden/tables_separated_with_rawblock.docx b/test/docx/golden/tables_separated_with_rawblock.docx Binary files differindex 6327ab59d..d616a55a3 100644 --- a/test/docx/golden/tables_separated_with_rawblock.docx +++ b/test/docx/golden/tables_separated_with_rawblock.docx diff --git a/test/docx/golden/track_changes_deletion.docx b/test/docx/golden/track_changes_deletion.docx Binary files differindex d374c62a1..4a0f0d40b 100644 --- a/test/docx/golden/track_changes_deletion.docx +++ b/test/docx/golden/track_changes_deletion.docx diff --git a/test/docx/golden/track_changes_insertion.docx b/test/docx/golden/track_changes_insertion.docx Binary files differindex a6cd14604..d7e90d21b 100644 --- a/test/docx/golden/track_changes_insertion.docx +++ b/test/docx/golden/track_changes_insertion.docx diff --git a/test/docx/golden/track_changes_move.docx b/test/docx/golden/track_changes_move.docx Binary files differindex 3150d64f8..f98d6de26 100644 --- a/test/docx/golden/track_changes_move.docx +++ b/test/docx/golden/track_changes_move.docx diff --git a/test/docx/golden/track_changes_scrubbed_metadata.docx b/test/docx/golden/track_changes_scrubbed_metadata.docx Binary files differindex 68eda70b7..c0d51b620 100644 --- a/test/docx/golden/track_changes_scrubbed_metadata.docx +++ b/test/docx/golden/track_changes_scrubbed_metadata.docx diff --git a/test/docx/golden/unicode.docx b/test/docx/golden/unicode.docx Binary files differindex 8eb2296f6..064775ea6 100644 --- a/test/docx/golden/unicode.docx +++ b/test/docx/golden/unicode.docx diff --git a/test/docx/golden/verbatim_subsuper.docx b/test/docx/golden/verbatim_subsuper.docx Binary files differindex 3a169c69b..8eaf6f503 100644 --- a/test/docx/golden/verbatim_subsuper.docx +++ b/test/docx/golden/verbatim_subsuper.docx 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 |
