mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 10:06:42 +00:00
Refactoring the slicer engine for easier reuse
This commit is contained in:
@@ -16,7 +16,7 @@ exports.processDefinitionNode = function(domNode,tagName) {
|
||||
var text = $tw.utils.htmlEncode(domNode.textContent);
|
||||
if(domNode.nodeType === 1 && tagName === "dd") {
|
||||
// if(!this.isBlank(text)) {
|
||||
var title = this.makeUniqueTitle("definition",text),
|
||||
var title = this.makeUniqueTitle("definition " + text),
|
||||
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
tags = [];
|
||||
if(domNode.className && domNode.className.trim() !== "") {
|
||||
|
||||
@@ -15,7 +15,7 @@ Handle slicing heading nodes
|
||||
exports.processHeadingNode = function(domNode,tagName) {
|
||||
if(domNode.nodeType === 1 && (tagName === "h1" || tagName === "h2" || tagName === "h3" || tagName === "h4")) {
|
||||
var text = $tw.utils.htmlEncode(domNode.textContent);
|
||||
var title = this.makeUniqueTitle("heading",text),
|
||||
var title = this.makeUniqueTitle("heading " + text),
|
||||
parentTitle = this.popParentStackUntil(tagName),
|
||||
tags = [];
|
||||
if(domNode.className && domNode.className.trim() !== "") {
|
||||
|
||||
@@ -21,8 +21,8 @@ exports.processImageNode = function(domNode,tagName) {
|
||||
text = parts[1],
|
||||
contentTypeInfo = $tw.config.contentTypeInfo[type],
|
||||
containerTitle = this.getTopContainer(),
|
||||
containerTiddler = this.tiddlers[containerTitle],
|
||||
title = this.makeUniqueTitle("image",containerTitle) + contentTypeInfo.extension,
|
||||
containerTiddler = this.getTiddler(containerTitle),
|
||||
title = this.makeUniqueTitle("image " + containerTitle) + contentTypeInfo.extension,
|
||||
tiddler = {
|
||||
title: title,
|
||||
type: parts[0],
|
||||
@@ -47,7 +47,7 @@ exports.processImageNode = function(domNode,tagName) {
|
||||
case "item":
|
||||
// Create a new older sibling item to contain the image
|
||||
var parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
itemTitle = this.makeUniqueTitle("image-item-wrapper",containerTitle),
|
||||
itemTitle = this.makeUniqueTitle("image-item-wrapper " + containerTitle),
|
||||
itemTiddler = {
|
||||
title: itemTitle,
|
||||
"toc-type": "item",
|
||||
|
||||
@@ -16,7 +16,7 @@ exports.processListItemNode = function(domNode,tagName) {
|
||||
var text = $tw.utils.htmlEncode(domNode.textContent);
|
||||
if(domNode.nodeType === 1 && tagName === "li") {
|
||||
// if(!this.isBlank(text)) {
|
||||
var title = this.makeUniqueTitle("list-item",text),
|
||||
var title = this.makeUniqueTitle("list-item " + text),
|
||||
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
tags = [];
|
||||
if(domNode.className && domNode.className.trim() !== "") {
|
||||
|
||||
@@ -14,7 +14,7 @@ Handle slicing list nodes
|
||||
|
||||
exports.processListNode = function(domNode,tagName) {
|
||||
if(domNode.nodeType === 1 && (tagName === "ul" || tagName === "ol")) {
|
||||
var title = this.makeUniqueTitle("list-" + tagName),
|
||||
var title = this.makeUniqueTitle("list " + tagName),
|
||||
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
tags = [];
|
||||
if(domNode.className && domNode.className.trim() !== "") {
|
||||
|
||||
@@ -18,7 +18,7 @@ exports.processParagraphNode = function(domNode,tagName) {
|
||||
if(!this.isBlank(text)) {
|
||||
var parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
tags = [],
|
||||
title = this.makeUniqueTitle("paragraph",text);
|
||||
title = this.makeUniqueTitle("paragraph " + text);
|
||||
if(domNode.className && domNode.className && domNode.className.trim() !== "") {
|
||||
tags = tags.concat(domNode.className.split(" "));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ exports.processTermNode = function(domNode,tagName) {
|
||||
var text = $tw.utils.htmlEncode(domNode.textContent);
|
||||
if(domNode.nodeType === 1 && tagName === "dt") {
|
||||
// if(!this.isBlank(text)) {
|
||||
var title = this.makeUniqueTitle("term",text),
|
||||
var title = this.makeUniqueTitle("term " + text),
|
||||
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||
tags = [];
|
||||
if(domNode.className && domNode.className.trim() !== "") {
|
||||
|
||||
Reference in New Issue
Block a user