Skip to content

Commit 2a7b83c

Browse files
committed
Fix line endings in links, images
1 parent 5201ff2 commit 2a7b83c

File tree

5 files changed

+1301
-16
lines changed

5 files changed

+1301
-16
lines changed

index.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ function compiler(options) {
6666
htmlFlowData: onenterdata,
6767
htmlText: opener(html, buffer),
6868
htmlTextData: onenterdata,
69-
image: opener(image, onenterimage),
69+
image: opener(image),
70+
label: buffer,
7071
link: opener(link),
7172
listItem: opener(listItem),
7273
listItemValue: onenterlistitemvalue,
@@ -538,10 +539,6 @@ function compiler(options) {
538539
this.stack[this.stack.length - 1].value = data
539540
}
540541

541-
function onenterimage() {
542-
this.buffer()
543-
}
544-
545542
function onexitlink() {
546543
var context = this.stack[this.stack.length - 1]
547544

@@ -579,26 +576,24 @@ function compiler(options) {
579576
}
580577

581578
function onexitlabeltext(token) {
582-
var ctx =
583-
this.stack[this.stack.length - 1].type === 'fragment'
584-
? this.stack[this.stack.length - 2]
585-
: this.stack[this.stack.length - 1]
586-
ctx.label = toString(this.stack[this.stack.length - 1])
587-
ctx.identifier = normalizeIdentifier(
579+
this.stack[this.stack.length - 2].identifier = normalizeIdentifier(
588580
this.sliceSerialize(token)
589581
).toLowerCase()
590582
}
591583

592584
function onexitlabel() {
593-
var data
585+
var fragment = this.stack[this.stack.length - 1]
586+
var value = this.resume()
587+
588+
this.stack[this.stack.length - 1].label = value
594589

595590
// Assume a reference.
596591
setData('inReference', true)
597592

598-
// If we’re in a fragment, we’re in an image and buffering.
599-
if (this.stack[this.stack.length - 1].type === 'fragment') {
600-
data = this.resume()
601-
this.stack[this.stack.length - 1].alt = data
593+
if (this.stack[this.stack.length - 1].type === 'link') {
594+
this.stack[this.stack.length - 1].children = fragment.children
595+
} else {
596+
this.stack[this.stack.length - 1].alt = value
602597
}
603598
}
604599

0 commit comments

Comments
 (0)