Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v1 source pure

Package render is the Remix Lab rendering block: escaping for untrusted text, Markdown tables, paginated lists, route...

Overview

Package render is the Remix Lab rendering block: escaping for untrusted text, Markdown tables, paginated lists, route parsing and gnoweb transaction links.

Every string that came from a user must pass through Text or Paragraph before it reaches Markdown. Escaped output cannot open links, images, HTML, headings, tables, code spans, bare URLs or @mentions. (gnoweb still links a bare g1 address; that target is a first-party user page.) Invisible and direction-changing format characters are dropped.

Functions 16

func Code

1func Code(s string) string
source

Code renders s as an inline code span that cannot be closed early. Control characters become spaces, format characters are dropped, and "|" becomes "¦" so the span is also safe inside a table cell.

func Heading

1func Heading(level int, text string) string
source

Heading returns a Markdown heading with escaped text. level is clamped to 1..6.

func Page

1func Page(q url.Values, maxPage int) int
source

Page reads a 1-based "page" query value, clamped to 1..maxPage (a maxPage below 1 counts as 1).

func PageCount

1func PageCount(total, pageSize int) int
source

PageCount returns the number of pages needed for total items.

func Pager

1func Pager(pkgPath, route string, page, pages int) string
source

Pager renders previous/next links for a paginated route under pkgPath. page is clamped to 1..pages.

func Paragraph

1func Paragraph(s string) string
source

Paragraph escapes multi-line text, keeping line breaks as hard breaks. Leading indentation is removed so no line becomes a code block.

func ParsePath

1func ParsePath(path string) ([]string, url.Values)
source

ParsePath splits a render path such as "polls/3?page=2" into its route segments and query values. Malformed queries yield empty values.

func RealmQueryURL

1func RealmQueryURL(pkgPath, route string, kv ...string) string
source

RealmQueryURL is RealmURL with query parameters: keys must be Go identifiers and values are URL-encoded, so any value (including "&", "=" or "%") reaches Render intact through ParsePath. route itself must not contain "?". It returns "" on invalid input.

func RealmURL

1func RealmURL(pkgPath, renderPath string) string
source

RealmURL turns a package path into the realm-relative URL gnoweb serves, optionally with a render path: RealmURL("gno.land/r/a/b", "polls/1") -> "/r/a/b:polls/1".

func Row

1func Row(cells ...string) []string
source

Row escapes every cell.

func Table

1func Table(headers []string, rows [][]string) string
source

Table renders a Markdown table. Headers are escaped with Text. Row cells are NOT escaped: build rows with Row (untrusted text) or TrustedRow (markup from Link, TxLink, Code). As a last line of defence every cell has line breaks replaced and unescaped "|" escaped, so a cell can never split the row or end the table. Rows shorter than the header are padded; longer rows are truncated.

func Text

1func Text(s string) string
source

Text escapes s for inline Markdown. Newlines and control characters become spaces, invisible and direction-changing format characters are dropped, every ASCII punctuation character Markdown or gnoweb could interpret is backslash-escaped, and "<", ">" and "&" become entities.

func TrustedRow

1func TrustedRow(cells ...string) []string
source

TrustedRow marks a row whose cells were already built from escaped text and trusted markup (for example links from Link or TxLink). Use Row for untrusted cells.

func TxURL

1func TxURL(pkgPath, fn string, kv ...string) string
source

TxURL builds the gnoweb "$help" URL used by TxLink, or "" when the input is invalid.

Dependencies

Imports 3

/p/g1lnkytfqcjwllws63gvf0mv9yt04aswy4y9amhm/remixlab/render/v1

Imported by indexer

Source Files 2