This is to do with URL processing it appears to be isolated to image tag URL parsing (doesn''t seem to be affected by normal URLs). puts RedCloth.new(''!../../index.html!'').to_html Returns: <p><img src="/../index.html" alt="" /></p> It trims the any number dots before the first / in relative URL''s. I kind of depend on this as the code I''m generating is part of a publishing system that needs to be able to handle relative links so pages can be distributed offline. On a side note, congrats Jason on the rewrite! Will it be long before this new version becomes standard? Cheers Jase.
This is to do with URL processing it appears to be isolated to image tag URL parsing (doesn''t seem to be affected by normal URLs). puts RedCloth.new(''!../../index.html!'').to_html Returns: <p><img src="/../index.html" alt="" /></p> It trims the any number dots before the first / in relative URL''s. I kind of depend on this as the code I''m generating is part of a publishing system that needs to be able to handle relative links so pages can be distributed offline. On a side note, congrats Jason on the rewrite! Will it be long before this new version becomes standard? Cheers Jase.
Textile allows for a dot there to end alignment/class/style for the image. RedCloth 3.0.4 and http://textile.thresholdstate.com/ both eat the first dot.> > RedCloth::VERSION > => "3.0.4" > > RedCloth.new("!../../image.jpg!").to_html > => <p><img src="./../image.jpg" alt="" /></p>Textile: !../../image.jpg! XHTML: <p><img src="./../image.jpg" alt="" /></p> It appears that both intend to allow that dot only when it''s followed by a space... RedCloth 3.0.4:> IMAGE_RE = / > (<p>|.|^) # start of line? > \! # opening > (\<|\=|\>)? # optional alignment atts > (#{C}) # optional style,class atts > (?:\. )? # optional dot-space > ([^\s(!]+?) # presume this is the src > \s? # optional space > (?:\(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title > \! # closing > (?::#{ HYPERLINK })? # optional href > /xclassTextile.php:> function image($text) > { > return preg_replace_callback("/ > (?:[[{])? # pre > \! # opening ! > (\<|\=|\>)?? # optional alignment atts > ($this->c) # optional style,class atts > (?:\. )? # optional dot-space > ([^\s(!]+) # presume this is the src > \s? # optional space > (?:\(([^\)]+)\))? # optional title > \! # closing > (?::(\S+))? # optional href > (?:[\]}]|(?=\s|$)) # lookahead: space or end of string > /Ux", array(&$this, "fImage"), $text); > }... but it appears the classTextile.php author missed that that space would be ignored because of the the x (PCRE_EXTENDED) option (and RedCloth copied the mistake). Using this seems to fix it:> (?:\.\s)? # optional dot-spaceIs it better to implement it the "right" (intended) way or in a way that''s backward-compatible? I''m going to do it "right" for now and we''ll see how that works out. http://code.whytheluckystiff.net/redcloth/ticket/49 On Apr 12, 2008, at 7:05 PM, Jase wrote:> This is to do with URL processing it appears to be isolated to > image tag > URL parsing (doesn''t seem to be affected by normal URLs). > > puts RedCloth.new(''!../../index.html!'').to_html > > Returns: > > <p><img src="/../index.html" alt="" /></p> > > It trims the any number dots before the first / in relative URL''s. I > kind of depend on this as the code I''m generating is part of a > publishing system that needs to be able to handle relative links so > pages can be distributed offline. > > On a side note, congrats Jason on the rewrite! Will it be long before > this new version becomes standard? > > Cheers > Jase. > > > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/redcloth-upwards/attachments/20080414/3f31e88e/attachment-0001.html
Excellent work! Many thanks. Can''t believe I missed how easy it was (I was looking at the URL parsing rules without even stopping to realise there was a separate set of image parsing rules in the inline Ragel file). On a side note, I think I saw something in Trac relating to this, not sure if it''s the same, but installing from instructions at http://code.whytheluckystiff.net/redcloth/wiki/SuperRedCloth don''t quite work (for me at least on Linux) $ gem install redcloth --source http://code.whytheluckystiff.net Doesn''t work before it needs to be spelt RedCloth still. $ svn co http://code.whytheluckystiff.net/svn/redcloth/trunk redcloth $ cd redcloth $ rake $ rake gem $ gem install pkg/redcloth-3.###.gem Also doesn''t work because it moans about something in the Rakefile on line 176. I had to change the platform from WIN32 to CURRENT. Seemed to work after that, though I dunno if it screws up compiling on WIN32 now (Not that I care much for Windows personally!) Anyway, once again thanks for the quick response. Jase On Mon, 2008-04-14 at 09:43 -0400, Jason Garber wrote:> Textile allows for a dot there to end alignment/class/style for the > image. RedCloth 3.0.4 and http://textile.thresholdstate.com/ both eat > the first dot. > > > > > RedCloth::VERSION=> "3.0.4"> > > RedCloth.new("!../../image.jpg!").to_html=> <p><img > > src="./../image.jpg" alt="" /></p> > > Textile: > !../../image.jpg! > XHTML: > <p><img src="./../image.jpg" alt="" /></p> > > It appears that both intend to allow that dot only when it''s followed > by a space... > RedCloth 3.0.4: > > IMAGE_RE = / (<p>|.|^) # start of line? > > \! # opening (\<|\=|\>)? > > # optional alignment atts (#{C}) # > > optional style,class atts (?:\. )? # optional > > dot-space ([^\s(!]+?) # presume this is the > > src \s? # optional space (?: > > \(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! > > # closing (?::#{ HYPERLINK })? # optional href /x > > > classTextile.php: > > function image($text) { return > > preg_replace_callback("/ (?:[[{])? # pre > > \! # opening ! (\<|\=|\>)?? # > > optional alignment atts ($this->c) # optional > > style,class atts (?:\. )? # optional > > dot-space ([^\s(!]+) # presume this is the src > > \s? # optional space (?:\(([^ > > \)]+)\))? # optional title \! # > > closing (?::(\S+))? # optional href > > (?:[\]}]|(?=\s|$)) # lookahead: space or end of string /Ux", > > array(&$this, "fImage"), $text); } > > > ... but it appears the classTextile.php author missed that that space > would be ignored because of the the x (PCRE_EXTENDED) option (and > RedCloth copied the mistake). Using this seems to fix it: > > > (?:\.\s)? # optional dot-space > > > Is it better to implement it the "right" (intended) way or in a way > that''s backward-compatible? > > > I''m going to do it "right" for now and we''ll see how that works out. > > > http://code.whytheluckystiff.net/redcloth/ticket/49 > > > > > On Apr 12, 2008, at 7:05 PM, Jase wrote: > > This is to do with URL processing it appears to be isolated to image > > tag > > URL parsing (doesn''t seem to be affected by normal URLs). > > > > > > puts RedCloth.new(''!../../index.html!'').to_html > > > > > > Returns: > > > > > > <p><img src="/../index.html" alt="" /></p> > > > > > > It trims the any number dots before the first / in relative URL''s. I > > kind of depend on this as the code I''m generating is part of a > > publishing system that needs to be able to handle relative links so > > pages can be distributed offline. > > > > > > On a side note, congrats Jason on the rewrite! Will it be long > > before > > this new version becomes standard? > > > > > > Cheers > > Jase. > > > > > > > > > > _______________________________________________ > > Redcloth-upwards mailing list > > Redcloth-upwards at rubyforge.org > > http://rubyforge.org/mailman/listinfo/redcloth-upwards > > > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards
> Excellent work! Many thanks. Can''t believe I missed how easy it was (I > was looking at the URL parsing rules without even stopping to realise > there was a separate set of image parsing rules in the inline Ragel > file).So glad you found this bug!> > On a side note, I think I saw something in Trac relating to this, not > sure if it''s the same, but installing from instructions at > http://code.whytheluckystiff.net/redcloth/wiki/SuperRedCloth don''t > quite > work (for me at least on Linux)You''re right. Rubygem names are case sensitive. I''ve changed the wiki page.> > $ gem install redcloth --source http://code.whytheluckystiff.net > > Doesn''t work before it needs to be spelt RedCloth still. > > $ svn co http://code.whytheluckystiff.net/svn/redcloth/trunk redcloth > $ cd redcloth > $ rake > $ rake gem > $ gem install pkg/redcloth-3.###.gem > > Also doesn''t work because it moans about something in the Rakefile on > line 176. I had to change the platform from WIN32 to CURRENT. > Seemed to > work after that, though I dunno if it screws up compiling on WIN32 now > (Not that I care much for Windows personally!)Yes, this is a problem. I''d been switching it from WIN32 to CURRENT and _why switched it back a time or two, so I asked him about it and he needs it set to WIN32 to cross-compile to win32 from his linux machine. He must be running an older version of rubygems. We need to figure out how to cross-compile without an error under rubygems >= 1.0. Jason> > Anyway, once again thanks for the quick response. > Jase > > > On Mon, 2008-04-14 at 09:43 -0400, Jason Garber wrote: >> Textile allows for a dot there to end alignment/class/style for the >> image. RedCloth 3.0.4 and http://textile.thresholdstate.com/ both >> eat >> the first dot. >> >> >>>> RedCloth::VERSION=> "3.0.4"> >>> RedCloth.new("!../../image.jpg!").to_html=> <p><img >>> src="./../image.jpg" alt="" /></p> >> >> Textile: >> !../../image.jpg! >> XHTML: >> <p><img src="./../image.jpg" alt="" /></p> >> >> It appears that both intend to allow that dot only when it''s followed >> by a space... >> RedCloth 3.0.4: >>> IMAGE_RE = / (<p>|.|^) # start of line? >>> \! # opening (\<|\=|\>)? >>> # optional alignment atts (#{C}) # >>> optional style,class atts (?:\. )? # optional >>> dot-space ([^\s(!]+?) # presume this is the >>> src \s? # optional space (?: >>> \(((?:[^\(\)]|\([^\)]+\))+?)\))? # optional title \! >>> # closing (?::#{ HYPERLINK })? # optional href /x >> >> >> classTextile.php: >>> function image($text) { return >>> preg_replace_callback("/ (?:[[{])? # pre >>> \! # opening ! (\<|\=|\>)?? # >>> optional alignment atts ($this->c) # optional >>> style,class atts (?:\. )? # optional >>> dot-space ([^\s(!]+) # presume this is the src >>> \s? # optional space (?:\(([^ >>> \)]+)\))? # optional title \! # >>> closing (?::(\S+))? # optional href >>> (?:[\]}]|(?=\s|$)) # lookahead: space or end of string /Ux", >>> array(&$this, "fImage"), $text); } >> >> >> ... but it appears the classTextile.php author missed that that space >> would be ignored because of the the x (PCRE_EXTENDED) option (and >> RedCloth copied the mistake). Using this seems to fix it: >> >>> (?:\.\s)? # optional dot-space >> >> >> Is it better to implement it the "right" (intended) way or in a way >> that''s backward-compatible? >> >> >> I''m going to do it "right" for now and we''ll see how that works out. >> >> >> http://code.whytheluckystiff.net/redcloth/ticket/49 >> >> >> >> >> On Apr 12, 2008, at 7:05 PM, Jase wrote: >>> This is to do with URL processing it appears to be isolated to image >>> tag >>> URL parsing (doesn''t seem to be affected by normal URLs). >>> >>> >>> puts RedCloth.new(''!../../index.html!'').to_html >>> >>> >>> Returns: >>> >>> >>> <p><img src="/../index.html" alt="" /></p> >>> >>> >>> It trims the any number dots before the first / in relative URL''s. I >>> kind of depend on this as the code I''m generating is part of a >>> publishing system that needs to be able to handle relative links so >>> pages can be distributed offline. >>> >>> >>> On a side note, congrats Jason on the rewrite! Will it be long >>> before >>> this new version becomes standard? >>> >>> >>> Cheers >>> Jase. >>> >>> >>> >>> >>> _______________________________________________ >>> Redcloth-upwards mailing list >>> Redcloth-upwards at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/redcloth-upwards >> >> >> _______________________________________________ >> Redcloth-upwards mailing list >> Redcloth-upwards at rubyforge.org >> http://rubyforge.org/mailman/listinfo/redcloth-upwards > > _______________________________________________ > Redcloth-upwards mailing list > Redcloth-upwards at rubyforge.org > http://rubyforge.org/mailman/listinfo/redcloth-upwards