Skip to content
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

Use <p></p> instead of <br/> #19

Open
veger opened this issue Feb 3, 2015 · 4 comments
Open

Use <p></p> instead of <br/> #19

veger opened this issue Feb 3, 2015 · 4 comments

Comments

@veger
Copy link
Owner

veger commented Feb 3, 2015

It is nicer (HTML) to use paragraphs (<p>...</p>) instead of <br /> for newlines/paragraphs.

Furthermore, the <p> HTML elements can be styled (e.g. using CSS) making the output more flexible

@veger veger self-assigned this Feb 3, 2015
@veger veger added this to the Next release milestone Feb 3, 2015
veger referenced this issue in DSalko/ruby-bbcode Feb 3, 2015
@TheNotary
Copy link

+1

@veger
Copy link
Owner Author

veger commented Feb 11, 2015

Simple adding paragraphs using something like:

node[:text].gsub("\r\n", "\n").map {|s| "<p>#{s}</p>"}.join("")

results in (lots of) paragraphs around each text section, for example

"This is [b]bold[/b] and this [i]italic[/i]."

becomes

 "<p>This is</p><b><p>bold</p></b><p> and this </p><i><p>italic</p></i><p>.</p>"

Lots of paragraphs, even without a single newline!

Using

node[:text].gsub("\r\n", "\n").gsub("\n", "</p>\n<p>")

and putting the opening and ending tag before and after the test, solves this
But it easily results in invalid HTML. The following is valid bbcode:

"This is [b] line 1
and this[/b] line 2."

but would become

"<p>This is <b> line 1</p>
<p>and this </b> line 2.</p>"

So solving this issue is not as trivial as I initially assumed and some more thoughts on the subject are required...

@veger veger removed this from the Next release milestone Feb 11, 2015
@veger
Copy link
Owner Author

veger commented Feb 11, 2015

Additionally, using the <p>-tags, limits the allowed contents (no tables, frames, blocks, etc.).
So it might be better to use <div>-tags, as these support any/most content.

@veger veger removed their assignment Jan 15, 2017
@almaron
Copy link

almaron commented May 24, 2019

Just a reminder. According to the official reference, newlines should not be treated as paragraph borders (see tag [*]). Double newlines however can be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants