aboutsummaryrefslogtreecommitdiff
path: root/mardown
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-10-01 09:51:21 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-10-01 09:51:21 +0200
commit11e4c0d5e62f5a7f3840a83081567eff33f16fd3 (patch)
tree59a070566b4912a2e01c37566b8723ef58c4871a /mardown
parente189a051ef8fe5e9fb439773e4cbc27103f537ca (diff)
feat(markdown): replace line break by space in paragraph
Diffstat (limited to 'mardown')
-rw-r--r--mardown/ast_paragraph.go7
-rw-r--r--mardown/ast_test.go2
2 files changed, 7 insertions, 2 deletions
diff --git a/mardown/ast_paragraph.go b/mardown/ast_paragraph.go
index 687e735..5961370 100644
--- a/mardown/ast_paragraph.go
+++ b/mardown/ast_paragraph.go
@@ -50,8 +50,13 @@ func paragraph(lxs *lexers, oneLine bool) (*astParagraph, error) {
}
tree.content = append(tree.content, astLiteral(lxs.Current().Value))
case lexerLiteral, lexerHeader:
+ s := lxs.Current().Value
+ // replace line break by space
+ if n > 0 {
+ s = " " + s
+ }
n = 0
- tree.content = append(tree.content, astLiteral(lxs.Current().Value))
+ tree.content = append(tree.content, astLiteral(s))
case lexerModifier:
n = 0
mod, err := modifier(lxs)
diff --git a/mardown/ast_test.go b/mardown/ast_test.go
index 030656b..971e6ac 100644
--- a/mardown/ast_test.go
+++ b/mardown/ast_test.go
@@ -22,7 +22,7 @@ var parsed = `
<h1>Je suis un titre</h1>
<p>Avec une description classique, sur plusieurs lignes</p>
<p>Et je peux mettre du texte en <b>gras</b>, en <em>italique</em> et les <b><em>deux en même temps</em></b> !</p>
-<div class="quote"><blockquote>Je suis une magnifique source sur plusieurs lignes</blockquote><p>avec une source</p></div>
+<div class="quote"><blockquote>Je suis une magnifique citation sur plusieurs lignes</blockquote><p>avec une source</p></div>
`
func TestAst(t *testing.T) {