From 49dd50b47d1cf5d16b0587069947e9cf3c215b01 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 26 Jan 2023 15:29:04 -0500 Subject: [PATCH] remove all uses of encodeEntities (#34202) --- lib/render-content/README.md | 1 - lib/render-content/renderContent.js | 6 +----- tests/linting/lint-files.js | 1 - tests/rendering/sidebar.js | 2 +- tests/unit/render-content.js | 9 --------- 5 files changed, 2 insertions(+), 17 deletions(-) diff --git a/lib/render-content/README.md b/lib/render-content/README.md index cc5069393826..2a03b1d67bd2 100644 --- a/lib/render-content/README.md +++ b/lib/render-content/README.md @@ -30,7 +30,6 @@ Liquid will be looking for includes in `${process.cwd()}/includes`. Options: -- `encodeEntities`: Encode html entities. Default: `false`. - `fileName`: File name for debugging purposes. - `textOnly`: Output text instead of html using [cheerio](https://ghub.io/cheerio). diff --git a/lib/render-content/renderContent.js b/lib/render-content/renderContent.js index 2839051bc909..071eb8645ad5 100644 --- a/lib/render-content/renderContent.js +++ b/lib/render-content/renderContent.js @@ -1,6 +1,6 @@ import liquid from './liquid.js' import cheerio from 'cheerio' -import { encode, decode } from 'html-entities' +import { decode } from 'html-entities' import stripHtmlComments from 'strip-html-comments' import createProcessor from './create-processor.js' @@ -50,10 +50,6 @@ async function renderContent(template = '', context = {}, options = {}) { html = fastTextOnly(html) } - if (options.encodeEntities) { - html = encode(html) - } - return html.trim() } catch (error) { if (options.filename) { diff --git a/tests/linting/lint-files.js b/tests/linting/lint-files.js index b5c0ee64b411..bb48a85f865b 100644 --- a/tests/linting/lint-files.js +++ b/tests/linting/lint-files.js @@ -983,7 +983,6 @@ describe('lint learning tracks', () => { typeof entry.featured_track === 'boolean' || (await renderContent(entry.featured_track, context, { textOnly: true, - encodeEntities: true, })) === 'true' featuredTracksPerVersion.push(isFeaturedLink) } diff --git a/tests/rendering/sidebar.js b/tests/rendering/sidebar.js index bbb7ca5e2a66..4b01adfd9d43 100644 --- a/tests/rendering/sidebar.js +++ b/tests/rendering/sidebar.js @@ -128,7 +128,7 @@ describe('sidebar', () => { // Create a ContentCheck object that has all the categories/subcategories and get the title from frontmatter async function createContentCheckDirectory() { - const renderOpts = { textOnly: true, encodeEntities: true } + const renderOpts = { textOnly: true } for (const filename of contentFiles) { const { data } = frontmatter(await fs.promises.readFile(filename, 'utf8')) diff --git a/tests/unit/render-content.js b/tests/unit/render-content.js index ea56a857e0e0..c54172cf98ad 100644 --- a/tests/unit/render-content.js +++ b/tests/unit/render-content.js @@ -98,15 +98,6 @@ describe('renderContent', () => { expect(output).toBe('') }) - test('encodes entities', async () => { - const template = '' - const context = {} - const output = await renderContent(template, context, { - encodeEntities: true, - }) - expect(output).toBe('<p><beep></beep></p>') - }) - test('does not render newlines around links in tables', async () => { const template = nl(` | Keyboard shortcut | Description