From 82ff890073b9f9dcca0f3f355f30539a8337fddc Mon Sep 17 00:00:00 2001 From: yuin Date: Thu, 2 Feb 2023 21:02:21 +0900 Subject: [PATCH] Fix #361 --- _test/extra.txt | 11 +++++++++++ parser/html_block.go | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/_test/extra.txt b/_test/extra.txt index 01140fd..cea89b5 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -741,3 +741,14 @@ a //= = = = = = = = = = = = = = = = = = = = = = = =// + + +58: HTML end tag without trailing new lines + OPTIONS: {"trim": true} +//- - - - - - - - -// +
+
+//- - - - - - - - -// +
+
+//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/html_block.go b/parser/html_block.go index 380e723..6881e25 100644 --- a/parser/html_block.go +++ b/parser/html_block.go @@ -149,7 +149,7 @@ func (b *htmlBlockParser) Open(parent ast.Node, reader text.Reader, pc Context) } } if node != nil { - reader.Advance(segment.Len() - 1) + reader.Advance(segment.Len() - util.TrimRightSpaceLength(line)) node.Lines().Append(segment) return node, NoChildren } @@ -172,7 +172,7 @@ func (b *htmlBlockParser) Continue(node ast.Node, reader text.Reader, pc Context } if htmlBlockType1CloseRegexp.Match(line) { htmlBlock.ClosureLine = segment - reader.Advance(segment.Len() - 1) + reader.Advance(segment.Len() - util.TrimRightSpaceLength(line)) return Close } case ast.HTMLBlockType2: @@ -211,7 +211,7 @@ func (b *htmlBlockParser) Continue(node ast.Node, reader text.Reader, pc Context } } node.Lines().Append(segment) - reader.Advance(segment.Len() - 1) + reader.Advance(segment.Len() - util.TrimRightSpaceLength(line)) return Continue | NoChildren }