mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Text-slicer: Add support for discarding the content of an element
This commit is contained in:
parent
3e81921eea
commit
55d7f43f0c
@ -7,7 +7,22 @@ tags: $:/tags/text-slicer/slicer-rules
|
|||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"selector": "address,blockquote,center,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,iframe,isindex,noframes,noscript,ol,p,pre,table,ul",
|
"selector": "li > p",
|
||||||
|
"actions": {
|
||||||
|
"dontRenderTag": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "p",
|
||||||
|
"actions": {
|
||||||
|
"startNewChunk": {
|
||||||
|
"toc-type": "paragraph"
|
||||||
|
},
|
||||||
|
"dontRenderTag": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "address,blockquote,center,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,hr,iframe,isindex,noframes,noscript,ol,pre,table,ul",
|
||||||
"actions": {
|
"actions": {
|
||||||
"startNewChunk": {
|
"startNewChunk": {
|
||||||
"toc-type": "paragraph"
|
"toc-type": "paragraph"
|
||||||
@ -25,19 +40,11 @@ tags: $:/tags/text-slicer/slicer-rules
|
|||||||
"isImage": true
|
"isImage": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"selector": "head > title",
|
|
||||||
"actions": {
|
|
||||||
"dontRenderTag": true,
|
|
||||||
"startNewChunk": {
|
|
||||||
"toc-type": "title"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"selector": "*",
|
"selector": "*",
|
||||||
"actions": {
|
"actions": {
|
||||||
"dontRenderTag": true
|
"dontRenderTag": true,
|
||||||
|
"discard": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
@ -340,8 +340,12 @@ Slicer.prototype.onCloseTag = function(name) {
|
|||||||
|
|
||||||
Slicer.prototype.onText = function(text) {
|
Slicer.prototype.onText = function(text) {
|
||||||
var self = this;
|
var self = this;
|
||||||
text = $tw.utils.htmlEncode(text);
|
// Discard the text if we're inside an element with actions.discard set true
|
||||||
|
if(this.elementStack.some(function(e) {return e.actions.discard;})) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Optionally escape common character sequences that might be parsed as wikitext
|
// Optionally escape common character sequences that might be parsed as wikitext
|
||||||
|
text = $tw.utils.htmlEncode(text);
|
||||||
if(this.escapeWikiText) {
|
if(this.escapeWikiText) {
|
||||||
$tw.utils.each(["[[","{{","__","''","//",",,","^^","~~","`","--","\"\"","@@"],function(str) {
|
$tw.utils.each(["[[","{{","__","''","//",",,","^^","~~","`","--","\"\"","@@"],function(str) {
|
||||||
var replace = str.split("").map(function(c) {
|
var replace = str.split("").map(function(c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user