2013-04-10 16:02:37 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/parsers/htmlparser.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: parser
|
|
|
|
|
|
|
|
The HTML parser displays text as raw HTML
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var HtmlParser = function(type,text,options) {
|
2014-06-11 22:04:58 +00:00
|
|
|
var src;
|
|
|
|
if(options._canonical_uri) {
|
|
|
|
src = options._canonical_uri;
|
|
|
|
} else if(text) {
|
2014-11-03 16:20:49 +00:00
|
|
|
src = "data:text/html;charset=utf-8," + encodeURIComponent(text);
|
2014-06-11 22:04:58 +00:00
|
|
|
}
|
2013-04-10 16:02:37 +00:00
|
|
|
this.tree = [{
|
2014-06-11 22:04:58 +00:00
|
|
|
type: "element",
|
|
|
|
tag: "iframe",
|
|
|
|
attributes: {
|
2021-04-11 09:10:16 +00:00
|
|
|
src: {type: "string", value: src}
|
2014-06-11 22:04:58 +00:00
|
|
|
}
|
2013-04-10 16:02:37 +00:00
|
|
|
}];
|
2021-04-11 09:10:16 +00:00
|
|
|
if($tw.wiki.getTiddlerText("$:/config/HtmlParser/DisableSandbox","no") !== "yes") {
|
|
|
|
this.tree[0].attributes.sandbox = {type: "string", value: $tw.wiki.getTiddlerText("$:/config/HtmlParser/SandboxTokens","")};
|
|
|
|
}
|
2022-05-08 19:48:33 +00:00
|
|
|
this.source = text;
|
|
|
|
this.type = type;
|
2013-04-10 16:02:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
exports["text/html"] = HtmlParser;
|
|
|
|
|
|
|
|
})();
|
|
|
|
|