Crates.io | ftml-rpc |
lib.rs | ftml-rpc |
version | 0.0.4 |
source | src |
created_at | 2020-01-25 02:41:09.572118 |
updated_at | 2020-01-27 05:42:16.811456 |
description | Foundation Text Markup Language - an RPC server to provide ftml parsing or rendering |
homepage | |
repository | https://github.com/Nu-SCPTheme/ftml |
max_upload_size | |
id | 201722 |
size | 88,594 |
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.