Double <br> after blockquote?
I'm automatically getting two line breaks after a blockquote? How can I can modify that?
Best Answer
-
hgtonight MVP
This is fixed in the 2.1b1 version. You can either a) port the affected changes, b) set Vanilla to not replace new lines as br tags, c) or deal with it.
Solutions
A) Add the function
FixNl2Br()
tofunctions.render.php
. Don't forget the include guard! Modifyclass.format.php
to call this after the regex replacements in theHtml()
formatter method. You can use the following diff as a starting point.class.format.php:
@@ -697,7 +697,6 @@ // nl2br if(C('Garden.Format.ReplaceNewlines', TRUE)) { $Mixed = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $Mixed); + $Mixed = FixNl2Br($Mixed); // $Mixed = wpautop($Mixed); } @@ -714,7 +713,6 @@ $Result = Gdn_Format::Links($Result); if(C('Garden.Format.ReplaceNewlines', TRUE)) { $Result = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $Result); + $Result = FixNl2Br($Result); // $Result = wpautop($Result); } }
functions.render.php:
@@ -281,19 +281,4 @@ function SignOutUrl($Target = '') { return '/entry/signout?TransientKey='.urlencode(Gdn::Session()->TransientKey()).($Target ? '&Target='.urlencode($Target) : ''); } +} + +if (!function_exists('FixNl2Br')) { + /** + * Removes the break above and below tags that have a natural margin. + * @param string $Text The text to fix. + * @return string + * @since 2.1 + */ + function FixNl2Br($Text) { + $allblocks = '(?:table|dl|ul|ol|pre|blockquote|address|p|h[1-6]|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; + $Text = preg_replace('!(?:<br\s*/>){1,2}\s*(<' . $allblocks . '[^>]*>)!', "\n$1", $Text); + $Text = preg_replace('!(</' . $allblocks . '[^>]*>)\s*(?:<br\s*/>){1,2}!', "$1\n", $Text); + return $Text; + } +}
$Configuration['Garden']['Format']['ReplaceNewlines'] = FALSE;
C) You are done!
I prefer these solutions in reverse order.
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
3
Answers
Ha. I forgot to wrap
<br>
in the title.But great bug discovered the same moment, i does make a linebreak in the Title tooo. Haha!
Are you using any editor plugins? Buttonbar, NBBC, Wysihtml, CLEditor, etc.?
What formatter? Html, BBCode, MarkDown?
What version of Vanilla are you running? 2.0.18.8 or 2.1b1?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
No editor plugins, running 2.0.18, HTML.
This is fixed in the 2.1b1 version. You can either a) port the affected changes, b) set Vanilla to not replace new lines as br tags, c) or deal with it.
Solutions
A) Add the function
FixNl2Br()
tofunctions.render.php
. Don't forget the include guard! Modifyclass.format.php
to call this after the regex replacements in theHtml()
formatter method. You can use the following diff as a starting point.class.format.php:
functions.render.php:
$Configuration['Garden']['Format']['ReplaceNewlines'] = FALSE;
C) You are done!
I prefer these solutions in reverse order.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.