mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-03 07:27:19 -04:00
Fix prefixing first paragraph with a newline, when there's no previous sibling node
This commit is contained in:
+3
-1
@@ -62,7 +62,9 @@ func (tr *ANSIRenderer) NewElement(node ast.Node, source []byte) Element {
|
||||
return Element{}
|
||||
}
|
||||
return Element{
|
||||
Renderer: &ParagraphElement{},
|
||||
Renderer: &ParagraphElement{
|
||||
First: node.PreviousSibling() == nil,
|
||||
},
|
||||
Finisher: &ParagraphElement{},
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -9,13 +9,16 @@ import (
|
||||
)
|
||||
|
||||
type ParagraphElement struct {
|
||||
First bool
|
||||
}
|
||||
|
||||
func (e *ParagraphElement) Render(w io.Writer, ctx RenderContext) error {
|
||||
bs := ctx.blockStack
|
||||
rules := ctx.options.Styles.Paragraph
|
||||
|
||||
_, _ = w.Write([]byte("\n"))
|
||||
if !e.First {
|
||||
_, _ = w.Write([]byte("\n"))
|
||||
}
|
||||
be := BlockElement{
|
||||
Block: &bytes.Buffer{},
|
||||
Style: cascadeStyle(bs.Current().Style, rules, true),
|
||||
|
||||
Vendored
-1
@@ -1,2 +1 @@
|
||||
|
||||
This is a [38;5;200mcode[0m. [0m[0m
|
||||
|
||||
Vendored
-1
@@ -1,2 +1 @@
|
||||
|
||||
This text is [3memphasized[0m. [0m[0m
|
||||
|
||||
Vendored
-1
@@ -1,2 +1 @@
|
||||
|
||||
[90m[0m[90m[0m[90mImage[0m [Image: [38;5;123mhttps://charm.sh/logo.png[0m]. [0m[0m
|
||||
|
||||
Vendored
-1
@@ -1,2 +1 @@
|
||||
|
||||
This is a [1;38;5;123mlink[0m ([4;38;5;123mhttps://charm.sh[0m). [0m[0m
|
||||
|
||||
Vendored
-1
@@ -1,2 +1 @@
|
||||
|
||||
This text is [1mstrong[0m. [0m[0m
|
||||
|
||||
Reference in New Issue
Block a user