Do not escape double quotes in tiddler DIVs to save space (#5383)

* double quotes are no longer escaped in html bodies

* changed tiddlyweb's html-div-tiddler; documentation

French version still needs a translation though
index-for-list-widget
Cameron Fischer 2021-04-02 04:32:32 -04:00 zatwierdzone przez GitHub
rodzic 3b35411aba
commit ef6307a64e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 19 dodań i 2 usunięć

Wyświetl plik

@ -515,6 +515,15 @@ exports.htmlEncode = function(s) {
} }
}; };
// Converts like htmlEncode, but forgets the double quote for brevity
exports.htmlTextEncode = function(s) {
if(s) {
return s.toString().replace(/&/mg,"&amp;").replace(/</mg,"&lt;").replace(/>/mg,"&gt;");
} else {
return "";
}
};
// Converts all HTML entities to their character equivalents // Converts all HTML entities to their character equivalents
exports.entityDecode = function(s) { exports.entityDecode = function(s) {
var converter = String.fromCodePoint || String.fromCharCode, var converter = String.fromCodePoint || String.fromCharCode,

Wyświetl plik

@ -65,6 +65,9 @@ ViewWidget.prototype.execute = function() {
case "htmlencoded": case "htmlencoded":
this.text = this.getValueAsHtmlEncoded(); this.text = this.getValueAsHtmlEncoded();
break; break;
case "htmltextencoded":
this.text = this.getValueAsHtmlTextEncoded();
break;
case "urlencoded": case "urlencoded":
this.text = this.getValueAsUrlEncoded(); this.text = this.getValueAsUrlEncoded();
break; break;
@ -160,6 +163,10 @@ ViewWidget.prototype.getValueAsHtmlEncoded = function() {
return $tw.utils.htmlEncode(this.getValueAsText()); return $tw.utils.htmlEncode(this.getValueAsText());
}; };
ViewWidget.prototype.getValueAsHtmlTextEncoded = function() {
return $tw.utils.htmlTextEncode(this.getValueAsText());
};
ViewWidget.prototype.getValueAsUrlEncoded = function() { ViewWidget.prototype.getValueAsUrlEncoded = function() {
return encodeURIComponent(this.getValueAsText()); return encodeURIComponent(this.getValueAsText());
}; };

Wyświetl plik

@ -5,5 +5,5 @@ title: $:/core/templates/html-div-tiddler
This template is used for saving tiddlers as an HTML DIV tag with attributes representing the tiddler fields. This template is used for saving tiddlers as an HTML DIV tag with attributes representing the tiddler fields.
-->`<div`<$fields template=' $name$="$encoded_value$"'></$fields>`> -->`<div`<$fields template=' $name$="$encoded_value$"'></$fields>`>
<pre>`<$view field="text" format="htmlencoded" />`</pre> <pre>`<$view field="text" format="htmltextencoded" />`</pre>
</div>` </div>`

Wyświetl plik

@ -29,6 +29,7 @@ The following formats can be specified in the `format` attribute:
|!Format |!Description | |!Format |!Description |
|''text'' |Plain text (default) | |''text'' |Plain text (default) |
|''htmlencoded'' |The field is displayed with HTML encoding | |''htmlencoded'' |The field is displayed with HTML encoding |
|''htmltextencoded'' |The field is displayed with HTML encoding, only double quotes (") are not escaped. This creates a more compact htmlencoding appropriate for html text content, but //not// for attributes. |
|''urlencoded'' |The field is displayed with URL encoding | |''urlencoded'' |The field is displayed with URL encoding |
|''doubleurlencoded'' |The field is displayed with double URL encoding | |''doubleurlencoded'' |The field is displayed with double URL encoding |
|''htmlwikified'' |The field is wikified according to the mode attribute and the resulting HTML returned as plain text (ie HTML elements will appear in plain text) | |''htmlwikified'' |The field is wikified according to the mode attribute and the resulting HTML returned as plain text (ie HTML elements will appear in plain text) |

Wyświetl plik

@ -5,5 +5,5 @@ title: $:/core/templates/html-div-tiddler
This template is used for saving tiddlers as an HTML DIV tag with attributes representing the tiddler fields. This version includes the tiddler changecount as the field `revision`. This template is used for saving tiddlers as an HTML DIV tag with attributes representing the tiddler fields. This version includes the tiddler changecount as the field `revision`.
-->`<div`<$fields exclude='text revision bag' template=' $name$="$encoded_value$"'></$fields>` revision="`<<changecount>>`" bag="default"> -->`<div`<$fields exclude='text revision bag' template=' $name$="$encoded_value$"'></$fields>` revision="`<<changecount>>`" bag="default">
<pre>`<$view field="text" format="htmlencoded" />`</pre> <pre>`<$view field="text" format="htmltextencoded" />`</pre>
</div>` </div>`