In the commit #26550 many DIV markups changed into SPANs, and as far as I know it was because of XHTML validity. But, you know, SPAN is inline element, and many of the influenced tags (such as [code], [align], [float], etc.) have block element implication. In my opinion, it's better to make them into DIV blocks. Then, of course, XHTML validity problem will arise again, e.g.:

some text...
[float=left]text in floated box...

and more
[/float]

will be rendered as

<p>some text...</p>
<div style="float:left;">text in floated box...</p>
<p>and more...
</div>

and this result is absolutely invalid. But if bbcode module inserts two newline characters after the <DIV> tag and before </DIV> (i.e. "<div style="float:left;">\n\n...\n\n</div>" instead of "<div style="float:left;">...</div>"), after line break converter we would get:

<p>some text...</p>
<div style="float:left;">
<p>text in floated box...</p>
<p>and more...</p>
</div>

which is a valid XHTML code block.

And in case of [code] tag, I think, PRE tag would be better than DIV (and SPAN) tag. If we use PRE tag, tab indentations are reserved as you know, and furthermore two or more successive empty lines are reserved (instead of being converted P block).

----

In short, how about to change...
(bbcode-filter.inc line 72)

    '#\[align=(.*?)(?::\w+)?\](.*?)\[/align(?::\w+)?\]#si'    => '<span style="text-align:\\1">\\2</span>',

into

    '#\[align=(.*?)(?::\w+)?\](.*?)\[/align(?::\w+)?\]#si'    => "<div style=\"text-align:\\1\">\n\n\\2\n\n</div>",

(also applies to the [float] tag, and many already-converting-to-div tags), and (bbcode-filter.inc line 168)

            $code_block = '<span class="bb-code-block">%s</span>';

into

            $code_block = '<pre class="bb-code-block">%s</pre>';

----

And one more... How about to add a class name such as "bb-code-block" to the result of _bbcode_php_tag()? [php] is a code block tag just like the [code] except syntax highlighting, isn't it?

And, one more, the last...:-) How about to process [notag] at the very first of the processing? [notag] is a kind of meta tag, so, in my opinion, it should be applied before any other tags such as [quote] and [list].

Thanks for your patient reading.

Comments

naudefj’s picture

Try changing "Smart paragraph and line breaks" to "Line breaks only". I'm sure it will solve your problem.

Also, please test with the latest version. Based on the results you've posted, it looks like you may be using an older release.

Anonymous’s picture

Oh, there was a new version! :-)

By the way, there is a typo in May 28 version, which generates some warning messages.
bbcode-filter.inc line 94:

    '#\[url=([a-z0-9:;&,%+!=@\/\.\-_\#\?]*?]*?)\](.*?)\[/url(?::\w+)?\]#si'   => '<a href="\\1" class="bb-url">\\2</a>',

=>

    '#\[url=([a-z0-9:;&,%+!=@\/\.\-_\#\?]*?)\](.*?)\[/url(?::\w+)?\]#si'   => '<a href="\\1" class="bb-url">\\2</a>',

Right?

About the "Smart paragraph and line breaks" feature in relation with [code] tag... I didn't prefer to use the feature because of the configuration-tip message which says not to use both of the feature and "Line break converter" together, but using both of them seems not to make any conflict. OK, that's very nice, and it could be more nice, I think:

  • How about to add a class name such as "bb-code-block" to the resulting PRE tag? I want code blocks to be rendered prettier, and to do it we need something which indicates bbcode [code] blocks.
  • "Smart paragraph and line breaks" feature ignores some unusual tag such as [code:1]code block...[/code:1], many of which my favorite site has already in thousands of nodes.
naudefj’s picture

1. Warning message was fixed - thanks.

2. Class="bb-code-block" was added.

3. This will not be easy to implement. What is the purpose of these [code:1] tags? Is it really necessary to have them?

Anonymous’s picture

Sorry but I don't know what's the meaning of the [code:1] tag:-), so I googled to get little clues.

According to the phpbb documentation, [code:1:UID] and [code:UID] seems to be formats for some kind of internal processing. On the other hand, some results of google also show [code:1] in them, though I cannot understand the exact meaning of the syntax.

What I used to call as "my favorite site" immigrated from phpbb to drupal this year, and in my though, it might be a problem during data converting, i.e.: phpbb stores [code] tags as the [code:1] format in DB and strips the :1 stuff when displaying the tag to the user. Then phpbb2drupal converter ignores the fact, and copy the DB data as it is, resulting [code:1] tags. Just a piece of possibility, and I'm too lazy to figure out what is the truth:-)

It's (of course) up to you to decide whether to accept [code:1] format or not. Yet in my opinion, it would not be bad to handle [code:1] format in the same way as the line 169 in bbcode-filter.inc.

  if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
    ...
  }
naudefj’s picture

Why don't you just do the following:

UPDATE node_revisions SET body = REPLACE(body, '[code:1]','[code]');

UPDATE node_revisions SET body = REPLACE(body, '[/code:1]','[/code]');

naudefj’s picture

Assigned: Unassigned » naudefj
Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)