Sha256: 3c68068f9247c6cf5ccdddb397f05c8712dbd81465a4d71a6d729a6fcd84745d

Contents?: true

Size: 1.17 KB

Versions: 23

Compression:

Stored size: 1.17 KB

Contents

'use strict'

module.exports = thematicBreak

var tab = '\t'
var lineFeed = '\n'
var space = ' '
var asterisk = '*'
var dash = '-'
var underscore = '_'

var maxCount = 3

function thematicBreak(eat, value, silent) {
  var index = -1
  var length = value.length + 1
  var subvalue = ''
  var character
  var marker
  var markerCount
  var queue

  while (++index < length) {
    character = value.charAt(index)

    if (character !== tab && character !== space) {
      break
    }

    subvalue += character
  }

  if (
    character !== asterisk &&
    character !== dash &&
    character !== underscore
  ) {
    return
  }

  marker = character
  subvalue += character
  markerCount = 1
  queue = ''

  while (++index < length) {
    character = value.charAt(index)

    if (character === marker) {
      markerCount++
      subvalue += queue + marker
      queue = ''
    } else if (character === space) {
      queue += character
    } else if (
      markerCount >= maxCount &&
      (!character || character === lineFeed)
    ) {
      subvalue += queue

      if (silent) {
        return true
      }

      return eat(subvalue)({type: 'thematicBreak'})
    } else {
      return
    }
  }
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.6 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.5 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.4 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.3 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.2 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.1 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3.5 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-5.0.0 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3.4 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3.3 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3.2 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3.1 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.3 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.2.3 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.2.2 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.2.1 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.2 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.1.9 node_modules/remark-parse/lib/tokenize/thematic-break.js
trusty-cms-4.1.8 node_modules/remark-parse/lib/tokenize/thematic-break.js