summaryrefslogtreecommitdiff
path: root/alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-01-10 14:54:04 +0100
committerMinteck <contact@minteck.org>2023-01-10 14:54:04 +0100
commit99c1d9af689e5325f3cf535c4007b3aeb8325229 (patch)
treee663b3c2ebdbd67c818ac0c5147f0ce1d2463cda /alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js
parent9871b03912fc28ad38b4037ebf26a78aa937baba (diff)
downloadpluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.gz
pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.bz2
pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.zip
Update - This is an automated commit
Diffstat (limited to 'alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js')
-rw-r--r--alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js62
1 files changed, 0 insertions, 62 deletions
diff --git a/alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js b/alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js
deleted file mode 100644
index e8ba37f..0000000
--- a/alarm/node_modules/string-strip-html/examples/leave-only-opening-td.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// Leave only opening `td` tags
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-const someHtml = `<table width="100" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="col1">
- cell1
- </td>
- <td class="col2">
- cell2
- </td>
- </tr>
- <tr>
- <td class="col3">
- cell3
- </td>
- <td class="col4">
- cell4
- </td>
- </tr>
-</table>`;
-
-// the first way
-// -----------------------------------------------------------------------------
-
-assert.equal(
- stripHtml(someHtml, {
- // notice there's no: onlyStripTags: ["td"]
- // we operate purely via callback
- cb: ({ tag, deleteFrom, deleteTo, insert, rangesArr, proposedReturn }) => {
- if (tag.name === "td" && !tag.slashPresent) {
- rangesArr.push(proposedReturn);
- }
- },
- }).ranges.reduce(
- (acc, [from, to]) => `${acc}${someHtml.slice(from, to).trim()}`,
- ""
- ),
- `<td class="col1"><td class="col2"><td class="col3"><td class="col4">`
-);
-
-// the second way:
-// -----------------------------------------------------------------------------
-
-let resultStr = "";
-// notice we don't even assign stripHtml() output to anything - we rely only
-// on the callback, it mutates the "resultStr" in the upper scope
-stripHtml(someHtml, {
- // notice there's no: onlyStripTags: ["td"]
- // we operate purely via callback
- cb: ({ tag, deleteFrom, deleteTo, insert, rangesArr, proposedReturn }) => {
- if (tag.name === "td" && !tag.slashPresent) {
- resultStr += someHtml.slice(deleteFrom, deleteTo).trim();
- }
- },
-});
-assert.equal(
- resultStr,
- `<td class="col1"><td class="col2"><td class="col3"><td class="col4">`
-);