Skip to content

Commit

Permalink
Comply with Gemini spec p. 5.4.1
Browse files Browse the repository at this point in the history
This part of spec says soft text wrapping is preferred to hard wrapping,
to comply with that we replace the newlines in raw Markdown text with
spaces.
  • Loading branch information
tdemin committed Nov 11, 2020
1 parent 637ff4b commit 35b4168
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/gemini/renderer.go
Expand Up @@ -22,6 +22,7 @@ import (
"bytes"
"fmt"
"io"
"strings"
"time"

"github.com/gomarkdown/markdown/ast"
Expand Down Expand Up @@ -266,7 +267,9 @@ func (r Renderer) list(w io.Writer, node *ast.List, level int) {

func (r Renderer) text(w io.Writer, node ast.Node) {
if node := node.AsLeaf(); node != nil {
w.Write(node.Literal)
// replace all newlines in text with spaces, allowing for soft
// wrapping; this is recommended as per Gemini spec p. 5.4.1
w.Write([]byte(strings.ReplaceAll(string(node.Literal), "\n", " ")))
}
}

Expand Down

0 comments on commit 35b4168

Please sign in to comment.