Imports changes from Mediacloth revision r123
| 25 | # text; or spans of XHTML, or wiki-escape, markup | # text; or spans of XHTML, or wiki-escape, markup | 25 |
|---|---|---|---|
| 26 | @formatting_lexer_table = {} | @formatting_lexer_table = {} | 26 |
| 27 | @formatting_lexer_table["'"] = method(:match_quote) | @formatting_lexer_table["'"] = method(:match_quote) | 27 |
| 28 | @formatting_lexer_table["<"] = method(:match_right_angle) | @formatting_lexer_table["<"] = method(:match_left_angle) | 28 |
| 29 | @formatting_lexer_table["&"] = method(:match_ampersand) | @formatting_lexer_table["&"] = method(:match_ampersand) | 29 |
| 30 | @formatting_lexer_table["{"] = method(:match_left_curly) | @formatting_lexer_table["{"] = method(:match_left_curly) | 30 |
| 31 | 31 | ||
| 96 more lines | |||
| 128 | @pre_lexer_table["\n"] = method(:match_newline_in_pre) | @pre_lexer_table["\n"] = method(:match_newline_in_pre) | 128 |
| 129 | 129 | ||
| 130 | # Lexer table used when inside spans of wiki-escaped text | # Lexer table used when inside spans of wiki-escaped text | 130 |
| 131 | @escape_lexer_table = {} | @nowiki_lexer_table = {} | 131 |
| 132 | @escape_lexer_table["<"] = method(:match_right_angle_in_tag) | @nowiki_lexer_table["<"] = method(:match_left_angle_in_nowiki) | 132 |
| 133 | |||
# Lexer table used when inside spans of math | 134 | ||
@math_lexer_table = {} | 135 | ||
@math_lexer_table["<"] = method(:match_left_angle_in_math) | 136 | ||
| 133 | 137 | ||
| 134 | # Lexer table used when inside a wiki variable reference | # Lexer table used when inside a wiki variable reference | 138 |
| 135 | @variable_lexer_table = {} | @variable_lexer_table = {} | 139 |
| 124 more lines | |||
| 260 | end | end | 264 |
| 261 | end | end | 265 |
| 262 | 266 | ||
| 263 | def match_right_angle | def match_left_angle | 267 |
| 264 | next_char = @text[@cursor + 1] | next_char = @text[@cursor + 1] | 268 |
| 265 | if next_char == 47 | if next_char == 47 | 269 |
| 266 | # Might be an XHTML end tag | # Might be an XHTML end tag | 270 |
| 20 more lines | |||
| 287 | if ((c = scanner.get_byte) == '>' or (c == '/' and scanner.get_byte == '>')) | if ((c = scanner.get_byte) == '>' or (c == '/' and scanner.get_byte == '>')) | 291 |
| 288 | # Found an XHTML start or empty tag | # Found an XHTML start or empty tag | 292 |
| 289 | if tag_name == 'nowiki' | if tag_name == 'nowiki' | 293 |
| 290 | @lexer_table.push(@escape_lexer_table) | @lexer_table.push(@nowiki_lexer_table) | 294 |
elsif tag_name == 'math' | 295 | ||
@lexer_table.push(@math_lexer_table) | 296 | ||
start_span(:TAG, tag_name) | 297 | ||
| 291 | else | else | 298 |
| 292 | start_span(:TAG, tag_name) | start_span(:TAG, tag_name) | 299 |
| 293 | attrs.collect do | attrs.collect do | 300 |
| 237 more lines | |||
| 531 | end | end | 538 |
| 532 | end | end | 539 |
| 533 | 540 | ||
| 534 | def match_right_angle_in_tag | def match_left_angle_in_nowiki | 541 |
| 535 | if @text[@cursor, 9] == '</nowiki>' | if @text[@cursor, 9] == '</nowiki>' | 542 |
| 536 | @cursor += 9 | @cursor += 9 | 543 |
| 537 | @lexer_table.pop | @lexer_table.pop | 544 |
| 2 more lines | |||
| 540 | end | end | 547 |
| 541 | end | end | 548 |
| 542 | 549 | ||
def match_left_angle_in_math | 550 | ||
if @text[@cursor, 7] == '</math>' | 551 | ||
end_span(:TAG, 'math') | 552 | ||
@cursor += 7 | 553 | ||
@lexer_table.pop | 554 | ||
else | 555 | ||
match_text | 556 | ||
end | 557 | ||
end | 558 | ||
| 559 | |||
| 543 | def match_left_curly | def match_left_curly | 560 |
| 544 | if at_start_of_line? and @text[@cursor + 1, 1] == '|' | if at_start_of_line? and @text[@cursor + 1, 1] == '|' | 561 |
| 545 | start_span(:TABLE, "{|") | start_span(:TABLE, "{|") | 562 |
| 18 | end | end | 18 |
|---|---|---|---|
| 19 | 19 | ||
| 20 | def test_uses_element_attributes_from_link_handler | def test_uses_element_attributes_from_link_handler | 20 |
| 21 | assert_generates '<p><a class="empty" href="http://www.example.com/wiki/InternalLink">This is just an internal link</a></p>', | assert_generates '<p><a href="http://www.example.com/wiki/InternalLink" class="empty">This is just an internal link</a></p>', | 21 |
| 22 | '[[InternalLink|This is just an internal link]]', | '[[InternalLink|This is just an internal link]]', | 22 |
| 23 | ClassEmptyLinkHandler.new | ClassEmptyLinkHandler.new | 23 |
| 24 | end | end | 24 |
| 337 | lex("<nowiki><u>uuu</u></nowiki>")) | lex("<nowiki><u>uuu</u></nowiki>")) | 337 |
|---|---|---|---|
| 338 | end | end | 338 |
| 339 | 339 | ||
def test_math | 340 | ||
assert_equal([[:PARA_START, ""], [:TAG_START, "math"], [:TEXT, "1 == 1 == 1"], [:TAG_END, "math"], | 341 | ||
[:PARA_END, ""], [false, false]], | 342 | ||
lex("<math>1 == 1 == 1</math>")) | 343 | ||
end | 344 | ||
| 345 | |||
| 340 | def test_variable | def test_variable | 346 |
| 341 | assert_equal([[:PARA_START, ""], [:VARIABLE_START, "{{"], [:TEXT, "ref"], [:VARIABLE_END, "}}"], | assert_equal([[:PARA_START, ""], [:VARIABLE_START, "{{"], [:TEXT, "ref"], [:VARIABLE_END, "}}"], | 347 |
| 342 | [:PARA_END, ""], [false, false]], | [:PARA_END, ""], [false, false]], | 348 |