mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fix #229
This commit is contained in:
parent
040b478cdb
commit
759cc35c3a
4 changed files with 52 additions and 6 deletions
|
|
@ -323,3 +323,45 @@ foo
|
|||
</li>
|
||||
</ul>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
||||
21: Fenced code block within list can start with tab
|
||||
//- - - - - - - - -//
|
||||
- List
|
||||
|
||||
```
|
||||
A
|
||||
B
|
||||
C
|
||||
```
|
||||
//- - - - - - - - -//
|
||||
<ul>
|
||||
<li>
|
||||
<p>List</p>
|
||||
<pre><code>A
|
||||
B
|
||||
C
|
||||
</code></pre>
|
||||
</li>
|
||||
</ul>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
22: Indented code block within list can start with tab
|
||||
//- - - - - - - - -//
|
||||
- List
|
||||
|
||||
A
|
||||
B
|
||||
C
|
||||
|
||||
a
|
||||
//- - - - - - - - -//
|
||||
<ul>
|
||||
<li>
|
||||
<p>List</p>
|
||||
<pre><code>A
|
||||
B
|
||||
C
|
||||
</code></pre>
|
||||
</li>
|
||||
</ul>
|
||||
<p>a</p>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
|
|
|||
|
|
@ -72,10 +72,6 @@ func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc C
|
|||
line, segment := reader.PeekLine()
|
||||
fdata := pc.Get(fencedCodeBlockInfoKey).(*fenceData)
|
||||
|
||||
// if code block line starts with a tab, keep a tab as it is.
|
||||
if segment.Padding != 0 {
|
||||
preserveLeadingTabInCodeBlock(&segment, reader, fdata.indent)
|
||||
}
|
||||
w, pos := util.IndentWidth(line, reader.LineOffset())
|
||||
if w < 4 {
|
||||
i := pos
|
||||
|
|
@ -94,6 +90,10 @@ func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc C
|
|||
pos, padding := util.DedentPositionPadding(line, reader.LineOffset(), segment.Padding, fdata.indent)
|
||||
|
||||
seg := text.NewSegmentPadding(segment.Start+pos, segment.Stop, padding)
|
||||
// if code block line starts with a tab, keep a tab as it is.
|
||||
if padding != 0 {
|
||||
preserveLeadingTabInCodeBlock(&seg, reader, fdata.indent)
|
||||
}
|
||||
node.Lines().Append(seg)
|
||||
reader.AdvanceAndSetPadding(segment.Stop-segment.Start-pos-1, padding)
|
||||
return Continue | NoChildren
|
||||
|
|
|
|||
|
|
@ -277,8 +277,12 @@ func DiffPretty(v1, v2 []byte) []byte {
|
|||
c = " "
|
||||
}
|
||||
for _, line := range diff.Lines {
|
||||
if c != " " {
|
||||
b.WriteString(fmt.Sprintf("%s | %s\n", c, util.VisualizeSpaces(line)))
|
||||
} else {
|
||||
b.WriteString(fmt.Sprintf("%s | %s\n", c, line))
|
||||
}
|
||||
}
|
||||
}
|
||||
return b.Bytes()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue