summaryrefslogtreecommitdiff
path: root/school/node_modules/string-strip-html/examples
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/string-strip-html/examples
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/string-strip-html/examples')
-rw-r--r--school/node_modules/string-strip-html/examples/_quickTake.js28
-rw-r--r--school/node_modules/string-strip-html/examples/api.json1
-rw-r--r--school/node_modules/string-strip-html/examples/cb-which-does-nothing.js33
-rw-r--r--school/node_modules/string-strip-html/examples/extract-html-head-contents.js42
-rw-r--r--school/node_modules/string-strip-html/examples/inline-tags.js23
-rw-r--r--school/node_modules/string-strip-html/examples/leave-only-html.js24
-rw-r--r--school/node_modules/string-strip-html/examples/leave-only-opening-td.js62
-rw-r--r--school/node_modules/string-strip-html/examples/leave-only-td.js33
-rw-r--r--school/node_modules/string-strip-html/examples/minimal-ranges.js33
-rw-r--r--school/node_modules/string-strip-html/examples/remove-html.js18
-rw-r--r--school/node_modules/string-strip-html/examples/strip-from-json.js41
-rw-r--r--school/node_modules/string-strip-html/examples/title-case-with-tag-skipping.js54
-rw-r--r--school/node_modules/string-strip-html/examples/widow-word-removal-from-html.js25
13 files changed, 0 insertions, 417 deletions
diff --git a/school/node_modules/string-strip-html/examples/_quickTake.js b/school/node_modules/string-strip-html/examples/_quickTake.js
deleted file mode 100644
index 741f1ea..0000000
--- a/school/node_modules/string-strip-html/examples/_quickTake.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// Quick Take
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-assert.equal(
- stripHtml(`Some text <b>and</b> text.`).result,
- `Some text and text.`
-);
-
-// prevents accidental string concatenation
-assert.equal(stripHtml(`aaa<div>bbb</div>ccc`).result, `aaa bbb ccc`);
-
-// tag pairs with content, upon request
-assert.equal(
- stripHtml(`a <pre><code>void a;</code></pre> b`, {
- stripTogetherWithTheirContents: [
- "script", // default
- "style", // default
- "xml", // default
- "pre", // <-- custom-added
- ],
- }).result,
- `a b`
-);
-
-// detects raw, legit brackets:
-assert.equal(stripHtml(`a < b and c > d`).result, `a < b and c > d`);
diff --git a/school/node_modules/string-strip-html/examples/api.json b/school/node_modules/string-strip-html/examples/api.json
deleted file mode 100644
index 28adb26..0000000
--- a/school/node_modules/string-strip-html/examples/api.json
+++ /dev/null
@@ -1 +0,0 @@
-{"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nassert.equal(\n stripHtml(`Some text <b>and</b> text.`).result,\n `Some text and text.`\n);\n\n// prevents accidental string concatenation\nassert.equal(stripHtml(`aaa<div>bbb</div>ccc`).result, `aaa bbb ccc`);\n\n// tag pairs with content, upon request\nassert.equal(\n stripHtml(`a <pre><code>void a;</code></pre> b`, &#x7B;\n stripTogetherWithTheirContents: [\n \"script\", // default\n \"style\", // default\n \"xml\", // default\n \"pre\", // <-- custom-added\n ],\n &#x7D;).result,\n `a b`\n);\n\n// detects raw, legit brackets:\nassert.equal(stripHtml(`a < b and c > d`).result, `a < b and c > d`);"},"cb-which-does-nothing.js":{"title":"A Bypass Callback and a Do-Nothing Callback","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\n// this callback just pushes proposed result to \"rangesArr\",\n// that's what gets used in the result calculation:\nconst cb1 = (&#x7B;\n tag,\n deleteFrom,\n deleteTo,\n insert,\n rangesArr,\n proposedReturn,\n&#x7D;) => &#x7B;\n rangesArr.push(deleteFrom, deleteTo, insert);\n&#x7D;;\nconst result1 = stripHtml(\"abc<hr>def\", &#x7B; cb: cb1 &#x7D;).result;\nassert.equal(result1, `abc def`);\n\n// to prove it works, don't do anything:\nconst cb2 = (&#x7B;\n tag,\n deleteFrom,\n deleteTo,\n insert,\n rangesArr,\n proposedReturn,\n&#x7D;) => &#x7B;\n // nothing here πŸ™ˆ\n&#x7D;;\nconst result2 = stripHtml(\"abc<hr>def\", &#x7B; cb: cb2 &#x7D;).result;\nassert.equal(result2, \"abc<hr>def\");"},"extract-html-head-contents.js":{"title":"Extract HTML `<head>` contents","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\">\n <head>\n <meta charset=\"utf-8\">\n <title>the title</title>\n </head>\n <body>\n the content\n </body>\n</html>`;\n\n// The task asks not to include <head...> and </head>.\n// First, extract head tag-to-head tag, including contents\nconst headWithHeadTags = stripHtml(someHtml, &#x7B;\n onlyStripTags: [\"head\"],\n stripTogetherWithTheirContents: [\"head\"],\n&#x7D;)\n .filteredTagLocations.reduce(\n (acc, [from, to]) => `$&#x7B;acc&#x7D;$&#x7B;someHtml.slice(from, to)&#x7D;`,\n \"\"\n )\n .trim();\n\nassert.equal(\n headWithHeadTags,\n `<head>\n <meta charset=\"utf-8\">\n <title>the title</title>\n </head>`\n);\n\nconst headContents = headWithHeadTags.replace(/<\\/?head>/g, \"\").trim();\nassert.equal(\n headContents,\n `<meta charset=\"utf-8\">\n <title>the title</title>`\n);"},"inline-tags.js":{"title":"Just deletes inline tags","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `This has an <b>un</b>bold word.`;\n\n// default behaviour:\nassert.equal(stripHtml(someHtml).result, `This has an un bold word.`);\n\n// let's tackle inline tags:\nassert.equal(\n stripHtml(someHtml, &#x7B;\n cb: (&#x7B; tag, deleteFrom, deleteTo, insert, rangesArr &#x7D;) => &#x7B;\n if ([\"b\", \"strong\"].includes(tag.name)) &#x7B;\n rangesArr.push(tag.lastOpeningBracketAt, tag.lastClosingBracketAt + 1);\n &#x7D; else &#x7B;\n rangesArr.push(deleteFrom, deleteTo, insert);\n &#x7D;\n &#x7D;,\n &#x7D;).result,\n `This has an unbold word.`\n);"},"leave-only-html.js":{"title":"Leave only HTML","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\">\n <head>\n <meta charset=\"utf-8\">\n <title></title>\n </head>\n <body>\n <h1>Title</h1>\n Some text.\n </body>\n</html>`;\n\nassert.equal(\n stripHtml(someHtml).allTagLocations.reduce(\n (acc, [from, to]) => `$&#x7B;acc&#x7D;$&#x7B;someHtml.slice(from, to)&#x7D;`,\n \"\"\n ),\n `<!DOCTYPE html><html lang=\"en\" dir=\"ltr\"><head><meta charset=\"utf-8\"><title></title></head><body><h1></h1></body></html>`\n);"},"leave-only-opening-td.js":{"title":"Leave only opening `td` tags","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n <tr>\n <td class=\"col1\">\n cell1\n </td>\n <td class=\"col2\">\n cell2\n </td>\n </tr>\n <tr>\n <td class=\"col3\">\n cell3\n </td>\n <td class=\"col4\">\n cell4\n </td>\n </tr>\n</table>`;\n\n// the first way\n// -----------------------------------------------------------------------------\n\nassert.equal(\n stripHtml(someHtml, &#x7B;\n // notice there's no: onlyStripTags: [\"td\"]\n // we operate purely via callback\n cb: (&#x7B; tag, deleteFrom, deleteTo, insert, rangesArr, proposedReturn &#x7D;) => &#x7B;\n if (tag.name === \"td\" && !tag.slashPresent) &#x7B;\n rangesArr.push(proposedReturn);\n &#x7D;\n &#x7D;,\n &#x7D;).ranges.reduce(\n (acc, [from, to]) => `$&#x7B;acc&#x7D;$&#x7B;someHtml.slice(from, to).trim()&#x7D;`,\n \"\"\n ),\n `<td class=\"col1\"><td class=\"col2\"><td class=\"col3\"><td class=\"col4\">`\n);\n\n// the second way:\n// -----------------------------------------------------------------------------\n\nlet resultStr = \"\";\n// notice we don't even assign stripHtml() output to anything - we rely only\n// on the callback, it mutates the \"resultStr\" in the upper scope\nstripHtml(someHtml, &#x7B;\n // notice there's no: onlyStripTags: [\"td\"]\n // we operate purely via callback\n cb: (&#x7B; tag, deleteFrom, deleteTo, insert, rangesArr, proposedReturn &#x7D;) => &#x7B;\n if (tag.name === \"td\" && !tag.slashPresent) &#x7B;\n resultStr += someHtml.slice(deleteFrom, deleteTo).trim();\n &#x7D;\n &#x7D;,\n&#x7D;);\nassert.equal(\n resultStr,\n `<td class=\"col1\"><td class=\"col2\"><td class=\"col3\"><td class=\"col4\">`\n);"},"leave-only-td.js":{"title":"Leave only `td` tags","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `<table width=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n <tr>\n <td class=\"col1\">\n cell1\n </td>\n <td class=\"col2\">\n cell2\n </td>\n </tr>\n <tr>\n <td class=\"col3\">\n cell3\n </td>\n <td class=\"col4\">\n cell4\n </td>\n </tr>\n</table>`;\n\nassert.equal(\n stripHtml(someHtml, &#x7B;\n onlyStripTags: [\"td\"],\n &#x7D;).filteredTagLocations.reduce(\n (acc, [from, to]) => `$&#x7B;acc&#x7D;$&#x7B;someHtml.slice(from, to)&#x7D;`,\n \"\"\n ),\n `<td class=\"col1\"></td><td class=\"col2\"></td><td class=\"col3\"></td><td class=\"col4\"></td>`\n);"},"minimal-ranges.js":{"title":"Minimal example using Ranges","content":"// We strip tags and fix apostrophes\n// that's part of what https://codsen.com/os/detergent/ does\n\nimport &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; rApply &#x7D; from \"ranges-apply\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\nimport &#x7B; convertAll &#x7D; from \"string-apostrophes\";\n\nfunction stripAndFixApos(str) &#x7B;\n if (!str || typeof str !== \"string\") &#x7B;\n return \"\";\n &#x7D;\n // Keep in mind, Ranges are array of 2-3 element arrays.\n // But absent Ranges are marked as null, not empty array.\n // It's so that we could test in \"if-else\" easily - null\n // is falsy but empty array is truthy.\n // That's why below we take precautions with \"|| []\".\n return rApply(\n str,\n (stripHtml(str).ranges || []).concat(convertAll(str).ranges || [])\n );\n&#x7D;\n\n// strips tags and fixes apostrophes:\nassert.equal(\n stripAndFixApos(`Let's Go <strong>Larval</strong>`),\n `Let’s Go Larval`\n);\n\n// no tags, no apostrophes:\nassert.equal(stripAndFixApos(`zzz`), `zzz`);"},"remove-html.js":{"title":"Remove all HTML from a string","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nconst someHtml = `<!DOCTYPE html>\n<html lang=\"en\" dir=\"ltr\">\n <head>\n <meta charset=\"utf-8\">\n <title></title>\n </head>\n <body>\n <h1>Title</h1>\n Some text.\n </body>\n</html>`;\n\nassert.equal(stripHtml(someHtml).result, `Title\\nSome text.`);"},"strip-from-json.js":{"title":"Strip HTML from a raw JSON string","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\nimport &#x7B; traverse &#x7D; from \"ast-monkey-traverse\";\n\nconst stripFromJsonStr = (str) => &#x7B;\n return traverse(JSON.parse(str), (key, val) => &#x7B;\n // if currently an object is traversed, you get both \"key\" and \"val\"\n // if it's array, only \"key\" is present, \"val\" is undefined\n const current = val !== undefined ? val : key;\n if (\n // ensure it's a plain object, not array (monkey will report only \"key\" in\n // arrays and \"val\" will be undefined)\n // also ensure object's value a string, not boolean or number, because we\n // don't strip HTML from booleans or numbers or anything else than strings\n typeof val === \"string\"\n ) &#x7B;\n // monkey's callback is like Array.map - whatever you return gets written:\n return stripHtml(val).result;\n &#x7D;\n // default return, do nothing:\n return current;\n &#x7D;);\n&#x7D;;\n\n// nothing to strip, \"<\" is false alarm:\nassert.equal(\n JSON.stringify(stripFromJsonStr(`&#x7B;\"Operator\":\"<\",\"IsValid\":true&#x7D;`), null, 0),\n `&#x7B;\"Operator\":\"<\",\"IsValid\":true&#x7D;`\n);\n\n// some HTML within one of key values, monkey will skip the boolean:\nassert.equal(\n JSON.stringify(\n stripFromJsonStr(`&#x7B;\"Operator\":\"a <div>b</div> c\",\"IsValid\":true&#x7D;`),\n null,\n 0\n ),\n `&#x7B;\"Operator\":\"a b c\",\"IsValid\":true&#x7D;`\n);"},"title-case-with-tag-skipping.js":{"title":"Set the title case using `title` package","content":"// This program will not touch any single tags (<br class=\"z\"/> for example)\n// or in case of paired tags, paired tags and content between\n\nimport &#x7B; strict as assert &#x7D; from \"assert\";\nimport title from \"title\";\nimport &#x7B; rInvert &#x7D; from \"ranges-invert\";\nimport &#x7B; rApply &#x7D; from \"ranges-apply\";\nimport &#x7B; rRegex &#x7D; from \"ranges-regex\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\n\nfunction tagAwareTitle(str) &#x7B;\n const whitelist = [\"eslint\", \"readme\", \"npm\"];\n const &#x7B; filteredTagLocations &#x7D; = stripHtml(str, &#x7B;\n stripTogetherWithTheirContents: [\"*\"],\n &#x7D;);\n const inverted = rInvert(\n filteredTagLocations.concat(\n whitelist.reduce((acc, curr) => &#x7B;\n const rangesFindings = rRegex(new RegExp(curr, \"gi\"), str);\n if (rangesFindings) &#x7B;\n return acc.concat(rangesFindings);\n &#x7D;\n return acc;\n &#x7D;, [])\n ),\n str.length\n );\n\n if (Array.isArray(inverted) && inverted.length) &#x7B;\n // take inverted ranges, for example, [[3, 4], [10, 15]]\n // and add third element, replacement, which is same character\n // indexes only processed through \"title\":\n return rApply(\n str,\n inverted.map(([from, to]) => [from, to, title(str.slice(from, to))])\n );\n &#x7D;\n // otherwise, just apply title() on the whole string:\n return title(str);\n&#x7D;\n\n// middle:\nassert.equal(\n tagAwareTitle(`This is a title with some <code>code</code> in it`),\n `This Is a Title with Some <code>code</code> In It`\n);\n\n// leading:\nassert.equal(\n tagAwareTitle(`<span class=\"xyz\">abc<span> defgh ESLint`),\n `<span class=\"xyz\">abc<span> Defgh ESLint`\n);"},"widow-word-removal-from-html.js":{"title":"Widow word removal from text within HTML","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; stripHtml &#x7D; from \"string-strip-html\";\nimport &#x7B; removeWidows &#x7D; from \"string-remove-widows\";\n\nconst someHtml = `The quick brown fox jumps of the lazy dog.<div class=\"a\">`;\n\n// default widow word removal libs are not aware of HTML:\n// -----------------------------------------------------------------------------\n\nassert.equal(\n removeWidows(someHtml).res,\n `The quick brown fox jumps of the lazy dog.<div&nbsp;class=\"a\">` // 😱\n);\n\n// luckily, removeWidows() consumes optional HTML tag locations\nassert.equal(\n removeWidows(someHtml, &#x7B;\n tagRanges: stripHtml(someHtml)\n // remove the third argument, what to insert (\"&nbsp;\" string in these cases)\n .ranges.map(([from, to]) => [from, to]),\n &#x7D;).res,\n `The quick brown fox jumps of the lazy&nbsp;dog.<div class=\"a\">` // βœ…\n);"}} \ No newline at end of file
diff --git a/school/node_modules/string-strip-html/examples/cb-which-does-nothing.js b/school/node_modules/string-strip-html/examples/cb-which-does-nothing.js
deleted file mode 100644
index 2145c46..0000000
--- a/school/node_modules/string-strip-html/examples/cb-which-does-nothing.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// A Bypass Callback and a Do-Nothing Callback
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-// this callback just pushes proposed result to "rangesArr",
-// that's what gets used in the result calculation:
-const cb1 = ({
- tag,
- deleteFrom,
- deleteTo,
- insert,
- rangesArr,
- proposedReturn,
-}) => {
- rangesArr.push(deleteFrom, deleteTo, insert);
-};
-const result1 = stripHtml("abc<hr>def", { cb: cb1 }).result;
-assert.equal(result1, `abc def`);
-
-// to prove it works, don't do anything:
-const cb2 = ({
- tag,
- deleteFrom,
- deleteTo,
- insert,
- rangesArr,
- proposedReturn,
-}) => {
- // nothing here πŸ™ˆ
-};
-const result2 = stripHtml("abc<hr>def", { cb: cb2 }).result;
-assert.equal(result2, "abc<hr>def");
diff --git a/school/node_modules/string-strip-html/examples/extract-html-head-contents.js b/school/node_modules/string-strip-html/examples/extract-html-head-contents.js
deleted file mode 100644
index 5c09d52..0000000
--- a/school/node_modules/string-strip-html/examples/extract-html-head-contents.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// Extract HTML `<head>` contents
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-const someHtml = `<!DOCTYPE html>
-<html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title>the title</title>
- </head>
- <body>
- the content
- </body>
-</html>`;
-
-// The task asks not to include <head...> and </head>.
-// First, extract head tag-to-head tag, including contents
-const headWithHeadTags = stripHtml(someHtml, {
- onlyStripTags: ["head"],
- stripTogetherWithTheirContents: ["head"],
-})
- .filteredTagLocations.reduce(
- (acc, [from, to]) => `${acc}${someHtml.slice(from, to)}`,
- ""
- )
- .trim();
-
-assert.equal(
- headWithHeadTags,
- `<head>
- <meta charset="utf-8">
- <title>the title</title>
- </head>`
-);
-
-const headContents = headWithHeadTags.replace(/<\/?head>/g, "").trim();
-assert.equal(
- headContents,
- `<meta charset="utf-8">
- <title>the title</title>`
-);
diff --git a/school/node_modules/string-strip-html/examples/inline-tags.js b/school/node_modules/string-strip-html/examples/inline-tags.js
deleted file mode 100644
index 622999a..0000000
--- a/school/node_modules/string-strip-html/examples/inline-tags.js
+++ /dev/null
@@ -1,23 +0,0 @@
-// Just deletes inline tags
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-const someHtml = `This has an <b>un</b>bold word.`;
-
-// default behaviour:
-assert.equal(stripHtml(someHtml).result, `This has an un bold word.`);
-
-// let's tackle inline tags:
-assert.equal(
- stripHtml(someHtml, {
- cb: ({ tag, deleteFrom, deleteTo, insert, rangesArr }) => {
- if (["b", "strong"].includes(tag.name)) {
- rangesArr.push(tag.lastOpeningBracketAt, tag.lastClosingBracketAt + 1);
- } else {
- rangesArr.push(deleteFrom, deleteTo, insert);
- }
- },
- }).result,
- `This has an unbold word.`
-);
diff --git a/school/node_modules/string-strip-html/examples/leave-only-html.js b/school/node_modules/string-strip-html/examples/leave-only-html.js
deleted file mode 100644
index 93e21a8..0000000
--- a/school/node_modules/string-strip-html/examples/leave-only-html.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Leave only HTML
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-const someHtml = `<!DOCTYPE html>
-<html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <h1>Title</h1>
- Some text.
- </body>
-</html>`;
-
-assert.equal(
- stripHtml(someHtml).allTagLocations.reduce(
- (acc, [from, to]) => `${acc}${someHtml.slice(from, to)}`,
- ""
- ),
- `<!DOCTYPE html><html lang="en" dir="ltr"><head><meta charset="utf-8"><title></title></head><body><h1></h1></body></html>`
-);
diff --git a/school/node_modules/string-strip-html/examples/leave-only-opening-td.js b/school/node_modules/string-strip-html/examples/leave-only-opening-td.js
deleted file mode 100644
index e8ba37f..0000000
--- a/school/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">`
-);
diff --git a/school/node_modules/string-strip-html/examples/leave-only-td.js b/school/node_modules/string-strip-html/examples/leave-only-td.js
deleted file mode 100644
index af0b2cd..0000000
--- a/school/node_modules/string-strip-html/examples/leave-only-td.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Leave only `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>`;
-
-assert.equal(
- stripHtml(someHtml, {
- onlyStripTags: ["td"],
- }).filteredTagLocations.reduce(
- (acc, [from, to]) => `${acc}${someHtml.slice(from, to)}`,
- ""
- ),
- `<td class="col1"></td><td class="col2"></td><td class="col3"></td><td class="col4"></td>`
-);
diff --git a/school/node_modules/string-strip-html/examples/minimal-ranges.js b/school/node_modules/string-strip-html/examples/minimal-ranges.js
deleted file mode 100644
index 91dcbf7..0000000
--- a/school/node_modules/string-strip-html/examples/minimal-ranges.js
+++ /dev/null
@@ -1,33 +0,0 @@
-// Minimal example using Ranges
-
-// We strip tags and fix apostrophes
-// that's part of what https://codsen.com/os/detergent/ does
-
-import { strict as assert } from "assert";
-import { rApply } from "../../ranges-apply";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-import { convertAll } from "../../string-apostrophes";
-
-function stripAndFixApos(str) {
- if (!str || typeof str !== "string") {
- return "";
- }
- // Keep in mind, Ranges are array of 2-3 element arrays.
- // But absent Ranges are marked as null, not empty array.
- // It's so that we could test in "if-else" easily - null
- // is falsy but empty array is truthy.
- // That's why below we take precautions with "|| []".
- return rApply(
- str,
- (stripHtml(str).ranges || []).concat(convertAll(str).ranges || [])
- );
-}
-
-// strips tags and fixes apostrophes:
-assert.equal(
- stripAndFixApos(`Let's Go <strong>Larval</strong>`),
- `Let’s Go Larval`
-);
-
-// no tags, no apostrophes:
-assert.equal(stripAndFixApos(`zzz`), `zzz`);
diff --git a/school/node_modules/string-strip-html/examples/remove-html.js b/school/node_modules/string-strip-html/examples/remove-html.js
deleted file mode 100644
index b45894e..0000000
--- a/school/node_modules/string-strip-html/examples/remove-html.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// Remove all HTML from a string
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-const someHtml = `<!DOCTYPE html>
-<html lang="en" dir="ltr">
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <h1>Title</h1>
- Some text.
- </body>
-</html>`;
-
-assert.equal(stripHtml(someHtml).result, `Title\nSome text.`);
diff --git a/school/node_modules/string-strip-html/examples/strip-from-json.js b/school/node_modules/string-strip-html/examples/strip-from-json.js
deleted file mode 100644
index 95d8bd0..0000000
--- a/school/node_modules/string-strip-html/examples/strip-from-json.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// Strip HTML from a raw JSON string
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-import { traverse } from "../../ast-monkey-traverse";
-
-const stripFromJsonStr = (str) => {
- return traverse(JSON.parse(str), (key, val) => {
- // if currently an object is traversed, you get both "key" and "val"
- // if it's array, only "key" is present, "val" is undefined
- const current = val !== undefined ? val : key;
- if (
- // ensure it's a plain object, not array (monkey will report only "key" in
- // arrays and "val" will be undefined)
- // also ensure object's value a string, not boolean or number, because we
- // don't strip HTML from booleans or numbers or anything else than strings
- typeof val === "string"
- ) {
- // monkey's callback is like Array.map - whatever you return gets written:
- return stripHtml(val).result;
- }
- // default return, do nothing:
- return current;
- });
-};
-
-// nothing to strip, "<" is false alarm:
-assert.equal(
- JSON.stringify(stripFromJsonStr(`{"Operator":"<","IsValid":true}`), null, 0),
- `{"Operator":"<","IsValid":true}`
-);
-
-// some HTML within one of key values, monkey will skip the boolean:
-assert.equal(
- JSON.stringify(
- stripFromJsonStr(`{"Operator":"a <div>b</div> c","IsValid":true}`),
- null,
- 0
- ),
- `{"Operator":"a b c","IsValid":true}`
-);
diff --git a/school/node_modules/string-strip-html/examples/title-case-with-tag-skipping.js b/school/node_modules/string-strip-html/examples/title-case-with-tag-skipping.js
deleted file mode 100644
index c248346..0000000
--- a/school/node_modules/string-strip-html/examples/title-case-with-tag-skipping.js
+++ /dev/null
@@ -1,54 +0,0 @@
-// Set the title case using `title` package
-
-// This program will not touch any single tags (<br class="z"/> for example)
-// or in case of paired tags, paired tags and content between
-
-import { strict as assert } from "assert";
-import title from "title";
-import { rInvert } from "../../ranges-invert";
-import { rApply } from "../../ranges-apply";
-import { rRegex } from "../../ranges-regex";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-
-function tagAwareTitle(str) {
- const whitelist = ["eslint", "readme", "npm"];
- const { filteredTagLocations } = stripHtml(str, {
- stripTogetherWithTheirContents: ["*"],
- });
- const inverted = rInvert(
- filteredTagLocations.concat(
- whitelist.reduce((acc, curr) => {
- const rangesFindings = rRegex(new RegExp(curr, "gi"), str);
- if (rangesFindings) {
- return acc.concat(rangesFindings);
- }
- return acc;
- }, [])
- ),
- str.length
- );
-
- if (Array.isArray(inverted) && inverted.length) {
- // take inverted ranges, for example, [[3, 4], [10, 15]]
- // and add third element, replacement, which is same character
- // indexes only processed through "title":
- return rApply(
- str,
- inverted.map(([from, to]) => [from, to, title(str.slice(from, to))])
- );
- }
- // otherwise, just apply title() on the whole string:
- return title(str);
-}
-
-// middle:
-assert.equal(
- tagAwareTitle(`This is a title with some <code>code</code> in it`),
- `This Is a Title with Some <code>code</code> In It`
-);
-
-// leading:
-assert.equal(
- tagAwareTitle(`<span class="xyz">abc<span> defgh ESLint`),
- `<span class="xyz">abc<span> Defgh ESLint`
-);
diff --git a/school/node_modules/string-strip-html/examples/widow-word-removal-from-html.js b/school/node_modules/string-strip-html/examples/widow-word-removal-from-html.js
deleted file mode 100644
index bcc07b1..0000000
--- a/school/node_modules/string-strip-html/examples/widow-word-removal-from-html.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Widow word removal from text within HTML
-
-import { strict as assert } from "assert";
-import { stripHtml } from "../dist/string-strip-html.esm.js";
-import { removeWidows } from "../../string-remove-widows";
-
-const someHtml = `The quick brown fox jumps of the lazy dog.<div class="a">`;
-
-// default widow word removal libs are not aware of HTML:
-// -----------------------------------------------------------------------------
-
-assert.equal(
- removeWidows(someHtml).res,
- `The quick brown fox jumps of the lazy dog.<div&nbsp;class="a">` // 😱
-);
-
-// luckily, removeWidows() consumes optional HTML tag locations
-assert.equal(
- removeWidows(someHtml, {
- tagRanges: stripHtml(someHtml)
- // remove the third argument, what to insert ("&nbsp;" string in these cases)
- .ranges.map(([from, to]) => [from, to]),
- }).res,
- `The quick brown fox jumps of the lazy&nbsp;dog.<div class="a">` // βœ…
-);