kopia lustrzana https://github.com/miklobit/TiddlyWiki5
41 wiersze
789 B
JavaScript
41 wiersze
789 B
JavaScript
/*\
|
|
title: $:/core/modules/parsers/wikiparser/rules/entity.js
|
|
type: application/javascript
|
|
module-type: wikirule
|
|
|
|
Wiki text inline 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.types = {inline: true};
|
|
|
|
exports.init = function(parser) {
|
|
this.parser = parser;
|
|
// 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]}];
|
|
};
|
|
|
|
})();
|