Last active
December 31, 2016 11:20
-
-
Save dginev/13f8dffbc73a1907d6941bb653071c7e to your computer and use it in GitHub Desktop.
Rust vs Perl binding syntax example for latexml (12.2016, intermediate)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
})); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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