#wikidot #parsing #rendering #html #ftml

yanked ftml-rpc

Foundation Text Markup Language - an RPC server to provide ftml parsing or rendering

0.0.4 Jan 27, 2020
0.0.3 Jan 25, 2020
0.0.2 Jan 25, 2020
0.0.1 Jan 25, 2020

#5 in #scp-foundation


369 lines


An RPC server and client for ftml calls. See the relevant crate documentation for more information on "Foundation Text Markup Language".

Currently it does not connect to a DEEPWELL server for necessary external information (other pages, users, etc.), but will in the future.


This crate targets the latest stable Rust. At time of writing, that is 1.40.0

$ cargo build --release
$ cargo run --release -- [arguments] # server

If you wish to use its client, import the crate and use it as a library.


Currently, all errors are transmitted as Err(String).

The current API provided by the RPC server is as follows:

protocol() -> io::Result<String>:
Returns a static protocol version. Currently "0".

ping() -> io::Result<()>:
Determines if the server is reachable.

time() -> io::Result<f64>:
Returns the system time on the server. It may be in any timezone and is not monotonic.

Followed by the three core ftml methods:

prefilter(input: String) -> io::Result<Result<String, String>>:
Preprocesses the text prior to parsing or rendering. This will load any includes or perform typographic transformations. See ftml Usage for more information.

parse(input: String) -> io::Result<Result<String, String>>:
Prefilters and then parses the input string, returning a JSON object corresponding to the syntax tree. This is currently not typed in code, but follows the object pattern in ftml's SyntaxTree.

render(page_info: PageInfoOwned, input: String) -> io::Result<Result<HtmlOutput, String>>:
Prefilters, parses, and renders the page into HTML. The definition of the HtmlOutput object is available here, though most notable are the html field containing partial HTML (i.e. not including tags like <html> or <body>), and style, which contains any generated CSS.

The argument of type PageInfoOwned passes in information about the article being rendered.


~293K SLoC