123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 'use strict'
-
- Object.defineProperty(exports, '__esModule', {value: true})
-
- var markdownLineEnding = require('../character/markdown-line-ending.js')
- var factorySpace = require('../tokenize/factory-space.js')
-
- var tokenize = initializeContent
-
- function initializeContent(effects) {
- var contentStart = effects.attempt(
- this.parser.constructs.contentInitial,
- afterContentStartConstruct,
- paragraphInitial
- )
- var previous
- return contentStart
-
- function afterContentStartConstruct(code) {
- if (code === null) {
- effects.consume(code)
- return
- }
-
- effects.enter('lineEnding')
- effects.consume(code)
- effects.exit('lineEnding')
- return factorySpace(effects, contentStart, 'linePrefix')
- }
-
- function paragraphInitial(code) {
- effects.enter('paragraph')
- return lineStart(code)
- }
-
- function lineStart(code) {
- var token = effects.enter('chunkText', {
- contentType: 'text',
- previous: previous
- })
-
- if (previous) {
- previous.next = token
- }
-
- previous = token
- return data(code)
- }
-
- function data(code) {
- if (code === null) {
- effects.exit('chunkText')
- effects.exit('paragraph')
- effects.consume(code)
- return
- }
-
- if (markdownLineEnding(code)) {
- effects.consume(code)
- effects.exit('chunkText')
- return lineStart
- } // Data.
-
- effects.consume(code)
- return data
- }
- }
-
- exports.tokenize = tokenize
|