Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,7 @@ func extractPlainText(node ast.Node, source []byte) (string, error) {
var buf bytes.Buffer
for child := node.FirstChild(); child != nil; child = child.NextSibling() {
if text, ok := child.(*ast.Text); ok {
if buf.Len() > 0 {
if _, err := buf.WriteRune(' '); err != nil {
return "", fmt.Errorf("buf.WriteRune: %w", err)
}
}
if _, err := buf.Write(bytes.TrimSpace(text.Value(source))); err != nil {
if _, err := buf.Write(text.Value(source)); err != nil {
return "", fmt.Errorf("buf.Write: %w", err)
}
} else {
Expand All @@ -901,7 +896,7 @@ func extractPlainText(node ast.Node, source []byte) (string, error) {
buf.WriteString(childText)
}
}
return buf.String(), nil
return strings.TrimSpace(buf.String()), nil
}

// extractRawMarkdown extracts raw source for a block node, preserving markdown syntax.
Expand Down
2 changes: 1 addition & 1 deletion testdata/golden/title_inline_formatting.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Title withemphasis andcode",
"title": "Title with emphasis and code",
"description": null,
"yields": [],
"tags": [],
Expand Down