mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Another fix to handle TAB
This commit is contained in:
parent
9313a1c188
commit
f675a65632
1 changed files with 23 additions and 4 deletions
|
|
@ -103,12 +103,31 @@ func NewDefinitionDescriptionParser() parser.BlockParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *definitionDescriptionParser) Open(parent gast.Node, reader text.Reader, pc parser.Context) (gast.Node, parser.State) {
|
func (b *definitionDescriptionParser) Open(parent gast.Node, reader text.Reader, pc parser.Context) (gast.Node, parser.State) {
|
||||||
line, _ := reader.PeekLine()
|
list, lok := parent.(*ast.DefinitionList) // for defition description, we must have a definition list as a parent
|
||||||
pos := pc.BlockOffset()
|
if !lok {
|
||||||
if line[pos] != ':' || len(line) <= pos || line[pos+1] != ' ' {
|
|
||||||
return nil, parser.NoChildren
|
return nil, parser.NoChildren
|
||||||
}
|
}
|
||||||
list, _ := parent.(*ast.DefinitionList)
|
line, _ := reader.PeekLine()
|
||||||
|
pos := pc.BlockOffset()
|
||||||
|
if line[pos] != ':' {
|
||||||
|
return nil, parser.NoChildren
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1 more space after :
|
||||||
|
w, _ := util.IndentWidth(line[pos+1:], pos+1)
|
||||||
|
if w < 1 {
|
||||||
|
return nil, parser.NoChildren
|
||||||
|
}
|
||||||
|
|
||||||
|
if w >= 8 {
|
||||||
|
w = 5
|
||||||
|
}
|
||||||
|
w += pos + 1
|
||||||
|
|
||||||
|
if w != list.Offset {
|
||||||
|
return nil, parser.NoChildren
|
||||||
|
}
|
||||||
|
|
||||||
para := list.TemporaryParagraph
|
para := list.TemporaryParagraph
|
||||||
list.TemporaryParagraph = nil
|
list.TemporaryParagraph = nil
|
||||||
if para != nil {
|
if para != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue