Documentation
¶
Index ¶
- Constants
- func BuildPageSVGDefsCSS(pageSlug string, pageStyle psrt.Style) string
- func BuildPageStylesheet(pageSlug string, pageStyle psrt.Style, texts []psrt.Text, canvasW, canvasH int, ...) string
- func BuildPageTextStylesheet(pageSlug string, pageStyle psrt.Style, texts []psrt.Text, canvasW, canvasH int, ...) string
- func FormatInt(n int) string
- func ImageDimensions(body []byte, mime string) (w, h int)
- func IsImageMIME(mime string) bool
- func MaskBlockGeometry(m *psrt.Mask, canvasW, canvasH int) (x, y, width, height int)
- func PageBgClass(slug string) string
- func PageBgID(slug string) string
- func PageClass(slug string) string
- func PageID(slug string) string
- func PageImageID(slug string) string
- func PageTextsID(slug string) string
- func PathMaskBlockGeometry(m *psrt.PathMask, canvasW, canvasH int) (x, y, width, height int)
- func PathMaskClipID(slug string, index int) string
- func PathMaskID(slug string, index int) string
- func PathMaskWrapID(slug string, index int) string
- func RenderPageSVG(p *psrt.Page, pageSlug string, fontURLs []string, ...) ([]byte, error)
- func ResolveDocument(doc psrt.Document) psrt.Document
- func ResolveDocumentKeepInteractive(doc psrt.Document) psrt.Document
- func ResolveDocumentStrict(doc psrt.Document) (psrt.Document, error)
- func ResolveDocumentStrictKeepInteractive(doc psrt.Document) (psrt.Document, error)
- func Slug(name string) string
- func TextA11yID(slug string, index int) string
- func TextBgClass(slug string, index int) string
- func TextBgID(slug string, index int) string
- func TextBlockGeometry(t *psrt.Text, content string, canvasW, canvasH int) (x, y, width, height int)
- func TextClass(slug string, index int) string
- func TextClassAttr(pageSlug string, index int) string
- func TextGlyphsID(slug string, index int) string
- func TextID(slug string, index int) string
- func TextInnerClass(slug string, index int) string
- func TextWrapID(slug string, index int) string
- func UniqueSlugs(pages []string) []string
- type CompileResult
- func Compile(doc psrt.Document, client *http.Client, outDir string) (CompileResult, error)
- func CompileWithCache(ctx context.Context, doc psrt.Document, client *http.Client, outDir string, ...) (CompileResult, error)
- func CompileWithOptions(ctx context.Context, doc psrt.Document, client *http.Client, outDir string, ...) (CompileResult, error)
- type PageSVGResult
- func CompilePageSVG(ctx context.Context, doc psrt.Document, pageName string, client *http.Client, ...) (PageSVGResult, error)
- func CompilePageSVGWithOptions(ctx context.Context, doc psrt.Document, pageName string, client *http.Client, ...) (PageSVGResult, error)
- func RenderPageSVGWithContext(ctx context.Context, p *psrt.Page, pageSlug string, fontURLs []string, ...) (PageSVGResult, error)
Constants ¶
const GoTextFallbackNotice = "Compilação SVG com motor go-text (Chromium não encontrado). Pode haver pequenas diferenças em relação ao preview."
GoTextFallbackNotice is shown in the GUI when the go-text fallback is used.
Variables ¶
This section is empty.
Functions ¶
func BuildPageSVGDefsCSS ¶
BuildPageSVGDefsCSS returns minimal CSS embedded in compiled SVG (page background only).
func BuildPageStylesheet ¶
func BuildPageStylesheet( pageSlug string, pageStyle psrt.Style, texts []psrt.Text, canvasW, canvasH int, fontURLs []string, assets map[string]compileasset.Asset, ) string
BuildPageStylesheet returns the full CSS for one page (font-face, page class, text classes).
func BuildPageTextStylesheet ¶
func BuildPageTextStylesheet( pageSlug string, pageStyle psrt.Style, texts []psrt.Text, canvasW, canvasH int, fontURLs []string, assets map[string]compileasset.Asset, ) string
BuildPageTextStylesheet returns CSS for headless text layout (font-face + text block rules).
func ImageDimensions ¶
ImageDimensions returns width and height from image bytes, or defaults on failure.
func IsImageMIME ¶
IsImageMIME reports whether mime is an image type.
func MaskBlockGeometry ¶
MaskBlockGeometry maps mask percent coords to a pixel rect (fixed height, no text metrics).
func PageBgClass ¶
PageBgClass returns the background rect class name.
func PageImageID ¶
PageImageID returns the page background image id.
func PathMaskBlockGeometry ¶
PathMaskBlockGeometry maps ~~ percent coords to a pixel rect for the nested <svg viewBox="0 0 100 100"> wrapper (same percent->pixel conversion as MaskBlockGeometry; the path's own 0-100 coordinates are left untouched and scaled by the nested viewBox, including non-uniformly when Width != Height).
func PathMaskClipID ¶
PathMaskClipID returns the clipPath id used to clip a ~~ block's image-ref.
func PathMaskID ¶
PathMaskID returns the standardized ~~ block id.
func PathMaskWrapID ¶
PathMaskWrapID returns the wrapper group id for a ~~ block.
func RenderPageSVG ¶
func RenderPageSVG( p *psrt.Page, pageSlug string, fontURLs []string, assets map[string]compileasset.Asset, ) ([]byte, error)
RenderPageSVG produces a standalone SVG for one page.
func ResolveDocument ¶
ResolveDocument expands all @const@ placeholders in styles, content, and URLs, collapsing interactive consts to their render text (universal SVG/HTML output).
func ResolveDocumentKeepInteractive ¶ added in v1.4.0
ResolveDocumentKeepInteractive expands plain consts but leaves @type:render@ tokens intact, for interactive readers (e.g. react-image) that render them.
func ResolveDocumentStrict ¶
ResolveDocumentStrict is like ResolveDocument but returns an error on invalid style JSON.
func ResolveDocumentStrictKeepInteractive ¶ added in v1.4.0
ResolveDocumentStrictKeepInteractive is ResolveDocumentKeepInteractive with strict style validation.
func TextA11yID ¶
TextA11yID returns the hidden accessibility text element id.
func TextBgClass ¶
TextBgClass returns the CSS class for the text background rect.
func TextBlockGeometry ¶
func TextBlockGeometry(t *psrt.Text, content string, canvasW, canvasH int) (x, y, width, height int)
TextBlockGeometry maps PSRT percent coords to a pixel rect for layout (SVG foreignObject / HTML text-layer). x, y, width match the editor/web border box (box-sizing: border-box); height includes vertical padding.
func TextClassAttr ¶
TextClassAttr returns both page and text classes for cascade (page first, text second).
func TextGlyphsID ¶
TextGlyphsID returns the group id wrapping outlined text paths.
func TextInnerClass ¶
TextInnerClass is the inner span that holds inline markup inside a flex foreignObject div.
func TextWrapID ¶
TextWrapID returns the wrapper group id (rect + glyph paths).
func UniqueSlugs ¶
UniqueSlugs assigns a unique slug per page name (suffix -2, -3 on collision).
Types ¶
type CompileResult ¶
type CompileResult struct {
UsedGoTextFallback bool
}
CompileResult holds batch SVG compile output metadata.
func CompileWithCache ¶
func CompileWithCache(ctx context.Context, doc psrt.Document, client *http.Client, outDir string, store *cache.Store) (CompileResult, error)
CompileWithCache uses local asset cache when store is non-nil.
func CompileWithOptions ¶
func CompileWithOptions(ctx context.Context, doc psrt.Document, client *http.Client, outDir string, store *cache.Store, opts compileopts.Options) (CompileResult, error)
CompileWithOptions compiles all pages to SVG files with shared compile flags.
type PageSVGResult ¶
PageSVGResult is the output of rendering one page to SVG.
func CompilePageSVG ¶
func CompilePageSVG(ctx context.Context, doc psrt.Document, pageName string, client *http.Client, store *cache.Store) (PageSVGResult, error)
CompilePageSVG returns SVG bytes for a single page by name.
func CompilePageSVGWithOptions ¶
func CompilePageSVGWithOptions(ctx context.Context, doc psrt.Document, pageName string, client *http.Client, store *cache.Store, opts compileopts.Options) (PageSVGResult, error)
CompilePageSVGWithOptions compiles one page to SVG with compile flags.
func RenderPageSVGWithContext ¶
func RenderPageSVGWithContext( ctx context.Context, p *psrt.Page, pageSlug string, fontURLs []string, assets map[string]compileasset.Asset, opts compileopts.Options, ) (PageSVGResult, error)
RenderPageSVGWithContext compiles one page using ctx for text outlining.