Skip to content

Instantly share code, notes, and snippets.

@dginev
Last active December 31, 2016 11:20
Show Gist options
  • Save dginev/13f8dffbc73a1907d6941bb653071c7e to your computer and use it in GitHub Desktop.
Save dginev/13f8dffbc73a1907d6941bb653071c7e to your computer and use it in GitHub Desktop.
Rust vs Perl binding syntax example for latexml (12.2016, intermediate)
use package::*;
pub fn load_definitions(state: &mut State) {
SetupBindingMacros!(state);
DefEnvironment!("{alltt}", "<ltx:verbatim font='#font'>#body</ltx:verbatim>",
before_digest => sub!(|stomach, state| {
for c in &['$', '&', '#', '^', '_', '%', '~'] {
AssignCatcode!(*c, Catcode::OTHER, None, state);
}
AssignCatcode!(' ', Catcode::ACTIVE, None, state);
LetI!(T_ACTIVE!(" "), T_CS!("\\space"), None, state);
AssignValue!("PRESERVE_NEWLINES", ObjectStore::Bool(true), None, state);
Vec::new()
}));
}
use LaTeXML::Package;
DefEnvironment('{alltt}', "<ltx:verbatim font='#font'>#body</ltx:verbatim>",
beforeDigest => sub {
map { AssignCatcode($_ => CC_OTHER) } '$', '&', '#', '^', '_', '%', '~';
AssignCatcode(" " => 13);
Let(T_ACTIVE(" "), '\space');
AssignValue(PRESERVE_NEWLINES => 1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment