mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 08:57:14 -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{}
|
||||||
}
|
}
|
||||||
return Element{
|
return Element{
|
||||||
Renderer: &ParagraphElement{},
|
Renderer: &ParagraphElement{
|
||||||
|
First: node.PreviousSibling() == nil,
|
||||||
|
},
|
||||||
Finisher: &ParagraphElement{},
|
Finisher: &ParagraphElement{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ParagraphElement struct {
|
type ParagraphElement struct {
|
||||||
|
First bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ParagraphElement) Render(w io.Writer, ctx RenderContext) error {
|
func (e *ParagraphElement) Render(w io.Writer, ctx RenderContext) error {
|
||||||
bs := ctx.blockStack
|
bs := ctx.blockStack
|
||||||
rules := ctx.options.Styles.Paragraph
|
rules := ctx.options.Styles.Paragraph
|
||||||
|
|
||||||
|
if !e.First {
|
||||||
_, _ = w.Write([]byte("\n"))
|
_, _ = w.Write([]byte("\n"))
|
||||||
|
}
|
||||||
be := BlockElement{
|
be := BlockElement{
|
||||||
Block: &bytes.Buffer{},
|
Block: &bytes.Buffer{},
|
||||||
Style: cascadeStyle(bs.Current().Style, rules, true),
|
Style: cascadeStyle(bs.Current().Style, rules, true),
|
||||||
|
|||||||
Vendored
-1
@@ -1,2 +1 @@
|
|||||||
|
|
||||||
This is a [38;5;200mcode[0m. [0m[0m
|
This is a [38;5;200mcode[0m. [0m[0m
|
||||||
|
|||||||
Vendored
-1
@@ -1,2 +1 @@
|
|||||||
|
|
||||||
This text is [3memphasized[0m. [0m[0m
|
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
|
[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
|
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
|
This text is [1mstrong[0m. [0m[0m
|
||||||
|
|||||||
Reference in New Issue
Block a user