61 lines
1.0 KiB
JavaScript
61 lines
1.0 KiB
JavaScript
/**
|
|
* @import {
|
|
* Construct,
|
|
* State,
|
|
* TokenizeContext,
|
|
* Tokenizer
|
|
* } from 'micromark-util-types'
|
|
*/
|
|
|
|
import { markdownLineEnding } from 'micromark-util-character';
|
|
/** @type {Construct} */
|
|
export const nonLazyContinuation = {
|
|
partial: true,
|
|
tokenize: tokenizeNonLazyContinuation
|
|
};
|
|
|
|
/**
|
|
* @this {TokenizeContext}
|
|
* Context.
|
|
* @type {Tokenizer}
|
|
*/
|
|
function tokenizeNonLazyContinuation(effects, ok, nok) {
|
|
const self = this;
|
|
return start;
|
|
|
|
/**
|
|
* At eol, before continuation.
|
|
*
|
|
* ```markdown
|
|
* > | * ```js
|
|
* ^
|
|
* | b
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function start(code) {
|
|
if (code === null) {
|
|
return nok(code);
|
|
}
|
|
effects.enter("lineEnding");
|
|
effects.consume(code);
|
|
effects.exit("lineEnding");
|
|
return after;
|
|
}
|
|
|
|
/**
|
|
* A continuation.
|
|
*
|
|
* ```markdown
|
|
* | * ```js
|
|
* > | b
|
|
* ^
|
|
* ```
|
|
*
|
|
* @type {State}
|
|
*/
|
|
function after(code) {
|
|
return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
|
|
}
|
|
} |