Add horizontal line using '---'
This commit is contained in:
parent
1ff241a74e
commit
567a1391b5
@ -256,6 +256,9 @@ func (h *HTMLFormatter) Format() string {
|
||||
} else if entry.Break != nil {
|
||||
// Write break tag to output
|
||||
h.out.WriteString("<br>")
|
||||
} else if entry.Hline != nil {
|
||||
// Write horizonhal line tag to output
|
||||
h.out.WriteString("<hr>")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,15 +112,6 @@ func (b *buffer) pop() (scanner.Token, string) {
|
||||
return scanner.EOF, ""
|
||||
}
|
||||
|
||||
func (b *buffer) peek() (scanner.Token, string) {
|
||||
if b.tok.Size() > 0 {
|
||||
tok := b.tok.Peek()
|
||||
lit := b.lit.Peek()
|
||||
return tok.(scanner.Token), lit.(string)
|
||||
}
|
||||
return scanner.EOF, ""
|
||||
}
|
||||
|
||||
// Parse parses the input into an AST
|
||||
func (p *Parser) Parse() (*ast.AST, error) {
|
||||
// Create new AST
|
||||
@ -172,6 +163,29 @@ parseLoop:
|
||||
// Continue to next token
|
||||
continue
|
||||
}
|
||||
} else if tok == scanner.PUNCT && lit == "-" {
|
||||
// Scan token
|
||||
tok, lit = p.scan()
|
||||
// If token is not PUNCT or literal is not "-"
|
||||
if tok != scanner.PUNCT || lit != "-" {
|
||||
// Unscan token
|
||||
p.unscan()
|
||||
// Continue parsing next token
|
||||
continue
|
||||
}
|
||||
// Scan token
|
||||
tok, lit = p.scan()
|
||||
// If token is not PUNCT or literal is not "-"
|
||||
if tok != scanner.PUNCT || lit != "-" {
|
||||
// Unscan two tokens
|
||||
p.unscanMulti(2)
|
||||
// Continue parsing next token
|
||||
continue
|
||||
}
|
||||
// Add Hline to AST
|
||||
AST.Entries = append(AST.Entries, ast.Entry{Hline: &ast.Hline{}})
|
||||
// Continue parsing next token
|
||||
continue
|
||||
}
|
||||
// Unscan token as it will be needed for parsing para
|
||||
p.unscan()
|
||||
|
Loading…
Reference in New Issue
Block a user