1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-13 17:16:48 +00:00
TiddlyWiki5/core/modules/parsers/wikiparser/rules/run/entity.js
Jeremy Ruston 31b283ef36 Refactoring implementation of wiki parse rules
And some documentation.
2012-12-14 13:31:47 +00:00

39 lines
732 B
JavaScript

/*\
title: $:/core/modules/parsers/wikiparser/rules/run/entity.js
type: application/javascript
module-type: wikirunrule
Wiki text run rule for HTML entities. For example:
{{{
This is a copyright symbol: ©
}}}
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "entity";
exports.init = function() {
// Regexp to match
this.matchRegExp = /(&#?[a-zA-Z0-9]{2,8};)/mg;
};
/*
Parse the most recent match
*/
exports.parse = function() {
// Get all the details of the match
var entityString = this.match[1];
// Move past the macro call
this.parser.pos = this.matchRegExp.lastIndex;
// Return the entity
return [{type: "entity", entity: this.match[0]}];
};
})();