Help us shape the future of Go! Take the 2026 Go Developer Survey

render

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package render wraps untrusted document HTML in the page that hosts it for the slashdocs app: a sandboxed iframe and the bridge that connects the document to comments, the theme, and document KV. The server and `slashdocs local` use it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSP

func CSP(appOrigin string) string

CSP is the Content-Security-Policy of a wrapper page. Documents can load any resource, but only appOrigin can frame them.

func ValidateBridge

func ValidateBridge(sourceHash string) error

ValidateBridge rejects an embedded bridge that is absent, stale, or corrupt. sourceHash is the fingerprint of every TypeScript source under frontend/bridge/ at build time, so a change to any bridge module invalidates an outdated bundle.

func Wrap

func Wrap(userHTML []byte, appOrigin string) []byte

Wrap returns the full wrapper page that embeds userHTML inside a sandboxed iframe. The bridge sends its messages only to appOrigin.

Types

type Heading

type Heading struct {
	ID    string `json:"id"`
	Text  string `json:"text"`
	Level int    `json:"level"`
}

Heading is a heading of a document, with the ID that the viewer gives it.

func Headings

func Headings(raw []byte) ([]Heading, error)

Headings mirrors bridge prepareHeadings: reserve every author ID first, then suffix generated IDs until unique. The source HTML is never changed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL