Arlolra has uploaded a new change for review.
https://gerrit.wikimedia.org/r/230269
Change subject: Cleanup _att_value rules
......................................................................
Cleanup _att_value rules
* Remove all the saved positions and just the offsets instead. Change
the nesting a bit to make it easier to read.
Change-Id: I78d00e0e6f1154a46caced2f987706ad2bf89e54
---
M lib/pegTokenizer.pegjs.txt
1 file changed, 42 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/69/230269/1
diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index 5cebc1b..e9c6e88 100644
--- a/lib/pegTokenizer.pegjs.txt
+++ b/lib/pegTokenizer.pegjs.txt
@@ -1334,37 +1334,51 @@
// Attribute value, quoted variants can span multiple lines.
generic_att_value
- = space_or_newline* "'" r:(valPos1:("" { return endOffset(); })
t1:attribute_preprocessor_text_single? valPos2:("" { return endOffset(); }) "'"
- { return tu.getAttributeValueAndSource(input, t1, valPos1,
valPos2); }
- // Missing end quote: accept | and > look-ahead as heuristic
- / valPos1:("" { return endOffset(); })
t2:attribute_preprocessor_text_single_broken? valPos2:("" { return endOffset();
}) &[|>]
- { return tu.getAttributeValueAndSource(input, t2, valPos1,
valPos2); } )
- { return r; }
- / space_or_newline* '"' r:(valPos1:("" { return endOffset(); })
t1:attribute_preprocessor_text_double? valPos2:("" { return endOffset(); }) '"'
- { return tu.getAttributeValueAndSource(input, t1, valPos1,
valPos2); }
- // Missing end quote: accept | and > look-ahead as heuristic
- / valPos1:("" { return endOffset(); })
t2:attribute_preprocessor_text_double_broken? valPos2:("" { return endOffset();
}) &[|>]
- { return tu.getAttributeValueAndSource(input, t2, valPos1,
valPos2); } )
- { return r; }
- / space_or_newline* valPos1:("" { return endOffset(); })
t:attribute_preprocessor_text !"=" valPos2:("" { return endOffset(); })
- { return tu.getAttributeValueAndSource(input, t, valPos1, valPos2); }
+ = space_or_newline* "'" r:(
+ t1:attribute_preprocessor_text_single? "'" {
+ return tu.getAttributeValueAndSource(input, t1, startOffset(),
endOffset() - 1);
+ }
+ // Missing end quote: accept | and > look-ahead as heuristic
+ / t2:attribute_preprocessor_text_single_broken? &[|>] {
+ return tu.getAttributeValueAndSource(input, t2, startOffset(),
endOffset());
+ }
+ ) { return r; }
+ / space_or_newline* '"' r:(
+ t1:attribute_preprocessor_text_double? '"' {
+ return tu.getAttributeValueAndSource(input, t1, startOffset(),
endOffset() - 1);
+ }
+ // Missing end quote: accept | and > look-ahead as heuristic
+ / t2:attribute_preprocessor_text_double_broken? &[|>] {
+ return tu.getAttributeValueAndSource(input, t2, startOffset(),
endOffset());
+ }
+ ) { return r; }
+ / s:$space_or_newline* t:attribute_preprocessor_text !"=" {
+ return tu.getAttributeValueAndSource(input, t, startOffset() + s.length,
endOffset());
+ }
// Attribute value, restricted to a single line.
table_att_value
- = space* "'" r:(valPos1:("" { return endOffset(); })
t1:attribute_preprocessor_text_single_line? valPos2:("" { return endOffset();
}) "'"
- { return tu.getAttributeValueAndSource(input, t1, valPos1,
valPos2); }
- // Missing end quote: accept | and > look-ahead as heuristic
- / valPos1:("" { return endOffset(); })
t2:attribute_preprocessor_text_single_line_broken? valPos2:("" { return
endOffset(); }) &[|>\n]
- { return tu.getAttributeValueAndSource(input, t2, valPos1,
valPos2); } )
- { return r; }
- / space* '"' r:(valPos1:("" { return endOffset(); })
t1:attribute_preprocessor_text_double_line? valPos2:("" { return endOffset();
}) '"'
- { return tu.getAttributeValueAndSource(input, t1, valPos1,
valPos2); }
- // Missing end quote: accept | and > look-ahead as heuristic
- / valPos1:("" { return endOffset(); })
t2:attribute_preprocessor_text_double_line_broken? valPos2:("" { return
endOffset(); }) &[|>\n]
- { return tu.getAttributeValueAndSource(input, t2, valPos1,
valPos2); } )
- { return r; }
- / space* valPos1:("" { return endOffset(); })
t:attribute_preprocessor_text_line !"=" valPos2:("" { return endOffset(); })
- { return tu.getAttributeValueAndSource(input, t ? t : "", valPos1,
valPos2); }
+ = space* "'" r:(
+ t1:attribute_preprocessor_text_single_line? "'" {
+ return tu.getAttributeValueAndSource(input, t1, startOffset(),
endOffset() - 1);
+ }
+ // Missing end quote: accept | and > look-ahead as heuristic
+ / t2:attribute_preprocessor_text_single_line_broken? &[|>\n] {
+ return tu.getAttributeValueAndSource(input, t2, startOffset(),
endOffset());
+ }
+ ) { return r; }
+ / space* '"' r:(
+ t1:attribute_preprocessor_text_double_line? '"' {
+ return tu.getAttributeValueAndSource(input, t1, startOffset(),
endOffset() - 1);
+ }
+ // Missing end quote: accept | and > look-ahead as heuristic
+ / t2:attribute_preprocessor_text_double_line_broken? &[|>\n] {
+ return tu.getAttributeValueAndSource(input, t2, startOffset(),
endOffset());
+ }
+ ) { return r; }
+ / s:$space* t:attribute_preprocessor_text_line !"=" {
+ return tu.getAttributeValueAndSource(input, t, startOffset() + s.length,
endOffset());
+ }
/*
* A variant of generic_tag, but also checks if the tag name is a block-level
--
To view, visit https://gerrit.wikimedia.org/r/230269
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I78d00e0e6f1154a46caced2f987706ad2bf89e54
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits