Simple Tree Text Markup: Simple Markup for Display as Text or in GUI
This is a tree-based combinator library for simple markup, mainly for displaying messages in a REPL. It features horizontal and vertical composition as well as framed markup. Its main distinguishing feature is its ability to embed source locations, which can be rendered as links.
This package comes with separate modules for inspecting and constructing markup - simple-tree-text-markup/data and simple-tree-text-markup/construct, respectively.
There’s also a module simple-tree-text-markup/text that renders markup to text. Rendering markup to GUI is quite context-specific. Hence, the code for rendering to GUIs is implemented with specific applications, such as DrRacket or the test engine.
1 Markup Representation
(require simple-tree-text-markup/data) | |
package: simple-tree-text-markup-lib |
This module defines the representation for markup as a set of struct definitions. It should be required when inspecting markup, For constructing markup, see simple-tree-text-markup/construct.
A markup object can be one of the following:
a string
an empty-markup
procedure
(markup? object) → boolean?
object : any
struct
(struct empty-markup ())
struct
(struct horizontal-markup (markups))
markups : (listof markup?)
struct
(struct vertical-markup (markups))
markups : (listof markup?)
struct
(struct srcloc-markup (srcloc markup))
srcloc : srcloc? markup : markup?
struct
(struct framed-markup (markup))
markup : markup?
2 Markup Construction
(require simple-tree-text-markup/construct) | |
package: simple-tree-text-markup-lib |
While the struct definitions in simple-tree-text-markup/data can also be used for constructing markup, the procedures exported here are somewhat more convenient to use, and do a fair amount of normalization upon constructions.
procedure
(srcloc-markup srcloc markup) → markup?
srcloc : srcloc? markup : markup?
procedure
(framed-markup markup) → markup?
markup : markup?
value
empty-markup : markup?
value
empty-line : markup?
procedure
(horizontal markup ...) → markup?
markup : markup?
procedure
(vertical markup ...) → markup?
markup : markup?
3 Rendering Markup to Text
(require simple-tree-text-markup/text) | |
package: simple-tree-text-markup-lib |
This module renders markup to text by printing to a port.
procedure
(display-markup markup [output-port]) → any
markup : markup? output-port : output-port? = (current-output-port)