mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 23:36:42 +00:00
* remove blks first try * dprint.json seems to be OK, some forgotten functions * add some more space-after-keyword settings * server remove blks * add **/files to dprint exclude * dprint.js fixes a typo * add boot.js and bootprefix.js to dprint exclude * dprint change dprint.json * add dprint fmt as script * remove jslint comments * fix whitespace * fix whitespace * remove function-wrapper from geospatial plugin * fix whitespace * add function wrapper to dyannotate-startup * remove dpring.json
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/*\
|
|
title: $:/core/modules/parsers/wikiparser/rules/commentblock.js
|
|
type: application/javascript
|
|
module-type: wikirule
|
|
|
|
Wiki text block rule for HTML comments. For example:
|
|
|
|
```
|
|
<!-- This is a comment -->
|
|
\define macroX()
|
|
<!-- This is a comment -->
|
|
xxxx
|
|
\end
|
|
<!-- This is a comment -->
|
|
|
|
```
|
|
|
|
Note that the syntax for comments is simplified to an opening "<!--" sequence and a closing "-->" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html)
|
|
|
|
\*/
|
|
|
|
"use strict";
|
|
|
|
exports.name = "commentblock";
|
|
exports.types = {block:true, pragma:true};
|
|
|
|
exports.init = function(parser) {
|
|
this.parser = parser;
|
|
this.matchRegExp = /<!--/mg;
|
|
this.endMatchRegExp = /-->/mg;
|
|
};
|
|
|
|
exports.findNextMatch = function(startPos) {
|
|
this.matchRegExp.lastIndex = startPos;
|
|
this.match = this.matchRegExp.exec(this.parser.source);
|
|
if(this.match) {
|
|
this.endMatchRegExp.lastIndex = this.match.index + this.match[0].length;
|
|
this.endMatch = this.endMatchRegExp.exec(this.parser.source);
|
|
if(this.endMatch) {
|
|
return this.match.index;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
|
|
exports.parse = function() {
|
|
// Move past the match
|
|
this.parser.pos = this.endMatchRegExp.lastIndex;
|
|
// Don't return any elements
|
|
return [];
|
|
};
|