# mdplayscript An extension of Markdown for play scripts This crate is a parser of an extension of Markdown for stage play scripts. It defines an extended grammar of texts in paragraphs. It is implemented as a filter for `struct Parser` of pulldown-cmark crate. The goal of this parser is to emit an HTML document. Thus it is recommended to pass the parser to `pulldown_cmark::html::push_html` or `write_html`. This crate has an implementation of mdbook preprocessor: [mdbook-playscript](https://github.com/ShotaroTsuji/mdbook-playscript). ## Example ### Play Script Format A line starts with a string and a right angle denotes a character's speech. The text before the right angle is the character name and the text after the right angle is the speech of the character. ```ignore A> Hello! ``` A text between a pair of parentheses in a speech is the content of a direction. ```ignore A> Hello! (some direction) ``` A direction can be placed after the character name. No space is allowed between the right parenthesis and the right angle. ```ignore A (running)> Hello! ``` ### Directives Directives are written as HTML comments. There are four directives: - playscript-on - playscript-off - playscript-monologue-begin - playscript-monologue-end `` and `` switch the parser on and off respectively. Monologues are surrounded by the directives: `` and ``. The texts surrounded by the monologue directives are styled in the normal font style and the directions between the directives are styled in italic. Other forms of texts are handled as normal paragraphs. The examples above are converted into the following HTML: ```rust use pulldown_cmark::Parser; use pulldown_cmark::html::push_html; use mdplayscript::MdPlayScript; fn convert(s: &str) -> String { let p = MdPlayScript::new(Parser::new(s)); let mut buf = String::new(); push_html(&mut buf, p); buf } assert_eq!(convert("A> Hello!"), r##"
Hello!
Hello!some direction
Hello!
Monologuedirection