Imports changes from Mediacloth revision r128
| 123 | @entries_lexer_table["\n"] = method(:match_newline_in_entries) | @entries_lexer_table["\n"] = method(:match_newline_in_entries) | 123 |
|---|---|---|---|
| 124 | @entries_lexer_table[":"] = method(:match_colon_in_entries) | @entries_lexer_table[":"] = method(:match_colon_in_entries) | 124 |
| 125 | 125 | ||
# Lexer table used inside spans of indented text | 126 | ||
@indent_lexer_table = @inline_lexer_table.dup | 127 | ||
@indent_lexer_table["\n"] = method(:match_newline_in_indent) | 128 | ||
| 129 | |||
| 126 | # Lexer table used inside spans of pre-formatted text | # Lexer table used inside spans of pre-formatted text | 130 |
| 127 | @pre_lexer_table = @inline_lexer_table.dup | @pre_lexer_table = @inline_lexer_table.dup | 131 |
| 128 | @pre_lexer_table["\n"] = method(:match_newline_in_pre) | @pre_lexer_table["<"] = method(:match_left_angle_in_pre) | 132 |
| 129 | 133 | ||
| 130 | # Lexer table used when inside spans of wiki-escaped text | # Lexer table used when inside spans of wiki-escaped text | 134 |
| 131 | @nowiki_lexer_table = {} | @nowiki_lexer_table = {} | 135 |
| 164 more lines | |||
| 296 | elsif tag_name == 'math' | elsif tag_name == 'math' | 300 |
| 297 | @lexer_table.push(@math_lexer_table) | @lexer_table.push(@math_lexer_table) | 301 |
| 298 | start_span(:TAG, tag_name) | start_span(:TAG, tag_name) | 302 |
elsif tag_name == 'pre' | 303 | ||
@lexer_table.push(@pre_lexer_table) | 304 | ||
start_span(:TAG, tag_name) | 305 | ||
| 299 | else | else | 306 |
| 300 | start_span(:TAG, tag_name) | start_span(:TAG, tag_name) | 307 |
| 301 | attrs.collect do | attrs.collect do | 308 |
| 145 more lines | |||
| 447 | def match_space | def match_space | 454 |
| 448 | if at_start_of_line? | if at_start_of_line? | 455 |
| 449 | start_span(:PRE) | start_span(:PRE) | 456 |
| 450 | @lexer_table.push(@pre_lexer_table) | @lexer_table.push(@indent_lexer_table) | 457 |
| 451 | match_text | match_text | 458 |
| 452 | else | else | 459 |
| 453 | match_text | match_text | 460 |
| 454 | end | end | 461 |
| 455 | end | end | 462 |
| 456 | 463 | ||
| 457 | def match_newline_in_pre | def match_newline_in_indent | 464 |
| 458 | match_text | match_text | 465 |
| 459 | unless @text[@cursor, 1] == " " | unless @text[@cursor, 1] == " " | 466 |
| 460 | @tokens << [:TEXT, @pending] | @tokens << [:TEXT, @pending] | 467 |
| 98 more lines | |||
| 559 | end | end | 566 |
| 560 | end | end | 567 |
| 561 | 568 | ||
def match_left_angle_in_pre | 569 | ||
if @text[@cursor, 7] == '</pre>' | 570 | ||
end_span(:TAG, 'pre') | 571 | ||
@cursor += 7 | 572 | ||
@lexer_table.pop | 573 | ||
else | 574 | ||
match_text | 575 | ||
end | 576 | ||
end | 577 | ||
| 578 | |||
| 562 | def match_left_curly | def match_left_curly | 579 |
| 563 | if at_start_of_line? and @text[@cursor + 1, 1] == '|' | if at_start_of_line? and @text[@cursor + 1, 1] == '|' | 580 |
| 564 | start_span(:TABLE, "{|") | start_span(:TABLE, "{|") | 581 |
| 343 | lex("<math>1 == 1 == 1</math>")) | lex("<math>1 == 1 == 1</math>")) | 343 |
|---|---|---|---|
| 344 | end | end | 344 |
| 345 | 345 | ||
def test_pre | 346 | ||
assert_equal([[:PARA_START, ""], [:TAG_START, "pre"], [:TEXT, "1 == 1 == 1"], [:TAG_END, "pre"], | 347 | ||
[:PARA_END, ""], [false, false]], | 348 | ||
lex("<pre>1 == 1 == 1</pre>")) | 349 | ||
end | 350 | ||
| 351 | |||
| 346 | def test_variable | def test_variable | 352 |
| 347 | assert_equal([[:PARA_START, ""], [:VARIABLE_START, "{{"], [:TEXT, "ref"], [:VARIABLE_END, "}}"], | assert_equal([[:PARA_START, ""], [:VARIABLE_START, "{{"], [:TEXT, "ref"], [:VARIABLE_END, "}}"], | 353 |
| 348 | [:PARA_END, ""], [false, false]], | [:PARA_END, ""], [false, false]], | 354 |