How to use detab - 6 common examples

To help you get started, we’ve selected a few detab 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 andreypopp / reactdown / src / render / Renderer.js View on Github external
code(node: MDASTCodeNode): JSAST {
    let value = node.value ? detab(node.value + '\n') : '';
    value = this.encode(value);
    value = this.renderText(value);
    return this.renderElement('Code', null, value);
  }
github nuxt / markdown / src / handlers / code.js View on Github external
export default function code (h, node) {
  const value = node.value ? detab(node.value + '\n') : ''
  const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
  const props = {}

  if (lang) {
    props.className = ['language-' + lang]
  }

  return h(node.position, 'pre', [h(node, 'code', props, [u('text', value)])])
}
github priceline / design-system / docs / src / Markdown.js View on Github external
const codeHandler = (h, node) => {
  const value = node.value ? detab(node.value + '\n') : ''
  const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
  const props = {}

  if (lang) {
    props.className = ['language-' + lang]
    props.lang = lang
  }

  return h(node.position, 'pre', props, [unist('text', value)])
}
github egoist / magi-deprecated / src / lib / handlers / code.js View on Github external
export default function code(h, node) {
  const value = node.value ? detab(node.value + '\n') : ''
  const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/)
  const props = {}

  if (lang) {
    props.className = ['language-' + lang]
  }

  return h(node.position, 'pre', [
    h(node, 'code', props, [u(node.highlighted ? 'raw' : 'text', value)])
  ])
}
github apollographql / gatsby-theme-apollo / packages / gatsby-theme-apollo-docs / src / util / code-to-hast.js View on Github external
export default function codeToHast(h, node) {
  const value = node.value ? detab(node.value + '\n') : '';
  const lang = node.lang && node.lang.match(/^[^ \t]+(?=[ \t]|$)/);
  const codeProps = {className: `language-${lang}`};
  const preProps = {className: 'line-numbers'};

  if (node.meta) {
    const {line} = querystring.parse(node.meta);
    preProps.dataLine = line;
  }

  return h(node.position, 'pre', preProps, [
    h(node, 'code', codeProps, [u('text', value)])
  ]);
}
github c8r / kit / md / src / createElement.js View on Github external
const codeHandler = (h, node, parent) => {
  const props = {
    lang: node.lang
  }

  const value = node.value ? detab(node.value + '\n') : ''
  return h(node.position, 'pre', props, [unist('text', value)])
}

detab

Detab: tabs -> spaces

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis

Popular detab functions