Closed zaygraveyard closed 8 years ago
This is definitely an issue, but is going to take some significant refactoring to fix. The problem is that the tags are basically rendered inside-out, so the outside tag (marked with transform_newlines) has no knowledge of the inner tags, just the final rendered markup. I have some ideas for how to fix it (by creating a tree of render blocks), but it may be some time before I get around to doing it.
Thank you for the quick response. Let me know if I can help out.
After looking at the code, I see that this problem can be fixed (at least for now) by moving these 4 lines inside the else
branch.
Am I correct?
Unfortunately, it's not that simple. In that scenario, newlines wouldn't be converted for tags that render embedded tags. So text inside a tag, but outside any inner tags, would not have newlines converted.
It's a bit clever for my taste, but this should do the trick for now. It relies on normalizing all newlines to \n
, then replacing any that should be transformed to <br />
with \r
, so that string stripping still works as expected. Then any \r
are replaced with <br />
at the very end.
Let me know if this works for you, and if so I'll push out a new release.
Thank you, I'll try it out and let know.
It works great, thank you!
Posted a new version to https://pypi.python.org/pypi/bbcode
Thank you
How to reproduce
Expected output
Actual output
Note the
<br>
inside the<code>c<br>d</code>
instead of the\n
.Version
BBCode 1.0.22 Python 2.7.12