How to use stringify-entities - 3 common examples

To help you get started, we’ve selected a few stringify-entities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orbiting / mdast / packages / remark-preset / src / span.js View on Github external
? ' ' + Object.keys(node.data).map(key => {
          if (typeof node.data[key] !== 'string') {
            throw new Error('mdast span: only stings are supported, you may use JSON.stringify')
          }
          return `data-${encodeEntities(key)}="${encodeEntities(node.data[key])}"`
        }).join(' ')
        : ''}>`
github jsamr / react-native-render-html-table-bridge / src / alter-node.ts View on Github external
export function domToHTML(root: HTMLNode, stats: TableStats): string {
  let html = ''
  if (root.type === 'tag') {
    const strChildren = root.children.reduce((prev: string, curr: HTMLNode) => {
      if (curr.type === 'tag' && curr.name === 'tr') {
        stats.rows += 1
      }
      if (curr.type === 'tag' && (curr.name === 'td' || curr.name === 'th') && stats.rows === 1) {
        stats.columns += 1
      }
      return `${prev}${domToHTML(curr, stats)}`
    }, '')
    html = `${renderOpeningTag(root.name, root.attribs)}${strChildren}`
  } else if (root.type === 'text') {
    const text = strigifyEntities(root.data)
    html = text
    stats.characters += text.length
  }
  return html
}
github mosjs / mos / packages / mos-core / src / stringify / encode-factory.ts View on Github external
function encoder (value: string): string {
    return encode(value, options)
  }

stringify-entities

Serialize (encode) HTML character references

MIT
Latest version published 23 days ago

Package Health Score

77 / 100
Full package analysis

Popular stringify-entities functions