1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-08 04:54:23 +00:00
TiddlyWiki5/core/modules/parsers/wikiparser/rules/run/dash.js

42 lines
800 B
JavaScript
Raw Normal View History

2012-12-15 11:39:58 +00:00
/*\
title: $:/core/modules/parsers/wikiparser/rules/run/dash.js
type: application/javascript
module-type: wikirunrule
Wiki text run rule for dashes. For example:
{{{
This is an en-dash: --
This is an em-dash: ---
}}}
Dashes must be followed by whitespace in order to be distinguished from strikethrough notation (`--strikethrough--`).
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "dash";
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /-{2,3}(?=\s)/mg;
};
exports.parse = function() {
// Move past the match
this.parser.pos = this.matchRegExp.lastIndex;
var dash = this.match[0].length === 2 ? "–" : "—";
return [{
type: "entity",
entity: dash
}];
};
})();