feat: render wml decks with paginated card sub-documents
This commit is contained in:
parent
36b868e094
commit
1de4674b09
17 changed files with 1519 additions and 5 deletions
|
|
@ -29,6 +29,21 @@ pub fn attr(value: &str) -> String {
|
|||
out
|
||||
}
|
||||
|
||||
/// Escape text for WML element content.
|
||||
#[cfg(feature = "wml")]
|
||||
///
|
||||
/// WML reads `$` as the start of a variable reference, so a literal one has to be
|
||||
/// doubled; otherwise a handset would substitute something or fail to parse.
|
||||
pub fn wml(value: &str) -> String {
|
||||
text(value).replace('$', "$$")
|
||||
}
|
||||
|
||||
/// Escape text for a WML attribute value.
|
||||
#[cfg(feature = "wml")]
|
||||
pub fn wml_attr(value: &str) -> String {
|
||||
attr(value).replace('$', "$$")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -41,6 +56,17 @@ mod tests {
|
|||
assert_eq!(attr("say \"hi\" & bye"), "say "hi" & bye");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "wml")]
|
||||
fn wml_doubles_a_literal_dollar() {
|
||||
assert_eq!(wml("Permit fee: $5"), "Permit fee: $$5");
|
||||
assert_eq!(wml("a & $b"), "a & $$b");
|
||||
assert_eq!(wml_attr("/x?a=1&b=$2"), "/x?a=1&b=$$2");
|
||||
// The doubling runs after the markup escape, so an escaped entity is not
|
||||
// itself rewritten.
|
||||
assert_eq!(wml("<$>"), "<$$>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn leaves_ordinary_text_alone() {
|
||||
assert_eq!(text("plain text 123"), "plain text 123");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue