@@ -34,9 +34,15 @@ function fromMarkdown(value, encoding, options) {
34
34
// Note this compiler only understand complete buffering, not streaming.
35
35
function compiler ( options ) {
36
36
var settings = options || { }
37
-
38
- var handlers = configure (
37
+ var config = configure (
39
38
{
39
+ canContainEols : [
40
+ 'emphasis' ,
41
+ 'fragment' ,
42
+ 'heading' ,
43
+ 'paragraph' ,
44
+ 'strong'
45
+ ] ,
40
46
enter : {
41
47
autolink : opener ( link ) ,
42
48
autolinkProtocol : onenterdata ,
@@ -170,13 +176,13 @@ function compiler(options) {
170
176
length = events . length - 1
171
177
172
178
while ( ++ index < length ) {
173
- handler = handlers [ events [ index ] [ 0 ] ]
179
+ handler = config [ events [ index ] [ 0 ] ]
174
180
175
181
if ( own . call ( handler , events [ index ] [ 1 ] . type ) ) {
176
182
handler [ events [ index ] [ 1 ] . type ] . call (
177
183
{
178
184
stack : stack ,
179
- handlers : handlers ,
185
+ config : config ,
180
186
enter : enter ,
181
187
exit : exit ,
182
188
buffer : buffer ,
@@ -497,13 +503,7 @@ function compiler(options) {
497
503
return
498
504
}
499
505
500
- if (
501
- context . type === 'emphasis' ||
502
- context . type === 'fragment' ||
503
- context . type === 'heading' ||
504
- context . type === 'paragraph' ||
505
- context . type === 'strong'
506
- ) {
506
+ if ( config . canContainEols . indexOf ( context . type ) !== - 1 ) {
507
507
onenterdata . call ( this , token )
508
508
onexitdata . call ( this , token )
509
509
}
@@ -739,29 +739,30 @@ function compiler(options) {
739
739
}
740
740
}
741
741
742
- function configure ( handlers , extensions ) {
742
+ function configure ( config , extensions ) {
743
743
var length = extensions . length
744
744
var index = - 1
745
745
746
746
while ( ++ index < length ) {
747
- extension ( handlers , extensions [ index ] )
747
+ extension ( config , extensions [ index ] )
748
748
}
749
749
750
- return handlers
750
+ return config
751
751
}
752
752
753
- function extension ( handlers , extension ) {
754
- var hook
753
+ function extension ( config , extension ) {
754
+ var key
755
755
var left
756
756
var right
757
- var type
758
757
759
- for ( hook in extension ) {
760
- left = own . call ( handlers , hook ) ? handlers [ hook ] : ( handlers [ hook ] = { } )
761
- right = extension [ hook ]
758
+ for ( key in extension ) {
759
+ left = own . call ( config , key ) ? config [ key ] : ( config [ key ] = { } )
760
+ right = extension [ key ]
762
761
763
- for ( type in right ) {
764
- left [ type ] = right [ type ]
762
+ if ( key === 'canContainEols' ) {
763
+ config [ key ] = [ ] . concat ( left , right )
764
+ } else {
765
+ Object . assign ( left , right )
765
766
}
766
767
}
767
768
}
0 commit comments