Welcome Guest, Not a member yet? Register   Sign In
Bug in auto_typography()
#1

[eluser]Matthew Pennell[/eluser]
This was reported back in February, but there doesn't seem to be any reference to it in the Bug Tracker. I'm using 1.5.4 and still seeing the bug.

Input:
Code:
This is the page all about "getting involved".

You can apply for <a href="/jobs">a job</a>, or <a href="/volunteer">volunteer your time</a> to help.

Output of auto_typography($above_string):
Code:
<p>This is the page all about “getting involved”.</p>

<p>You can apply for</p><a href="/jobs">a job</a>, or <a href="/volunteer"></a><p><a href="/volunteer">volunteer your time</a> to help.</p>

I think it's to do with the 'greedy' way regex matches, so two links in the same block of text are getting a closing/opening P tag wrapped around them.
#2

[eluser]Matthew Pennell[/eluser]
Bug submitted.
#3

[eluser]#1313[/eluser]
I second this problem. Any solutions?
#4

[eluser]#1313[/eluser]
Ah, there is no point for waiting for such trivial fix. Patch your \system\helpers\typography_helper.php like this:

Comment/delete these lines (around line #532):
Code:
$str = str_replace("\n\n", "</p>\n\n<p>", $str);
$str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);

Insert this:
Code:
$str = str_replace(array("\r\n", "\r", "\n"), "<br />", $str);
$str = str_replace("<br /><br />","</p>\n<p>",$str);

UPD: ah, disregard this. this patch may be helpful, but it does not fix the problem being discussed. sorry =) read next post
#5

[eluser]#1313[/eluser]
\system\helpers\typography_helper.php, lines 155-156:

Code:
$str = preg_replace("#(<.*?)(".$this->block_elements.")(.*?&gt;)#", "</p>\\1\\2\\3", $str);
        $str = preg_replace("#(</.*?)(".$this->block_elements.")(.*?&gt;)#", "\\1\\2\\3<p>", $str);

replace with

Code:
$str = preg_replace("#<(".$this->block_elements.")(.*?)>#", "</p>\\1\\2\\3", $str);
        $str = preg_replace("#</(".$this->block_elements.")(.*?)>#", "\\1\\2\\3<p>", $str);

Worked for me.
#6

[eluser]Unknown[/eluser]
The solution above worked to fix the problems that anchor tags were having, but it also seemed to break a bunch of other things like unordered lists, b/strong tags at the beginning of paragraphs, etc.

Here's an alternative that doesn't break other things. You can add this line just before the 'return $str;' part in the convert() function of auto_typography:

Code:
$str = preg_replace('#</p><a(.*?)</a><p>#', ' <a\\1</a> ', $str);




Theme © iAndrew 2016 - Forum software by © MyBB