@@ -8,12 +8,11 @@ var codes = require('micromark/dist/character/codes')
88var constants = require ( 'micromark/dist/constant/constants' )
99var own = require ( 'micromark/dist/constant/has-own-property' )
1010var types = require ( 'micromark/dist/constant/types' )
11- var flatMap = require ( 'micromark/dist/util/flat-map' )
1211var normalizeIdentifier = require ( 'micromark/dist/util/normalize-identifier' )
1312var safeFromInt = require ( 'micromark/dist/util/safe-from-int' )
1413var parser = require ( 'micromark/dist/parse' )
1514var preprocessor = require ( 'micromark/dist/preprocess' )
16- var postprocessor = require ( 'micromark/dist/postprocess' )
15+ var postprocess = require ( 'micromark/dist/postprocess' )
1716
1817function fromMarkdown ( value , encoding , options ) {
1918 if ( typeof encoding !== 'string' ) {
@@ -22,11 +21,8 @@ function fromMarkdown(value, encoding, options) {
2221 }
2322
2423 return compiler ( options ) (
25- postprocessor ( ) (
26- flatMap (
27- flatMap ( [ value , codes . eof ] , preprocessor ( ) , encoding ) ,
28- parser ( options ) . document ( ) . write
29- )
24+ postprocess (
25+ parser ( options ) . document ( ) . write ( preprocessor ( ) ( value , encoding , true ) )
3026 )
3127 )
3228}
@@ -155,8 +151,6 @@ function compiler(options) {
155151 while ( ++ index < events . length ) {
156152 event = events [ index ]
157153
158- if ( ! event ) break
159-
160154 // We preprocess lists to add `listItem` tokens, and to infer whether
161155 // items the list itself are spread out.
162156 if (
@@ -173,7 +167,7 @@ function compiler(options) {
173167 }
174168
175169 index = - 1
176- length = events . length - 1
170+ length = events . length
177171
178172 while ( ++ index < length ) {
179173 handler = config [ events [ index ] [ 0 ] ]
0 commit comments