mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 20:10:03 +00:00
Adjust wikitext html rule to parse in block mode if the opening tag is immediate followed by a newline
This commit is contained in:
parent
ca2c790c27
commit
a7dd86b52a
@ -27,10 +27,13 @@ exports.regExpString = "<[A-Za-z]+\\s*[^>]*>";
|
|||||||
|
|
||||||
exports.parse = function(match,isBlock) {
|
exports.parse = function(match,isBlock) {
|
||||||
var reStart = /<([A-Za-z]+)(\s*[^>]*)>/mg,
|
var reStart = /<([A-Za-z]+)(\s*[^>]*)>/mg,
|
||||||
|
reLineBreak = /(\r?\n)/mg,
|
||||||
reAttr = /\s*([A-Za-z\-_]+)(?:\s*=\s*(?:("[^"]*")|('[^']*')|([^"'\s]+)))?/mg;
|
reAttr = /\s*([A-Za-z\-_]+)(?:\s*=\s*(?:("[^"]*")|('[^']*')|([^"'\s]+)))?/mg;
|
||||||
|
// Process the start regexp to get the attribute portion
|
||||||
reStart.lastIndex = this.pos;
|
reStart.lastIndex = this.pos;
|
||||||
var startMatch = reStart.exec(this.source);
|
var startMatch = reStart.exec(this.source);
|
||||||
if(startMatch && startMatch.index === this.pos) {
|
if(startMatch && startMatch.index === this.pos) {
|
||||||
|
// Process the attributes
|
||||||
var attrMatch = reAttr.exec(startMatch[2]),
|
var attrMatch = reAttr.exec(startMatch[2]),
|
||||||
attributes = {};
|
attributes = {};
|
||||||
while(attrMatch) {
|
while(attrMatch) {
|
||||||
@ -49,6 +52,15 @@ exports.parse = function(match,isBlock) {
|
|||||||
attrMatch = reAttr.exec(startMatch[2]);
|
attrMatch = reAttr.exec(startMatch[2]);
|
||||||
}
|
}
|
||||||
this.pos = startMatch.index + startMatch[0].length;
|
this.pos = startMatch.index + startMatch[0].length;
|
||||||
|
// Check for a line break immediate after the opening tag
|
||||||
|
reLineBreak.lastIndex = this.pos;
|
||||||
|
var lineBreakMatch = reLineBreak.exec(this.source);
|
||||||
|
if(lineBreakMatch && lineBreakMatch.index === this.pos) {
|
||||||
|
this.pos = lineBreakMatch.index + lineBreakMatch[0].length;
|
||||||
|
isBlock = true;
|
||||||
|
} else {
|
||||||
|
isBlock = false;
|
||||||
|
}
|
||||||
var reEndString = "(</" + startMatch[1] + ">)",
|
var reEndString = "(</" + startMatch[1] + ">)",
|
||||||
reEnd = new RegExp(reEndString,"mg"),
|
reEnd = new RegExp(reEndString,"mg"),
|
||||||
content;
|
content;
|
||||||
|
Loading…
Reference in New Issue
Block a user