-- root URL for links define: docs-root as: "" -- current pretty-printer indentation level define: indent-level as: 0 -- allow multiline pretty-printing define: multiline-pretty? as: False -- context for a pretty-print define: context as: @top -- output as values? (i.e. instead of 1 + 1) define: value-output? as: False -- indent s up to the current indentation level indented: (s: String) := ($ repeat: (indent-level * 2)) .. s -- an empty line, followed by (indentation - 1) indentation unindent := "\n" .. ($ repeat: ((indent-level - 1) * 2)) -- default pretty-printer; just do @show (a: A) pretty: o := a highlight: o show (a: A) pretty: (e: Expression) := if: value-output? then: { a highlight: e show } else: { a highlight: e pretty-expression render } -- find a url for an expression, and link it with t as the text (a: A) linked: (e: Expression) as: (t: String) := a (url-for: e) match: { @none -> t escape @(ok: u) -> t escape in-tag: ("a href=\"" .. docs-root .. u .. "\"") }