diff --git a/core/modules/parsers/wikiparser/rules/emphasis.js b/core/modules/parsers/wikiparser/rules/emphasis.js deleted file mode 100644 index 5950efbbe..000000000 --- a/core/modules/parsers/wikiparser/rules/emphasis.js +++ /dev/null @@ -1,79 +0,0 @@ -/*\ -title: $:/core/modules/parsers/wikiparser/rules/emphasis.js -type: application/javascript -module-type: wikirule - -Wiki text inline rule for emphasis. For example: - -``` - This is ''bold'' text - - This is //italic// text - - This is __underlined__ text - - This is ^^superscript^^ text - - This is ,,subscript,, text - - This is ~~strikethrough~~ text -``` - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.name = "emphasis"; -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; - // Figure out which element and closing regexp to use - var tag,reEnd; - switch(this.match[0]) { - case "''": // Bold - tag = "strong"; - reEnd = /''/mg; - break; - case "//": // Italics - tag = "em"; - reEnd = /\/\//mg; - break; - case "__": // Underline - tag = "u"; - reEnd = /__/mg; - break; - case "^^": // Superscript - tag = "sup"; - reEnd = /\^\^/mg; - break; - case ",,": // Subscript - tag = "sub"; - reEnd = /,,/mg; - break; - case "~~": // Strikethrough - tag = "strike"; - reEnd = /~~/mg; - break; - } - // Parse the run including the terminator - var tree = this.parser.parseInlineRun(reEnd,{eatTerminator: true}); - // Return the classed span - return [{ - type: "element", - tag: tag, - children: tree - }]; -}; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/bold.js b/core/modules/parsers/wikiparser/rules/emphasis/bold.js new file mode 100644 index 000000000..3799feeb5 --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/bold.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/bold.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - bold. For example: + +``` + This is ''bold'' text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except bold +\rules only bold +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "bold"; +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: "strong", + children: tree + }]; +}; + +})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/emphasis/italic.js b/core/modules/parsers/wikiparser/rules/emphasis/italic.js new file mode 100644 index 000000000..3e0744c4d --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/italic.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/italic.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - italic. For example: + +``` + This is //italic// text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except italic +\rules only italic +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "italic"; +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: "em", + children: tree + }]; +}; + +})(); \ No newline at end of file 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 + }]; +}; + +})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js new file mode 100644 index 000000000..12be0fbbc --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/subscript.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - subscript. For example: + +``` + This is ,,subscript,, text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except subscript +\rules only subscript +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "subscript"; +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: "sub", + children: tree + }]; +}; + +})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js new file mode 100644 index 000000000..5a5330d8c --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/superscript.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - superscript. For example: + +``` + This is ^^superscript^^ text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except superscript +\rules only superscript +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "superscript"; +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: "sup", + children: tree + }]; +}; + +})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js new file mode 100644 index 000000000..d36bd242d --- /dev/null +++ b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js @@ -0,0 +1,50 @@ +/*\ +title: $:/core/modules/parsers/wikiparser/rules/emphasis/underscore.js +type: application/javascript +module-type: wikirule + +Wiki text inline rule for emphasis - underscore. For example: + +``` + This is __underscore__ text +``` + +This wikiparser can be modified using the rules eg: + +``` +\rules except underscore +\rules only underscore +``` + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.name = "underscore"; +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: "u", + children: tree + }]; +}; + +})(); \ No newline at end of file