mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-03-13 23:18:09 +00:00
Added parse tree utility functions
This commit is contained in:
parent
c0e36f1129
commit
60dca0f38a
32
core/modules/utils/parsetree.js
Normal file
32
core/modules/utils/parsetree.js
Normal file
@ -0,0 +1,32 @@
|
||||
/*\
|
||||
title: $:/core/modules/utils/parsetree.js
|
||||
type: application/javascript
|
||||
module-type: utils
|
||||
|
||||
Parse tree utility functions.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.addAttributeToParseTreeNode = function(node,name,value) {
|
||||
if(node.type === "element") {
|
||||
node.attributes = node.attributes || {};
|
||||
node.attributes[name] = {type: "string", value: value};
|
||||
}
|
||||
};
|
||||
|
||||
exports.addClassToParseTreeNode = function(node,classString) {
|
||||
if(node.type === "element") {
|
||||
node.attributes = node.attributes || {};
|
||||
node.attributes["class"] = node.attributes["class"] || {type: "string", value: ""};
|
||||
if(node.attributes["class"].type === "string") {
|
||||
node.attributes["class"].value += " " + classString;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user