Fixed super minor issue with import pragma (#5521)

publishing-framework
Cameron Fischer 2021-05-23 12:39:06 -04:00 zatwierdzone przez GitHub
rodzic 8fbf52e419
commit 61714cbda3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -36,7 +36,7 @@ exports.parse = function() {
// Move past the pragma invocation
this.parser.pos = this.matchRegExp.lastIndex;
// Parse the filter terminated by a line break
var reMatch = /(.*)(\r?\n)|$/mg;
var reMatch = /(.*)(?:$|\r?\n)/mg;
reMatch.lastIndex = this.parser.pos;
var match = reMatch.exec(this.parser.source);
this.parser.pos = reMatch.lastIndex;

Wyświetl plik

@ -702,6 +702,19 @@ describe("Widget module", function() {
expect(wrapper.innerHTML).toBe("<p>Don't forget me.</p>");
});
/** Special case. \import should parse correctly, even if it's
* the only line in the tiddler. Technically doesn't cause a
* visual difference, but may affect plugins if it doesn't.
*/
it("should work when import pragma is standalone", function() {
var wiki = new $tw.Wiki();
var text = "\\import [prefix[XXX]]";
var parseTreeNode = parseText(text,wiki);
// Test the resulting parse tree node, since there is no
// rendering which may expose a problem.
expect(parseTreeNode.children[0].attributes.filter.value).toBe('[prefix[XXX]]');
});
/** This test reproduces issue #4504.
*
* The importvariable widget was creating redundant copies into