-
Notifications
You must be signed in to change notification settings - Fork 3k
Encode line breaks as <br> tags for file saving #28522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
793aa49 to
5c4c27b
Compare
That would be nice indeed... it looks like TinyXML's Also, this is the sort of thing where a unit test would seem nice to me (and perhaps even more appropriate than a VTest). |
5c4c27b to
0b0b693
Compare
src/engraving/dom/textbase.cpp
Outdated
| } else { | ||
| LOGD("unknown symbol <%s>", muPrintable(sym)); | ||
| } | ||
| } else if (token == "br/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, I don't love the idea that the layout code knows about this, unless it's absolutely necessary. As far as I understand, the problem only involves the XML reading, not the program runtime. The program itself has no problem dealing with line breaks, so I don't see a reason why the substitution of line breaks with tags should be carried all the way into the runtime. If it's possible, I think the ideal approach would be
- On write: check the string for line breaks just before writing it to the file, and write to the file a version of that string where line breaks are replaced with tags.
- On read: read the string normally, then do a second pass on it to check it for line-break tags and replace them with actual line breaks.
That way the knowledge about this tag is strictly confined to the read/write modules and no other part of the program needs to deal with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I think you're probably right - though couldn't this be extended to all other tags in the xml text?
114e9bb to
cdabfa7
Compare
a046571 to
3335b0b
Compare
3335b0b to
4f24e3d
Compare

Resolves: #19189
This PR encodes line breaks as
<br/>forTextBaseitems, fixing the loss of newlines after XML tags - eg. formatting & symbols.This isn't a huge change and preserves backwards compatibility.
TextBasestill needs to turn\ninto newlines when setting text on user input. This means old files using actual newlines in the XML can still be read.