diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 17:40:27 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-09-30 17:40:27 +0200 |
| commit | baccf109b9d7eb7e95f084579eaea7b6d88b782b (patch) | |
| tree | d8908415f92828ef4de568280ed67833536a7e03 /mardown | |
| parent | c40941359d46468ecd0b71919e34a1c481c7bee2 (diff) | |
feat(markdown): ast for literal and line break
support header in header
Diffstat (limited to 'mardown')
| -rw-r--r-- | mardown/ast.go | 4 | ||||
| -rw-r--r-- | mardown/ast_header.go | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/mardown/ast.go b/mardown/ast.go index 76328f4..819d73a 100644 --- a/mardown/ast.go +++ b/mardown/ast.go @@ -37,13 +37,13 @@ func getBlock(lxs lexers) (block, error) { switch lxs.Current().Type { case lexerHeader: b, err = header(lxs) - case lexerBreak: case lexerExternal: case lexerModifier: case lexerCode: case lexerEscape: case lexerQuote: - case lexerLiteral: + case lexerLiteral, lexerBreak: + b = astLiteral(lxs.Current().Value) default: err = errors.Join(ErrUnkownLexType, fmt.Errorf("type received: %s", lxs.Current().Type)) } diff --git a/mardown/ast_header.go b/mardown/ast_header.go index 540f47f..c7bc85d 100644 --- a/mardown/ast_header.go +++ b/mardown/ast_header.go @@ -16,8 +16,14 @@ func header(lxs lexers) (block, error) { if err != nil { return nil, err } + // if this is a header, just consider it as literal # if h, ok := bl.(*astHeader); ok { - //TODO: handle + var s string + for range h.level { + s += "#" + } + b.content = append(b.content, astLiteral(s)) + b.content = append(b.content, h.content...) } b.content = append(b.content, bl) } |
