Mercurial > libervia-backend
changeset 1735:b2d6f3c92842
tools: expandNewLinesToXHTML replaces two or more \n instead of each ones
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 11 Dec 2015 07:54:14 +0100 |
parents | 56fa4e7e158c |
children | 3739f7779f17 |
files | src/tools/xml_tools.py |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tools/xml_tools.py Thu Dec 10 15:14:23 2015 +0100 +++ b/src/tools/xml_tools.py Fri Dec 11 07:54:14 2015 +0100 @@ -1354,13 +1354,12 @@ def expandNewLinesToXHTML(text): - """If not present yet, add a <br /> before all \n occurences. + """Replace two or more "\n" with "\n<br />\n". @param text(unicode) @return unicode """ - # if present, replace <br> (HTML), <br > and <br/> at end of line with <br /> (XHTML) - return re.sub(r"<br[ ]?/?>\n", "\n", text).replace("\n", "<br />\n") + return re.sub(r"\n{2,}", "\n<br />\n", text) def decapsulateDomishContent(elt):