-
Notifications
You must be signed in to change notification settings - Fork 104
Add a new paragraph instead of "<br>" if the text to be merged contains "\n" #74
base: master
Are you sure you want to change the base?
Conversation
@Bouke Sorry for my poor English |
This looks like an interesting change. I think it’s good to differentiate between line breaks and paragraph. And so my question with this change is, how can we differentiate between the two? What does the user intent when there’s a |
So I think the confusion on my part is due to the styling changes of new paragraphs that have changed between Word versions. I believe Word 2013 would offset paragraphs with a blank line, were this change was reverted in later versions. You might be correct that Word inserts a new paragraph with So what would happen now with this change when the merge field is surrounded by text, and the replacement contains a line break?
|
I don't have any version of Microsoft Word for testing, all of my docx file were edited with WPS Office that is compatible with the Microsoft Word in China, There are my files for testing, run If you create a new docx file as the template file with Microsoft Word 2013, such as template/r2.docx, After running |
Description
Just modified the function "__merge_field" for adding real paragraphs instead of "<br>" if the text to be merged contains "\n".
Motivation and Context
For example, for field named "text" in docx, there are text to be merged: "1.one\n2.two\n3.three"
By the old function, it will insert "<br>" to get line break ( In MSword, it shows "Shift+Enter"):
But considering text indentation, (for me, Chinese language), actually we need "Real Enter".
By the old function, it will be:
In other word, now we need two more paragraphs instead of two "<br>".
So I writed some codes to add paragraphs to solve these "bugs",perhaps features?
I hope it will show:
How Has This Been Tested?
Tested on window10, python 3.6.6.
I run the unittest by
python -m unittest
and the result isFAILED (failures=8)
All these failures seem are the result of test cases, these cases are based on "<br>",It's no surprise that failed. Maybe these test cases need to be changed.
Types of changes
Checklist: