2012-12-15 11:39:58 +00:00
|
|
|
/*\
|
2012-12-20 16:41:06 +00:00
|
|
|
title: $:/core/modules/parsers/wikiparser/rules/dash.js
|
2012-12-15 11:39:58 +00:00
|
|
|
type: application/javascript
|
2012-12-20 16:02:03 +00:00
|
|
|
module-type: wikirule
|
2012-12-15 11:39:58 +00:00
|
|
|
|
2012-12-20 12:18:38 +00:00
|
|
|
Wiki text inline rule for dashes. For example:
|
2012-12-15 11:39:58 +00:00
|
|
|
|
2012-12-22 23:09:44 +00:00
|
|
|
```
|
2012-12-15 11:39:58 +00:00
|
|
|
This is an en-dash: --
|
|
|
|
|
|
|
|
This is an em-dash: ---
|
2012-12-22 23:09:44 +00:00
|
|
|
```
|
2012-12-15 11:39:58 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
exports.name = "dash";
|
2012-12-20 16:02:03 +00:00
|
|
|
exports.types = {inline: true};
|
2012-12-15 11:39:58 +00:00
|
|
|
|
|
|
|
exports.init = function(parser) {
|
|
|
|
this.parser = parser;
|
|
|
|
// Regexp to match
|
2012-12-26 19:32:06 +00:00
|
|
|
this.matchRegExp = /-{2,3}(?!-)/mg;
|
2012-12-15 11:39:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|