Add passing style_map kwarg to Mammoth when converting docx to allow keeping comments #38
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.
Mammoth, which is used for converting docx, allows specifying custom mappings for docx styles => html elements; see https://pypi.org/project/mammoth/#custom-style-map By default, Mammoth ignores comments in docx files. These custom style maps allow including comments in the generated html; see https://pypi.org/project/mammoth/#comments
This PR adds passing this
style_map
kwarg to Mammoth when converting a docx file. Tests are also added for specifically converting comments using a style map.For example, using
style_map="comment-reference => "
, the two comments added to the test file are added to the converted markdown as follows:Note: The new test file was created by adding comments to the existing file test.docx using LibreOffice. I'm not sure if using LibreOffice for this messes with the document in some way or if MS Word comments would be somehow different so it might make sense for a maintainer to add a suitable test file instead or include comments directly to test.docx.
Resolves #31