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