-
Notifications
You must be signed in to change notification settings - Fork 44
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
Unespected space at beginning of link text #168
Comments
combined bug. if a second line have a broken link (caused by space-linktext), e.g. * "Bauordnung für Berlin":http://www.stadtentwicklung.berlin.de/service/gesetzestexte/de/bauen.shtml * " Verwaltungsverfahrensgesetz":http://www.gesetze-im-internet.de/vwvfg/BJNR012530976.html will get you two broken / not-evaluated links. line one alone will get you an correct evaluated link. |
Broken syntax will generate broken code, in any language. |
Allow link text to start with a space.
@neffets I've just pushed a new branch with a partial fix for this. Could you try out the issue-168 branch and let me know how that works for you. Could you please also verify that the issue you reported in #167 still exists in that branch. Many thanks! |
@eliph I'd like to make the handling of this case more robust if I can - but I agree with your sentiment here. |
Tested the "issue-168" branch. It accepts the first link with a space at begin of the linktext. With "issue-168" branch the line-2 and line-3 remains untouched
generates source code <a href="/test/">Line 1</a><br /> “ Line 2”:/test/<br /> “ Line 3”:/test/<br /> Bug #167 is fixed in this branch, it works |
@neffets Just pushed a correction that should cover this case. Please test again. |
@netcarver: Generally I would not not consider bad usage of the Textile syntax a "bug", as already pointed out. Hopefully, this change will not result in breaking other, complex situations where Textile is used correcly. |
Hi @eliph - this has not caused any of the existing test cases to fail. It also makes php-textile more resilient to typos in otherwise correct link text. If you know of any examples that this change would negatively impact, please make them known so I can include them in the test cases and work towards getting them fixed. |
Thanx @eliph , with last commit it is now working completely, all links work. |
@neffets Thank you for testing that. I'll leave this open a few more days in case there is more feedback. |
Hello, i tried v3.6.0 it fixes issue #167, but issue #168 has still problems. Example-1:
Example-2:
I need a little patch in line 3630 like former issue-168 patch patch.Netcarver_Textile_Parser-118.txt --- vendor/netcarver/textile/src/Netcarver/Textile/Parser.php-3.6.0 2018-10-09 09:23:42.792001373 +0000 +++ vendor/netcarver/textile/src/Netcarver/Textile/Parser.php 2018-10-09 15:38:24.667558319 +0000 @@ -3627,16 +3627,27 @@ } } - // Rebuild the link's text by reversing the parts and sticking them back - // together with quotes. - $link_content = implode('"', array_reverse($linkparts)); - - // Rebuild the remaining stuff that goes before the link but that's - // already in order. - $pre_link = implode('"', $possible_start_quotes); - - // Re-assemble the link starts with a specific marker for the next regex. - $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content; + if ($balanced > 0) { + // We found more end-quotes than start quotes. We can try to correct this if there are 'ambiguous' quotes + // present. Ambiguous quotes are quotes that appear with spaces on each side - such that they are not + // obviously a start or an end quote. + $replaced = 0; + $slice = preg_replace('~ +" +~'.$mod, ' '.$this->uid.'linkStartMarker:"', $slice, 1, $replaced); + if ($replaced == 0) { + $slice = preg_replace('~^" +~m'.$mod, $this->uid.'linkStartMarker:"', $slice, 1, $replaced); + } + } else { + // Rebuild the link's text by reversing the parts and sticking them back + // together with quotes. + $link_content = implode('"', array_reverse($linkparts)); + + // Rebuild the remaining stuff that goes before the link but that's + // already in order. + $pre_link = implode('"', $possible_start_quotes); + + // Re-assemble the link starts with a specific marker for the next regex. + $slice = $pre_link . $this->uid.'linkStartMarker:"' . $link_content; + } } // Add the last part back |
I was irritated by text from an editor. Why it does not generate correct links?
The raw text was:
it generates as html output
Until I found: the link-text begins with a space.
I expected as output:
or
Why we cannot accept spaces at beginning of link-text? (came from paste and copy) And it made a typographic quote from it.
The text was updated successfully, but these errors were encountered: