All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
31 lines
545 B
JavaScript
31 lines
545 B
JavaScript
'use strict'
|
|
|
|
var markdownSpace = require('../character/markdown-space.js')
|
|
|
|
function spaceFactory(effects, ok, type, max) {
|
|
var limit = max ? max - 1 : Infinity
|
|
var size = 0
|
|
return start
|
|
|
|
function start(code) {
|
|
if (markdownSpace(code)) {
|
|
effects.enter(type)
|
|
return prefix(code)
|
|
}
|
|
|
|
return ok(code)
|
|
}
|
|
|
|
function prefix(code) {
|
|
if (markdownSpace(code) && size++ < limit) {
|
|
effects.consume(code)
|
|
return prefix
|
|
}
|
|
|
|
effects.exit(type)
|
|
return ok(code)
|
|
}
|
|
}
|
|
|
|
module.exports = spaceFactory
|