How to use longest-streak - 2 common examples

To help you get started, we’ve selected a few longest-streak 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 mosjs / mos / packages / mos-core / src / stringify / visitors / code.ts View on Github external
* isn’t compiled using a tab.
     */

    if (
      parent &&
      parent.type === 'listItem' &&
      options.listItemIndent !== LIST_ITEM_TAB &&
      options.pedantic
    ) {
      throw new Error(ERROR_LIST_ITEM_INDENT + node.position)
    }

    return pad(value, 1)
  }

  let fence = longestStreak(value, marker) + 1

  /*
   * Fix GFM / RedCarpet bug, where fence-like characters
   * inside fenced code can exit a code-block.
   * Yes, even when the outer fence uses different
   * characters, or is longer.
   * Thus, we can only pad the code to make it work.
   */

  if (FENCE.test(value)) {
    value = pad(value, 1)
  }

  const fenceMarkdown = marker.repeat(Math.max(fence, MINIMUM_CODE_FENCE_LENGTH))

  return `${fenceMarkdown + language}\n${value}\n${fenceMarkdown}`
github mosjs / mos / packages / mos-core / src / stringify / visitors / inline-code.ts View on Github external
const visitor: Visitor = (compiler, node) => {
  const ticks = '`'.repeat(longestStreak(node.value, '`') + 1)
  let start = ticks
  let end = ticks

  if (node.value.charAt(0) === '`') {
    start += ' '
  }

  if (node.value.charAt(node.value.length - 1) === '`') {
    end = ` ${end}`
  }

  return start + node.value + end
}

longest-streak

Count the longest repeating streak of a substring

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis

Popular longest-streak functions