|
|
@@ -145,14 +145,9 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Empty the display.
|
|
|
- *
|
|
|
- * An extra update is needed for subsequent changes to `output` (e.g. `add()`,
|
|
|
- * `restore()`) to display properly.
|
|
|
- */
|
|
|
clear() {
|
|
|
this.output.length = 0
|
|
|
+ // This is needed for subsequent changes to `output` to display properly.
|
|
|
this.update()
|
|
|
}
|
|
|
|
|
|
@@ -168,17 +163,9 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Make sure whitespace displays correctly.
|
|
|
- *
|
|
|
- * Keep the following:
|
|
|
- *
|
|
|
- * - Newlines.
|
|
|
- * - Whitespace for display. This means all spaces that are not within tags.
|
|
|
- */
|
|
|
preserveWhiteSpace(text) {
|
|
|
text = text.replace(/(?:\r\n|\r|\n)/g, '<br />')
|
|
|
- // Search for tags or whitespace. Replace whitespace, leave the tags.
|
|
|
+ // Search for tags or whitespace. Escape whitespace, leave tags.
|
|
|
text = text.replace(/<[^<]+>|( )/g, function(match, group1) {
|
|
|
if (group1 == " ") { return ' ' }
|
|
|
return match
|
|
|
@@ -236,7 +223,7 @@
|
|
|
<raw>
|
|
|
<span></span>
|
|
|
|
|
|
- // Initialise contents from tag options, but expose `write()` for updating.
|
|
|
+ // Initialise HTML from tag options and expose `write()` for updating.
|
|
|
write(text) {
|
|
|
this.root.innerHTML = text
|
|
|
}
|