Skip to content

Commit

Permalink
remove all uses of encodeEntities (github#34202)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Jan 26, 2023
1 parent 6b2e628 commit 49dd50b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion lib/render-content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
6 changes: 1 addition & 5 deletions lib/render-content/renderContent.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion tests/linting/lint-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/rendering/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/render-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,6 @@ describe('renderContent', () => {
expect(output).toBe('')
})

test('encodes entities', async () => {
const template = '<beep></beep>'
const context = {}
const output = await renderContent(template, context, {
encodeEntities: true,
})
expect(output).toBe('&lt;p&gt;&lt;beep&gt;&lt;/beep&gt;&lt;/p&gt;')
})

test('does not render newlines around links in tables', async () => {
const template = nl(`
| Keyboard shortcut | Description
Expand Down

0 comments on commit 49dd50b

Please sign in to comment.