Crate ftml[][src]

Expand description

A library to parse Wikidot text and produce an abstract syntax tree (AST).

This library aims to be a replacement of Wikidot’s Text_Wiki parser, which is presently a loose group of regular expressions (with irregular Perl extensions). The aim is to provide an AST while also maintaining the flexibility and lax parsing that Wikidot permits.

The overall flow is the following:

  • Run messy includer
  • Run preprocessor
  • Run tokenizer
  • Run parser
  • Run renderer

Each step of the flow makes extensive use of Rust’s borrowing capabilities, ensuring that as few allocations are performed as possible. Any strings which are unmodified are passed by reference. Despite this, all of the exported structures are both serializable and deserializable via serde.

Rendering is performed by the trait Render. There are two main implementations of note, TextRender and HtmlRender, which render to plain text and full HTML respectively.

Features

This crate has several features of note.

By default the ffi and log features are enabled. These enable support for FFI interfacing for the library via cbindgen (with a slightly more limited interface), and logging via slog respectively.

If the log feature is enabled, then all calls requiring a Logger are replaced with a stub, and all actual logging calls are replaced with no-ops. Generally you want this for very performance-sensitive contexts where logging is simply not worth the overhead.

Targets

The library supports being compiled into WebAssembly. (target wasm32-unknown-unknown, see wasm-pack for more information)

This adds the feature wasm-log, which adds slog logging support via console.log() calls to the browser’s console. This is very useful for debugging, but caveat emptor! This spams the console very hard and can cause lag on some browsers. Do not enable in production.

Additionally, disabling log as a feature compiles out all logging, similar to the default target.

Compiling to wasm also disables all FFI integration, since these are inherently incompatible.

Bugs

If you discover any bugs or have any feature requests, you can submit them via our Atlassian helpdesk here.

Alternatively, you can get in touch with Wikijump developers directly.

Re-exports

pub use self::includes::include;
pub use self::parsing::parse;
pub use self::tokenizer::tokenize;
pub use self::tokenizer::Tokenization;

Modules

Structs

Metadata information on the article being rendered.

Returned information about a user.

Constants

Functions

Run the preprocessor on the given wikitext, which is modified in-place.