textile/parser/
patterns.rs

1use regex::Regex;
2
3lazy_static! {
4    pub static ref BLOCK_QUOTATION_PATTERN: Regex = Regex::new("^bq(?P<attributes>.*?)(?P<mode>\\.{1,2})(?::(?P<cite>.+?))? ").unwrap();
5    pub static ref CODE_BLOCK_PATTERN: Regex = Regex::new("^bc(?P<attributes>.*?)(?P<mode>\\.{1,2}) ").unwrap();
6    pub static ref COMMENT_PATTERN: Regex = Regex::new("^#{3}(?P<mode>\\.{1,2}) ").unwrap();
7    pub static ref HEADING_PATTERN: Regex = Regex::new("^h(?P<level>[1-6])(?P<attributes>.*)\\. ").unwrap();
8    pub static ref NO_TEXTILE_BLOCK_PATTERN: Regex = Regex::new("^notextile(?P<mode>\\.{1,2}) ").unwrap();
9    pub static ref PARAGRAPH_PATTERN: Regex = Regex::new("(?:^p(?P<attributes>.*)\\. )?").unwrap();
10    pub static ref PRE_PATTERN: Regex = Regex::new("^pre(?P<attributes>.*?)(?P<mode>\\.{1,2}) ").unwrap();
11
12    pub static ref ABBREVIATION_PATTERN: Regex = Regex::new(r"^(?P<abbreviation>\p{Lu}{3,})(?:\((?P<transcript>.*?)\))?").unwrap();
13    pub static ref BOLD_TEXT_PATTERN: Regex = Regex::new(r"^(?P<count1>\*+)(?P<string>.+?)(?P<count2>\*+)").unwrap();
14    pub static ref CITATION_PATTERN: Regex = Regex::new(r"^\?\?(?P<string>.+?)\?\?").unwrap();
15    pub static ref CODE_PATTERN: Regex = Regex::new("^@(?P<code>.*?)@").unwrap();
16    pub static ref IMAGE_PATTERN: Regex = Regex::new("^!(?P<align>[<|>|=]?)(?P<string>.+?)!(?::(?P<href>[^ \\(\\)]+))?").unwrap();
17    pub static ref IMAGE_ALT_PATTERN: Regex = Regex::new("(?:\\(([^\\(\\)]+)\\))?$").unwrap();
18    pub static ref ITALIC_TEXT_PATTERN: Regex = Regex::new("^(?P<count1>_+)(?P<string>.+?)(?P<count2>_+)").unwrap();
19    pub static ref LINK_PATTERN: Regex = Regex::new("^\"(?P<string>.+?)\":(?P<href>[^ \\(\\)]+)").unwrap();
20    pub static ref LINK_TITLE_PATTERN: Regex = Regex::new("(?:\\(([^\\(\\)]+)\\))?$").unwrap();
21    pub static ref NO_TEXTILE_INLINE_PATTERN: Regex = Regex::new("^={2}(?P<string>.*?)={2}").unwrap();
22    pub static ref SPAN_PATTERN: Regex = Regex::new("^(?P<count1>%+)(?P<string>.+?)(?P<count2>%+)").unwrap();
23    pub static ref STRIKETHROUGH_TEXT_PATTERN: Regex = Regex::new("^(?P<count1>-+)(?P<string>.+?)(?P<count2>-+)").unwrap();
24    pub static ref SUBSCRIPT_TEXT_PATTERN: Regex = Regex::new("^(?P<count1>~+)(?P<string>.+?)(?P<count2>~+)").unwrap();
25    pub static ref SUPERSCRIPT_TEXT_PATTERN: Regex = Regex::new(r"^(?P<count1>\^+)(?P<string>.+?)(?P<count2>\^+)").unwrap();
26    pub static ref UNDERLINED_TEXT_PATTERN: Regex = Regex::new(r"^(?P<count1>\++)(?P<string>.+?)(?P<count2>\++)").unwrap();
27
28    pub static ref ATTRS_STR_PATTERN: Regex = Regex::new("(?:^([\\[\\{\\(].+?[\\]\\}\\)])*)").unwrap();
29    pub static ref PADDING_PATTERN: Regex = Regex::new("\\(+|\\)+").unwrap();
30    pub static ref ALIGN_PATTERN: Regex = Regex::new("[<|>|=]{1,2}").unwrap();
31    pub static ref LANG_PATTERN: Regex = Regex::new("\\[([A-Za-z]{2}(?:-[A-Za-z]{2})?)\\]").unwrap();
32    pub static ref CLASS_ID_PATTERN: Regex = Regex::new("\\((?P<class>[\\w-_\\. ]+)?(?:#(?P<id>[\\w-_]+))?\\)").unwrap();
33    pub static ref CLASS_STR_SPLIT_PATTERN: Regex = Regex::new(" +").unwrap();
34    pub static ref CSS_PROPS_PATTERN: Regex = Regex::new("\\{([^\\{\\}]+)\\}").unwrap();
35    pub static ref CSS_PROPS_SPLIT_PATTERN: Regex = Regex::new("; *").unwrap();
36    pub static ref CSS_PROP_STR_PATTERN: Regex = Regex::new("(?P<key>[a-z-_]+): *(?P<value>.+)").unwrap();
37}