Skip to content

Commit

Permalink
Upgrade NPM packages (github#21480)
Browse files Browse the repository at this point in the history
* Upgrade a bunch of packages

* ...and upgrade highlightjs

* ... and ajv-formats (but not ajv)

* Revert graphql changes

* Revert "Revert graphql changes"

This reverts commit a5b8a34d52a48a7c2858415f6b1081c1d4902482.

* Update build-changelog.js

* Upgrade html-entities

* Upgrade commander, following migration guide
  • Loading branch information
heiskr authored Sep 13, 2021
1 parent b808ca6 commit 43158e8
Show file tree
Hide file tree
Showing 11 changed files with 2,050 additions and 2,464 deletions.
5 changes: 2 additions & 3 deletions lib/render-content/plugins/use-english-headings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import GithubSlugger from 'github-slugger'
import HtmlEntities from 'html-entities'
import { encode } from 'html-entities'
import { toString } from 'hast-util-to-string'
import { visit } from 'unist-util-visit'
const slugger = new GithubSlugger()
const entities = new HtmlEntities.XmlEntities()

const matcher = (node) => node.type === 'element' && ['h2', 'h3', 'h4'].includes(node.tagName)

Expand All @@ -16,7 +15,7 @@ export default function useEnglishHeadings({ englishHeadings }) {
// Get the plain text content of the heading node
const text = toString(node)
// find English heading in the collection
const englishHeading = englishHeadings[entities.encode(text)]
const englishHeading = englishHeadings[encode(text)]
// get English slug
const englishSlug = slugger.slug(englishHeading)
// use English slug for heading ID and link
Expand Down
5 changes: 2 additions & 3 deletions lib/render-content/renderContent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import liquid from './liquid.js'
import cheerio from 'cheerio'
import HtmlEntities from 'html-entities'
import { encode } from 'html-entities'
import stripHtmlComments from 'strip-html-comments'
import createProcessor from './create-processor.js'
const entities = new HtmlEntities.XmlEntities()

// used below to remove extra newlines in TOC lists
const endLine = '</a>\r?\n'
Expand Down Expand Up @@ -60,7 +59,7 @@ async function renderContent(template = '', context = {}, options = {}) {
return cheerio.load(html, { xmlMode: true })
}

if (options.encodeEntities) html = entities.encode(html)
if (options.encodeEntities) html = encode(html)

return html.trim()
} catch (error) {
Expand Down
5 changes: 2 additions & 3 deletions lib/use-english-headings.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import GithubSlugger from 'github-slugger'
import HtmlEntities from 'html-entities'
import { encode } from 'html-entities'
const slugger = new GithubSlugger()
const entities = new HtmlEntities.XmlEntities()

// replace translated IDs and links in headings with English
export default function useEnglishHeadings($, englishHeadings) {
$('h2, h3, h4').each((i, el) => {
slugger.reset()

// find English heading in the collection
const englishHeading = englishHeadings[entities.encode($(el).text())]
const englishHeading = englishHeadings[encode($(el).text())]

// get English slug
const englishSlug = slugger.slug(englishHeading)
Expand Down
Loading

0 comments on commit 43158e8

Please sign in to comment.