mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 09:30:28 +00:00
Merge pull request #2026 from Evolena/def-list
Text-slicer: Add support for definition lists
This commit is contained in:
commit
106f11343e
@ -104,6 +104,13 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i
|
|||||||
Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
Dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<dl>
|
||||||
|
<dt>Term being defined</dt>
|
||||||
|
<dd>Definition of that term</dd>
|
||||||
|
<dt>Another term</dt>
|
||||||
|
<dd>Another definition</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
<h3>Story</h3>
|
<h3>Story</h3>
|
||||||
|
|
||||||
<ul class="intro">
|
<ul class="intro">
|
||||||
|
@ -144,6 +144,32 @@ The tiddlers representing items within the list have the following fields:
|
|||||||
* ''text'': the text of the list item
|
* ''text'': the text of the list item
|
||||||
* ''tags'': any CSS classes found in the HTML are converted into tags
|
* ''tags'': any CSS classes found in the HTML are converted into tags
|
||||||
|
|
||||||
|
!!! Definition lists
|
||||||
|
|
||||||
|
Definition lists are represented by several tiddlers: one for the definition list itself, and one for each term and definition in the list.
|
||||||
|
|
||||||
|
The tiddler representing the definition list itself has the following fields:
|
||||||
|
|
||||||
|
* ''toc-type'': the text "def-list"
|
||||||
|
* ''toc-list-filter'': the default filter used to generate the titles of the definition list items
|
||||||
|
* ''title'': an automatically generated unique title
|
||||||
|
* ''list'': ordered list of titles of tiddlers representing the items (terms and/or definition) in the definition list
|
||||||
|
* ''tags'': any CSS classes found in the HTML are converted into tags
|
||||||
|
|
||||||
|
The tiddlers representing terms within the definition list have the following fields:
|
||||||
|
|
||||||
|
* ''toc-type'': the text "term"
|
||||||
|
* ''title'': an automatically generated unique title
|
||||||
|
* ''text'': the text of the definition list term
|
||||||
|
* ''tags'': any CSS classes found in the HTML are converted into tags
|
||||||
|
|
||||||
|
The tiddlers representing definitions within the definition list have the following fields:
|
||||||
|
|
||||||
|
* ''toc-type'': the text "definition"
|
||||||
|
* ''title'': an automatically generated unique title
|
||||||
|
* ''text'' : the text of the definition list definition
|
||||||
|
* ''tags'': any CSS classes found in the HTML are converted into tags
|
||||||
|
|
||||||
!!! Images
|
!!! Images
|
||||||
|
|
||||||
Tiddlers representing images have the following fields:
|
Tiddlers representing images have the following fields:
|
||||||
|
40
plugins/tiddlywiki/text-slicer/modules/slicers/def-list.js
Normal file
40
plugins/tiddlywiki/text-slicer/modules/slicers/def-list.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/text-slicer/modules/slicers/def-list.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: slicer
|
||||||
|
|
||||||
|
Handle slicing definition list nodes
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.processDefListNode = function(domNode,tagName) {
|
||||||
|
if(domNode.nodeType === 1 && tagName === "dl") {
|
||||||
|
var title = this.makeUniqueTitle("def-list-" + tagName),
|
||||||
|
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||||
|
tags = [];
|
||||||
|
if(domNode.className.trim() !== "") {
|
||||||
|
tags = tags.concat(domNode.className.split(" "));
|
||||||
|
}
|
||||||
|
this.addToList(parentTitle,title);
|
||||||
|
this.parentStack.push({type: tagName, title: this.addTiddler({
|
||||||
|
"toc-type": "def-list",
|
||||||
|
"toc-list-filter": "[list<currentTiddler>!has[draft.of]]",
|
||||||
|
text: "",
|
||||||
|
title: title,
|
||||||
|
list: [],
|
||||||
|
tags: tags
|
||||||
|
})});
|
||||||
|
this.currentTiddler = title;
|
||||||
|
this.processNodeList(domNode.childNodes);
|
||||||
|
this.parentStack.pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
44
plugins/tiddlywiki/text-slicer/modules/slicers/definition.js
Normal file
44
plugins/tiddlywiki/text-slicer/modules/slicers/definition.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/text-slicer/modules/slicers/definition.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: slicer
|
||||||
|
|
||||||
|
Handle slicing definition nodes in definition lists
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
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),
|
||||||
|
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||||
|
tags = [];
|
||||||
|
if(domNode.className.trim() !== "") {
|
||||||
|
tags = tags.concat(domNode.className.split(" "));
|
||||||
|
}
|
||||||
|
this.addToList(parentTitle,title);
|
||||||
|
this.addTiddler({
|
||||||
|
"toc-type": "definition",
|
||||||
|
title: title,
|
||||||
|
text: "",
|
||||||
|
list: [],
|
||||||
|
tags: tags
|
||||||
|
});
|
||||||
|
this.currentTiddler = title;
|
||||||
|
this.containerStack.push(title);
|
||||||
|
// this.containerStack.push("Just testing" + new Date());
|
||||||
|
this.processNodeList(domNode.childNodes);
|
||||||
|
this.containerStack.pop();
|
||||||
|
return true;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
44
plugins/tiddlywiki/text-slicer/modules/slicers/term.js
Normal file
44
plugins/tiddlywiki/text-slicer/modules/slicers/term.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*\
|
||||||
|
title: $:/plugins/tiddlywiki/text-slicer/modules/slicers/term.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: slicer
|
||||||
|
|
||||||
|
Handle slicing term nodes in definition lists
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
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),
|
||||||
|
parentTitle = this.parentStack[this.parentStack.length - 1].title,
|
||||||
|
tags = [];
|
||||||
|
if(domNode.className.trim() !== "") {
|
||||||
|
tags = tags.concat(domNode.className.split(" "));
|
||||||
|
}
|
||||||
|
this.addToList(parentTitle,title);
|
||||||
|
this.addTiddler({
|
||||||
|
"toc-type": "term",
|
||||||
|
title: title,
|
||||||
|
text: "",
|
||||||
|
list: [],
|
||||||
|
tags: tags
|
||||||
|
});
|
||||||
|
this.currentTiddler = title;
|
||||||
|
this.containerStack.push(title);
|
||||||
|
// this.containerStack.push("Just testing" + new Date());
|
||||||
|
this.processNodeList(domNode.childNodes);
|
||||||
|
this.containerStack.pop();
|
||||||
|
return true;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/interactive/def-list
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<dl>
|
||||||
|
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
|
||||||
|
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/interactive/tiddler"/>
|
||||||
|
</$list>
|
||||||
|
</dl>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/interactive/definition
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<$link tag="dd" class="tc-document-tiddler-link">
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
</$link>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/interactive/term
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<$link tag="dt" class="tc-document-tiddler-link">
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
</$link>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
@ -27,3 +27,15 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/interactive/tiddler
|
|||||||
<$reveal type="match" state="!!toc-type" text="image">
|
<$reveal type="match" state="!!toc-type" text="image">
|
||||||
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/interactive/image" mode="block"/>
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/interactive/image" mode="block"/>
|
||||||
</$reveal>
|
</$reveal>
|
||||||
|
|
||||||
|
<$reveal type="match" state="!!toc-type" text="def-list">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/interactive/def-list" mode="block"/>
|
||||||
|
</$reveal>
|
||||||
|
|
||||||
|
<$reveal type="match" state="!!toc-type" text="term">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/interactive/term" mode="block"/>
|
||||||
|
</$reveal>
|
||||||
|
|
||||||
|
<$reveal type="match" state="!!toc-type" text="definition">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/interactive/definition" mode="block"/>
|
||||||
|
</$reveal>
|
||||||
|
11
plugins/tiddlywiki/text-slicer/templates/plain/def-list.tid
Normal file
11
plugins/tiddlywiki/text-slicer/templates/plain/def-list.tid
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/def-list
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<dl>
|
||||||
|
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
|
||||||
|
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler"/>
|
||||||
|
</$list>
|
||||||
|
</dl>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/definition
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<dd>
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
</dd>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
11
plugins/tiddlywiki/text-slicer/templates/plain/term.tid
Normal file
11
plugins/tiddlywiki/text-slicer/templates/plain/term.tid
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/plain/term
|
||||||
|
|
||||||
|
\define body()
|
||||||
|
<dt>
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
</dt>
|
||||||
|
\end
|
||||||
|
|
||||||
|
<<body>>
|
@ -26,4 +26,16 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/plain/tiddler
|
|||||||
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/image" mode="block"/>
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/image" mode="block"/>
|
||||||
</$list>
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[def-list]]" variable="item">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/def-list" mode="block"/>
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[term]]" variable="item">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/term" mode="block"/>
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[definition]]" variable="item">
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/plain/definition" mode="block"/>
|
||||||
|
</$list>
|
||||||
|
|
||||||
</$vars>
|
</$vars>
|
||||||
|
11
plugins/tiddlywiki/text-slicer/templates/static/def-list.tid
Normal file
11
plugins/tiddlywiki/text-slicer/templates/static/def-list.tid
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/static/def-list
|
||||||
|
|
||||||
|
<$list filter="""[all[current]] $(tv-exclude-filter)$ +[limit[1]]""" variable="item">
|
||||||
|
|
||||||
|
`<dl class="`{{||$:/plugins/tiddlywiki/text-slicer/templates/static/helpers/classes}}`">`
|
||||||
|
|
||||||
|
<$list filter={{!!toc-list-filter}} template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
|
||||||
|
|
||||||
|
`</dl>`
|
||||||
|
|
||||||
|
</$list>
|
@ -0,0 +1,9 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/static/definition
|
||||||
|
|
||||||
|
`<dd class="`{{||$:/plugins/tiddlywiki/text-slicer/templates/static/helpers/classes}}`">`
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
`</dd>`
|
||||||
|
|
||||||
|
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
|
9
plugins/tiddlywiki/text-slicer/templates/static/term.tid
Normal file
9
plugins/tiddlywiki/text-slicer/templates/static/term.tid
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
title: $:/plugins/tiddlywiki/text-slicer/templates/static/term
|
||||||
|
|
||||||
|
`<dt class="`{{||$:/plugins/tiddlywiki/text-slicer/templates/static/helpers/classes}}`">`
|
||||||
|
|
||||||
|
<$transclude/>
|
||||||
|
|
||||||
|
`</dt>`
|
||||||
|
|
||||||
|
<$list filter="[list<currentTiddler>!has[draft.of]]" template="$:/plugins/tiddlywiki/text-slicer/templates/static/tiddler"/>
|
@ -38,4 +38,22 @@ title: $:/plugins/tiddlywiki/text-slicer/templates/static/tiddler
|
|||||||
|
|
||||||
</$list>
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[def-list]]" variable="item">
|
||||||
|
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/def-list" mode="block"/>
|
||||||
|
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[term]]" variable="item">
|
||||||
|
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/term" mode="block"/>
|
||||||
|
|
||||||
|
</$list>
|
||||||
|
|
||||||
|
<$list filter="[<toc-type>prefix[definition]]" variable="item">
|
||||||
|
|
||||||
|
<$transclude tiddler="$:/plugins/tiddlywiki/text-slicer/templates/static/definition" mode="block"/>
|
||||||
|
|
||||||
|
</$list>
|
||||||
|
|
||||||
</$vars>
|
</$vars>
|
||||||
|
Loading…
Reference in New Issue
Block a user