From bb47f1dbadadbbf8a5cea8f9dad11f98771ecf56 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Thu, 24 Jul 2014 23:49:42 +0200 Subject: [PATCH] fix whitespace and filename --- .../rules/emphasis/strikethrough.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js diff --git a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js new file mode 100644 index 000000000..0fb34fc52 --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - strikethrough. For example: + +``` + This is ~~strikethrough~~ text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except strikethrough +\rules only strikethrough +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "strikethrough"; +exports.types = {inline: true}; + +exports.init = function(parser) { + this.parser = parser; + // Regexp to match + this.matchRegExp = /~~/mg; +}; + +exports.parse = function() { + // Move past the match + this.parser.pos = this.matchRegExp.lastIndex; + + // Parse the run including the terminator + var tree = this.parser.parseInlineRun(/~~/mg,{eatTerminator: true}); + + // Return the classed span + return [{ + type: "element", + tag: "strike", + children: tree + }]; +}; + +})();