fix(html): do not crash ConvertToHtml when DocumentSettingsPart is missing#264
Merged
JSv4 merged 14 commits intoJul 12, 2026
Merged
Conversation
…ssing
OOXML does not require word/settings.xml. CalculateSpanWidthForTabs called
DocumentSettingsPart.GetXDocument() unconditionally, so packages with only
document + styles threw ArgumentNullException("part") before any HTML.
Treat settings as optional and keep the existing 720-twip default tab stop.
Add HCO057 regression coverage for a no-settings package.
Drop redundant MainDocumentPart null-conditional (already non-null in ConvertToHtml), read w:defaultTabStop as a direct child of w:settings, and remove the throwaway DocumentSettingsPart invent-if-missing path in AddFormattingParts now that ConvertToHtml tolerates a missing part.
AddFormattingParts no longer synthesizes a dummy DocumentSettingsPart; update the RenderBlockHtml regression comment to match.
dotnet.js applies fetch integrity from asset.hash; some SDK builds emit integrity instead. Rename at publish so SRI is not silently skipped.
Contributor
Author
|
Extract DefaultTabStopTwips const and GetSettingsXDocumentOrDefault helper; reuse in both CalculateSpanWidthForTabs and GetDocumentDefaultLanguage. Conflict-resolved to keep the .Root?.Element() optimization.
…harness (PR #5) Type-mania recipe: annotate docx_scalpel session.py __exit__, enums.py _missing_ return type, and all LibreOffice diff-harness scripts (lo_batch, lo_bookmark_check, lo_comment_check, lo_compare, lo_footnote_check, lo_headerfooter_check).
#6) Type-mania recipe: annotate npm session.ts predicate functions with boolean return types; use TYPE_CHECKING guard for TracebackType import in docx_scalpel session.py (avoids runtime import under PEP 563).
Contributor
Author
|
Here the full results: https://github.com/jandira-tech/neurotic_docx_bench |
Stop tracking macOS Finder metadata (.DS_Store) across the repo and prevent future commits from re-adding them.
Owner
|
Thanks! This looks great. Will review a little further but good find. The HTML converter has not been my focus, but it's handy and great fix! |
…nd boot-config SRI normalization
JSv4
approved these changes
Jul 12, 2026
JSv4
left a comment
Owner
There was a problem hiding this comment.
Added a changelog entry but looks great. Thank you
5 tasks
JSv4
added a commit
that referenced
this pull request
Jul 12, 2026
…ssing (#266) word/styles.xml is optional in OOXML (Word opens a document-only package without repair), but FormattingAssembler.AssembleFormatting dereferenced StyleDefinitionsPart unconditionally at many sites - and it runs before the settings fix from #264 - so a package with only word/document.xml still threw ArgumentNullException("part") before producing any HTML. Ensure the styles part exists at the AssembleFormatting entry via a new shared StyleFactory.EnsureStylesPart find-or-create helper (extracted from the two identical synthesize sites already in StyleFactory), so every style lookup falls through to built-in defaults; this covers the full-document, RenderBlockHtml, and session-render paths in one place. Regression coverage: HCO062 (programmatic document-only package), HCO063 (in-repo RPR-FivePageTestDoc.docx document-only fixture), HCO064 (RenderBlockHtml on a styles-less source). Closes #265
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CalculateSpanWidthForTabsno longer assumesMainDocumentPart.DocumentSettingsPartis always present. Missingword/settings.xmlis legal OOXML (Word opens those packages without repair); the converter previously threwArgumentNullException("part")viaGetXDocumentand aborted conversion.w:defaultTabStop) are absent, keep the existing default of 720 twips.w:defaultTabStopas a direct child ofw:settings(not a fullDescendantswalk).DocumentSettingsPartpath inAddFormattingPartsnow that conversion tolerates a missing part.dotnet.boot.jsassetintegrity→hashinscripts/build-wasm.shso the .NET 10 loader applies SRI.HCO057–HCO061(no settings / custom tab stop / empty settings /RenderBlockHtml).Surfaced while scoring Docxodus on a large minimal-OOXML corpus: this single null path was the dominant convert failure for packages without settings.
Behaviour
w:defaultTabStopsettings.xmlTest plan
dotnet test --filter FullyQualifiedName~HCO05/HCO06(includes HCO056–HCO061)docxodusconsumers get the engine fix (JS + WASM must ship as a matched pair)