From 0f77f829e49b4cbe9c94ca37cadea56f2673c99c Mon Sep 17 00:00:00 2001 From: Dmitry Kotik <7944694+dkotik@users.noreply.github.com> Date: Sat, 21 Oct 2023 10:26:41 +0200 Subject: [PATCH] Add clarifying comments for thematic break parser --- parser/thematic_break.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/parser/thematic_break.go b/parser/thematic_break.go index e44ccb6..898faa6 100644 --- a/parser/thematic_break.go +++ b/parser/thematic_break.go @@ -17,6 +17,10 @@ func NewThematicBreakParser() BlockParser { return defaultthematicBreakParser } +// isThematicBreak returns true if a line indented +// with an offset contains only a set of three or more +// asterisks, dashes, or underscores mixed with characters +// deemed white space by [util.IsSpace]. func isThematicBreak(line []byte, offset int) bool { w, pos := util.IndentWidth(line, offset) if w > 3 { @@ -30,14 +34,18 @@ func isThematicBreak(line []byte, offset int) bool { continue } if mark == 0 { + // note the mark character mark = c count = 1 if mark == '*' || mark == '-' || mark == '_' { continue } + // mark character was not recognized return false } if c != mark { + // current character does not match + // previously noted mark return false } count++