Text-slicer: Add support for discarding the content of an element

This commit is contained in:
Jermolene
2018-01-24 12:01:56 +00:00
parent 3e81921eea
commit 55d7f43f0c
2 changed files with 23 additions and 12 deletions

View File

@@ -340,8 +340,12 @@ Slicer.prototype.onCloseTag = function(name) {
Slicer.prototype.onText = function(text) {
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
text = $tw.utils.htmlEncode(text);
if(this.escapeWikiText) {
$tw.utils.each(["[[","{{","__","''","//",",,","^^","~~","`","--","\"\"","@@"],function(str) {
var replace = str.split("").map(function(c) {