mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 21:46:51 +00:00
Extend new parser mechanism to determine parser based on content type
And add an image parser and a plain text parser
This commit is contained in:
31
core/modules/parsers/textparser.js
Normal file
31
core/modules/parsers/textparser.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/*\
|
||||
title: $:/core/modules/parsers/textparser.js
|
||||
type: application/javascript
|
||||
module-type: newparser
|
||||
|
||||
The plain text parser processes blocks of source text into a degenerate parse tree consisting of a single text node
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
var TextParser = function(type,text,options) {
|
||||
this.tree = [{
|
||||
type: "element",
|
||||
tag: "pre",
|
||||
children: [{
|
||||
type: "text",
|
||||
text: text
|
||||
}]
|
||||
}];
|
||||
};
|
||||
|
||||
exports["text/plain"] = TextParser;
|
||||
exports["text/html"] = TextParser;
|
||||
exports["application/javascript"] = TextParser;
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user