File: render_comment.go

package info (click to toggle)
golang-github-johanneskaufmann-html-to-markdown 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,080 kB
  • sloc: makefile: 3
file content (25 lines) | stat: -rw-r--r-- 654 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package commonmark

import (
	"github.com/JohannesKaufmann/html-to-markdown/v2/converter"
	"github.com/JohannesKaufmann/html-to-markdown/v2/internal/domutils"
	"golang.org/x/net/html"
)

func (c *commonmark) renderComment(_ converter.Context, w converter.Writer, n *html.Node) converter.RenderStatus {

	if n.Data == domutils.ListEndCommentData {
		// We definitely want to render the list end comments
		// that were just added
		w.WriteRune('\n')
		w.WriteRune('\n')
		_ = html.Render(w, n)
		w.WriteRune('\n')
		w.WriteRune('\n')
		return converter.RenderSuccess

	}

	// Fallback to the normal settings for comments
	return converter.RenderTryNext
}