12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import {factorySpace} from 'micromark-factory-space'
- import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
- export function factoryWhitespace(effects, ok) {
-
- let seen
- return start
-
- function start(code) {
- if (markdownLineEnding(code)) {
- effects.enter('lineEnding')
- effects.consume(code)
- effects.exit('lineEnding')
- seen = true
- return start
- }
- if (markdownSpace(code)) {
- return factorySpace(
- effects,
- start,
- seen ? 'linePrefix' : 'lineSuffix'
- )(code)
- }
- return ok(code)
- }
- }
|