1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-15 22:34:51 +00:00
TiddlyWiki5/plugins/tiddlywiki/text-slicer/modules/slicers/paragraph.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-09-15 12:37:12 +00:00
/*\
title: $:/plugins/tiddlywiki/text-slicer/modules/slicers/paragraph.js
type: application/javascript
module-type: slicer
Handle slicing paragraph nodes
2015-09-15 12:37:12 +00:00
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.processParagraphNode = function(domNode,tagName) {
var text = $tw.utils.htmlEncode(domNode.textContent);
if(domNode.nodeType === 1 && tagName === "p") {
2015-09-15 12:37:12 +00:00
if(!this.isBlank(text)) {
var parentTitle = this.parentStack[this.parentStack.length - 1].title,
tags = [],
title = this.makeUniqueTitle("paragraph",text);
if(domNode.className && domNode.className && domNode.className.trim() !== "") {
2015-09-15 12:37:12 +00:00
tags = tags.concat(domNode.className.split(" "));
}
this.addToList(parentTitle,this.addTiddler({
"toc-type": "paragraph",
title: title,
text: "",
2015-09-15 12:37:12 +00:00
tags: tags
}));
this.currentTiddler = title;
this.containerStack.push(title);
this.processNodeList(domNode.childNodes);
this.containerStack.pop();
2015-09-15 12:37:12 +00:00
return true;
}
}
return false;
};
})();