Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,24 @@ func NewParser() parser.BlockParser {
return defaultParser
}

func isSeparator(line []byte) bool {
line = util.TrimRightSpace(util.TrimLeftSpace(line))
func isStartSeparator(line []byte) bool {
line = util.TrimRightSpace(line)
for i := 0; i < len(line); i++ {
if line[i] != '-' {
return false
}
}
return true
return len(line) >= 3
}

func isEndSeparator(line []byte) bool {
line = util.TrimRightSpace(line)
for i := 0; i < len(line); i++ {
if line[i] != '-' && line[i] != '.' {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to accept -.- or ..- ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if line[0] != '-' || line[0] != '.' { return false }
for i := 1 ... {
    if line[i] != line[0] { return false }
}

return false
}
}
return len(line) >= 3
}

func (b *metaParser) Trigger() []byte {
Expand All @@ -112,15 +122,15 @@ func (b *metaParser) Open(parent gast.Node, reader text.Reader, pc parser.Contex
return nil, parser.NoChildren
}
line, _ := reader.PeekLine()
if isSeparator(line) {
if isStartSeparator(line) {
return gast.NewTextBlock(), parser.NoChildren
}
return nil, parser.NoChildren
}

func (b *metaParser) Continue(node gast.Node, reader text.Reader, pc parser.Context) parser.State {
line, segment := reader.PeekLine()
if isSeparator(line) && !util.IsBlank(line) {
if isEndSeparator(line) && !util.IsBlank(line) {
reader.Advance(segment.Len())
return parser.Close
}
Expand Down