diff --git a/extension/_test/definition_list.txt b/extension/_test/definition_list.txt index 2ddc3ea..a6c1c87 100644 --- a/extension/_test/definition_list.txt +++ b/extension/_test/definition_list.txt @@ -141,3 +141,16 @@ on two lines.

//= = = = = = = = = = = = = = = = = = = = = = = =// + +6: Definition lists indented with tabs +//- - - - - - - - -// +0 +: ``` + 0 +//- - - - - - - - -// +
+
0
+
	0
+
+
+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/extension/definition_list.go b/extension/definition_list.go index eb16dd0..d2f5fec 100644 --- a/extension/definition_list.go +++ b/extension/definition_list.go @@ -138,7 +138,7 @@ func (b *definitionDescriptionParser) Open(parent gast.Node, reader text.Reader, para.Parent().RemoveChild(para.Parent(), para) } cpos, padding := util.IndentPosition(line[pos+1:], pos+1, list.Offset-pos-1) - reader.AdvanceAndSetPadding(cpos, padding) + reader.AdvanceAndSetPadding(cpos+1, padding) return ast.NewDefinitionDescription(), parser.HasChildren } diff --git a/parser/code_block.go b/parser/code_block.go index 4b18639..10a6762 100644 --- a/parser/code_block.go +++ b/parser/code_block.go @@ -52,7 +52,7 @@ func (b *codeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context // if code block line starts with a tab, keep a tab as it is. if segment.Padding != 0 { - preserveLeadingTabInCodeBlock(&segment, reader) + preserveLeadingTabInCodeBlock(&segment, reader, 0) } node.Lines().Append(segment) @@ -84,11 +84,12 @@ func (b *codeBlockParser) CanAcceptIndentedLine() bool { return true } -func preserveLeadingTabInCodeBlock(segment *text.Segment, reader text.Reader) { - offsetWithPadding := reader.LineOffset() +func preserveLeadingTabInCodeBlock(segment *text.Segment, reader text.Reader, indent int) { + offsetWithPadding := reader.LineOffset() + indent sl, ss := reader.Position() reader.SetPosition(sl, text.NewSegment(ss.Start-1, ss.Stop)) if offsetWithPadding == reader.LineOffset() { + println("here") segment.Padding = 0 segment.Start-- } diff --git a/parser/fcode_block.go b/parser/fcode_block.go index 4801449..63c2fd4 100644 --- a/parser/fcode_block.go +++ b/parser/fcode_block.go @@ -71,9 +71,10 @@ func (b *fencedCodeBlockParser) Open(parent ast.Node, reader text.Reader, pc Con func (b *fencedCodeBlockParser) Continue(node ast.Node, reader text.Reader, pc Context) State { 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) + preserveLeadingTabInCodeBlock(&segment, reader, fdata.indent) } w, pos := util.IndentWidth(line, reader.LineOffset()) if w < 4 {