Documentation
¶
Overview ¶
Package renderer converts markdown to HTML with caching and syntax highlighting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service renders markdown into HTML with caching. It uses Goldmark for markdown parsing with GitHub-flavored markdown extensions, syntax highlighting, and automatic link transformation for wiki-style navigation. Rendered documents are cached by path and modification time for improved performance.
func NewService ¶
NewService constructs a markdown renderer with GitHub-flavored markdown support. The renderer includes:
- GitHub-flavored markdown extensions (tables, strikethrough, task lists, autolinks, etc.)
- Syntax highlighting with the github-dark theme
- YAML frontmatter parsing for document metadata
- Automatic link transformation for .md files to /page/ routes
- Raw HTML rendering enabled (safe for local-only wikis)
- Soft line breaks (newlines become spaces, matching GitHub's default behavior)
- Hard line breaks can be created with two trailing spaces or <br> tags
If logger is nil, the default slog logger is used.
func (*Service) Invalidate ¶
Invalidate removes the cached entry for the given path. This should be called when a document is updated or deleted to ensure the next Render call processes the latest content.
func (*Service) Render ¶
func (s *Service) Render(_ context.Context, path string, modTime time.Time, content []byte) (Document, error)
Render converts markdown content to HTML, caching results by path and modification time. If a cached entry exists with a matching modification time, it is returned immediately. Otherwise, the markdown is parsed and rendered, then cached for future requests. The path parameter is used for cache key generation and relative link resolution.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package d2 provides server-side helpers for compiling D2 diagrams into SVG.
|
Package d2 provides server-side helpers for compiling D2 diagrams into SVG. |
|
Package transform provides custom rendering transformations for markdown elements.
|
Package transform provides custom rendering transformations for markdown elements. |