2012-12-13 21:34:31 +00:00
|
|
|
/*\
|
2012-12-20 16:41:06 +00:00
|
|
|
title: $:/core/modules/parsers/wikiparser/rules/entity.js
|
2012-12-13 21:34:31 +00:00
|
|
|
type: application/javascript
|
2012-12-20 16:02:03 +00:00
|
|
|
module-type: wikirule
|
2012-12-13 21:34:31 +00:00
|
|
|
|
2012-12-20 12:18:38 +00:00
|
|
|
Wiki text inline rule for HTML entities. For example:
|
2012-12-13 21:34:31 +00:00
|
|
|
|
|
|
|
{{{
|
|
|
|
This is a copyright symbol: ©
|
|
|
|
}}}
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2012-12-14 13:31:47 +00:00
|
|
|
exports.name = "entity";
|
2012-12-20 16:02:03 +00:00
|
|
|
exports.types = {inline: true};
|
2012-12-13 21:34:31 +00:00
|
|
|
|
2012-12-14 15:44:19 +00:00
|
|
|
exports.init = function(parser) {
|
|
|
|
this.parser = parser;
|
2012-12-14 13:31:47 +00:00
|
|
|
// Regexp to match
|
|
|
|
this.matchRegExp = /(&#?[a-zA-Z0-9]{2,8};)/mg;
|
2012-12-13 21:34:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Parse the most recent match
|
|
|
|
*/
|
2012-12-14 13:31:47 +00:00
|
|
|
exports.parse = function() {
|
2012-12-13 21:34:31 +00:00
|
|
|
// Get all the details of the match
|
|
|
|
var entityString = this.match[1];
|
|
|
|
// Move past the macro call
|
2012-12-14 13:31:47 +00:00
|
|
|
this.parser.pos = this.matchRegExp.lastIndex;
|
2012-12-13 21:34:31 +00:00
|
|
|
// Return the entity
|
|
|
|
return [{type: "entity", entity: this.match[0]}];
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|