From 466482bf1977bb9ae848dda2606157344fffd3a9 Mon Sep 17 00:00:00 2001 From: yuin Date: Sat, 11 Sep 2021 09:55:07 +0900 Subject: [PATCH] Fix #245 - 3 --- _test/extra.txt | 7 +++++++ parser/code_block.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/_test/extra.txt b/_test/extra.txt index 41b1d7d..8c9578f 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -380,3 +380,10 @@ a* b c d *e* //- - - - - - - - -// //= = = = = = = = = = = = = = = = = = = = = = = =// + +25: code block starts with tab +//- - - - - - - - -// + x +//- - - - - - - - -// +
	x
+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/code_block.go b/parser/code_block.go index c16ea41..732f18c 100644 --- a/parser/code_block.go +++ b/parser/code_block.go @@ -31,6 +31,10 @@ func (b *codeBlockParser) Open(parent ast.Node, reader text.Reader, pc Context) node := ast.NewCodeBlock() reader.AdvanceAndSetPadding(pos, padding) _, segment = reader.PeekLine() + // if code block line starts with a tab, keep a tab as it is. + if segment.Padding != 0 { + preserveLeadingTabInCodeBlock(&segment, reader, 0) + } node.Lines().Append(segment) reader.Advance(segment.Len() - 1) return node, NoChildren