Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow HTML tags with quoted attributes to be inside link text.

To do this, I had to remove the possibility that attributes in HTML tags could have spaces around the equals sign or unquoted attributes.  This change also greatly expands the complexity of the state machine, so compilation takes a long time. Sorry.
  • Loading branch information...
commit df84e47a44c5677457afb52992b319d15fdc2059 1 parent 28f97a5
@jgarber jgarber authored
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+=== Edge
+
+* Allow HTML tags with quoted attributes to be inside link text. To do this, I had to remove the possibility that attributes in HTML tags could have spaces around the equals sign or unquoted attributes. This change also greatly expands the complexity of the state machine, so compilation takes a long time. Sorry.
+
=== 4.1.9 / February 20, 2009
* Make compatible with Ruby 1.9.
View
2  ext/redcloth_scan/redcloth_common.rl
@@ -70,7 +70,7 @@
Q2Attr = [^"]* ;
UnqAttr = ( space | [^ \t\r\n<>"'] [^ \t\r\n<>]* ) ;
Nmtoken = NameChar+ ;
- Attr = NameAttr space* "=" space* ('"' Q2Attr '"' | "'" Q1Attr "'" | UnqAttr space+ ) space* ;
+ Attr = NameAttr "=" ('"' Q2Attr '"' | "'" Q1Attr "'" ) space* ;
AttrEnd = ( NameAttr space* "=" space* UnqAttr? | Nmtoken ) ;
AttrSet = ( Attr | Nmtoken space+ ) ;
View
32 ext/redcloth_scan/redcloth_inline.rl
@@ -7,13 +7,27 @@
machine redcloth_inline;
+ # html
+ start_tag_noactions = "<" Name space+ AttrSet* (AttrEnd)? ">" | "<" Name ">" ;
+ empty_tag_noactions = "<" Name space+ AttrSet* (AttrEnd)? "/>" | "<" Name "/>" ;
+ end_tag_noactions = "</" Name space* ">" ;
+ any_tag_noactions = ( start_tag_noactions | empty_tag_noactions | end_tag_noactions ) ;
+
+ start_tag = start_tag_noactions >X >A %T ;
+ empty_tag = empty_tag_noactions >X >A %T ;
+ end_tag = end_tag_noactions >X >A %T ;
+ html_comment = ("<!--" (default+) :>> "-->") >X >A %T;
+
# links
- mtext_noquotes = mtext -- '"' ;
- quoted_mtext = '"' mtext_noquotes '"' ;
- mtext_including_quotes = (mtext_noquotes ' "' mtext_noquotes '" ' mtext_noquotes?)+ ;
- link_says = ( C_noactions "."* " "* ((quoted_mtext | mtext_including_quotes | mtext_noquotes) -- '":') ) >A %{ STORE("name"); } ;
- link_says_noquotes_noactions = ( C_noquotes_noactions "."* " "* ((mtext_noquotes) -- '":') ) ;
- link = ( '"' link_says '":' %A uri %{ STORE_URL("href"); } ) >X ;
+ link_text_char = (default - [ "<>]) ;
+ link_text_char_or_tag = ( link_text_char | any_tag_noactions ) ;
+ link_mtext = ( link_text_char+ (mspace link_text_char+)* ) ;
+ quoted_mtext = '"' link_mtext '"' ;
+ link_mtext_including_tags = ( link_text_char_or_tag+ (mspace link_text_char_or_tag+)* ) ;
+ mtext_including_quotes = (link_mtext ' "' link_mtext '" ' link_mtext?)+ ;
+ link_says = ( C_noactions "."* " "* (quoted_mtext | mtext_including_quotes | link_mtext_including_tags ) ) >A %{ STORE("name"); } ;
+ link_says_noquotes_noactions = ( C_noquotes_noactions "."* " "* ((link_mtext) -- '":') ) ;
+ link = ( '"' link_says :>> '":' %A uri %{ STORE_URL("href"); } ) >X ;
link_noquotes_noactions = ( '"' link_says_noquotes_noactions '":' uri ) ;
bracketed_link = ( '["' link_says '":' %A uri %{ STORE("href"); } :> "]" ) >X ;
@@ -57,12 +71,6 @@
quote2 = ('"' >X %A ( mtext_inside_quotes - (mtext_inside_quotes html_tag_up_to_attribute_quote ) ) %T :> '"' ) ;
multi_paragraph_quote = (('"' when starts_line) >X %A ( chars -- '"' ) %T );
- # html
- start_tag = ( "<" Name space+ AttrSet* (AttrEnd)? ">" | "<" Name ">" ) >X >A %T ;
- empty_tag = ( "<" Name space+ AttrSet* (AttrEnd)? "/>" | "<" Name "/>" ) >X >A %T ;
- end_tag = ( "</" Name space* ">" ) >X >A %T ;
- html_comment = ("<!--" (default+) :>> "-->") >X >A %T;
-
# glyphs
ellipsis = ( " "? >A %T "..." ) >X ;
emdash = "--" ;
View
8 test/links.yml
@@ -282,4 +282,10 @@ name: with caps in the title
in: |-
"British Skin Foundation (BSF)":http://www.britishskinfoundation.org.uk
html: |-
- <p><a href="http://www.britishskinfoundation.org.uk" title="BSF">British Skin Foundation</a></p>
+ <p><a href="http://www.britishskinfoundation.org.uk" title="BSF">British Skin Foundation</a></p>
+---
+name: containing HTML tags with quotes
+in: |-
+ "<r:attachment:image name="checkmark.gif" alt="Apply online" />*apply online*":/admissions/apply/
+html: |-
+ <p><a href="/admissions/apply/"><r:attachment:image name="checkmark.gif" alt="Apply online" /><strong>apply online</strong></a></p>
Please sign in to comment.
Something went wrong with that request. Please try again.