asciidork-parser 0.34.0

Asciidork parser
Documentation
use lazy_static::lazy_static;
use regex::{Regex, bytes::Regex as BytesRegex};

// attrs
lazy_static! {
  pub static ref ATTR_DECL: Regex = Regex::new(r"^:([^\s:]+):\s*([^\s].*)?$").unwrap();
  pub static ref ATTR_VAL_REPLACE: Regex = Regex::new(r"\{([^\s}]+)\}").unwrap();
}

// email
lazy_static! {
  pub static ref EMAIL_RE: Regex = Regex::new(
    r"^([a-z0-9_+]([a-z0-9_+.]*[a-z0-9_+])?)@([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6})"
  )
  .unwrap();
}

// attr def with pass macro wrapping footnote macro
lazy_static! {
  pub static ref PASS_DBL_MACRO_ATTR: Regex =
    Regex::new(r#"^pass:([a-z]+(?:,[a-z-]+)*)?\[footnote:(.*)\]\]$"#).unwrap();
}

// directives
lazy_static! {
  pub static ref DIRECTIVE_INCLUDE: Regex =
    Regex::new(r#"^include::([^\[]+[^\[\s])\[.*\]$"#).unwrap();
  pub static ref DIRECTIVE_IFDEF: Regex =
    Regex::new(r#"^ifn?def::([^\[]+[^\[\s])\[(.*)\]$"#).unwrap();
  pub static ref DIRECTIVE_ENDIF: Regex = Regex::new(r#"^endif::(\S*)\[\]$"#).unwrap();
}

// ifeval directives
lazy_static! {
  pub static ref DIRECTIVE_IFEVAL: Regex =
    Regex::new(r#"^ifeval::(.*?)\[(.+?) *([=!><]=|[><]) *(.+)\]$"#).unwrap();
  pub static ref DIRECTIVE_INVALID_IFEVAL: Regex = Regex::new(r#"^ifeval::(\[(.*)\])$"#).unwrap();
}

// line
lazy_static! {
  pub static ref REPEAT_STAR_LI_START: Regex = Regex::new(r#"^\s?(\*+)( |\t)+.+"#).unwrap();
}

// inlines
lazy_static! {
  pub static ref KBD_MACRO_KEYS: Regex = Regex::new(r"(?:\s*([^\s,+]+|[,+])\s*)").unwrap();
}

// image
lazy_static! {
  pub static ref SVG_TARGET: Regex = Regex::new(r"(?i)\.svg(\[|\?|$)").unwrap();
}

// inline svg
lazy_static! {
  pub static ref SVG_PREAMBLE: BytesRegex = BytesRegex::new(r"(?s)^(.*)<svg").unwrap();
  pub static ref SVG_START_TAG: BytesRegex = BytesRegex::new(r"<svg").unwrap();
  pub static ref SVG_STRIP_ATTRS: BytesRegex =
    BytesRegex::new(r#"(?s)\s(?:width|height|style)=("([^"]*)"|'([^']*)')"#).unwrap();
}