@@ -38,7 +38,7 @@ func (p *Parser) tag() Tag {
38
38
return p .quote ()
39
39
return p .img ()
40
40
} else if p .check (scanner .BACKTICK ) {
41
- return p .code ()
41
+ return p .code (false )
42
42
} else if p .check (scanner .HASH ) && (p .prev ().Kind == scanner .EMPTYLINE || p .prev ().Kind == 0 ) {
43
43
return p .heading ()
44
44
} else {
@@ -257,7 +257,8 @@ func (p *Parser) emphasis() Tag {
257
257
}
258
258
}
259
259
260
- func (p * Parser ) code () Tag {
260
+ // TODO: possible issue: if no language or type is specified the parser assumes the next line to be the content
261
+ func (p * Parser ) code (quoteContext bool ) Tag {
261
262
p .advance ()
262
263
if p .check (scanner .TEXT ) {
263
264
// inline code:
@@ -292,6 +293,14 @@ func (p *Parser) code() Tag {
292
293
293
294
b := strings.Builder {}
294
295
for ! p .check (scanner .BACKTICK ) {
296
+ if quoteContext && (p .prev ().Kind == scanner .NEWLINE || p .prev ().Kind == scanner .EMPTYLINE ) {
297
+ // skips the > and the space at the start of the line in a quoted context
298
+ p .advance ()
299
+ if p .peek ().Value == " " {
300
+ p .advance ()
301
+ }
302
+ continue
303
+ }
295
304
if p .check (scanner .TEXT ) {
296
305
b .WriteString (p .peek ().Value )
297
306
} else {
@@ -318,12 +327,11 @@ func (p *Parser) paragraph() Tag {
318
327
children := make ([]Tag , 0 )
319
328
// paragraph should only contain inline code, italic and bold or text
320
329
for ! p .check (scanner .EMPTYLINE ) && ! p .isAtEnd () {
321
- // TODO: add link case here
322
330
switch p .peek ().Kind {
323
331
case scanner .STRAIGHTBRACEOPEN :
324
332
children = append (children , p .link ())
325
333
case scanner .BACKTICK :
326
- children = append (children , p .code ())
334
+ children = append (children , p .code (false ))
327
335
case scanner .STAR , scanner .UNDERSCORE :
328
336
children = append (children , p .emphasis ())
329
337
case scanner .TEXT :
0 commit comments