From faca28020f4894bdfcf5a4b164ebbc75864d8776 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 4 Jul 2022 12:16:51 +0200 Subject: Add support for attention (emphasis, strong) --- src/content/text.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/content') diff --git a/src/content/text.rs b/src/content/text.rs index c3f4e1b..ecb6ae1 100644 --- a/src/content/text.rs +++ b/src/content/text.rs @@ -1,12 +1,13 @@ //! The text content type. //! -//! **Text** contains phrasing content such as attention (emphasis, strong), -//! media (links, images), and actual text. +//! **Text** contains phrasing content such as +//! [attention][crate::construct::attention] (emphasis, strong), +//! [code (text)][crate::construct::code_text], and actual text. //! //! The constructs found in text are: //! +//! * [Attention][crate::construct::attention] //! * [Autolink][crate::construct::autolink] -//! * Attention //! * [HTML (text)][crate::construct::html_text] //! * [Hard break (escape)][crate::construct::hard_break_escape] //! * [Hard break (trailing)][crate::construct::hard_break_trailing] @@ -18,9 +19,9 @@ //! * [Character reference][crate::construct::character_reference] use crate::construct::{ - autolink::start as autolink, character_escape::start as character_escape, - character_reference::start as character_reference, code_text::start as code_text, - hard_break_escape::start as hard_break_escape, + attention::start as attention, autolink::start as autolink, + character_escape::start as character_escape, character_reference::start as character_reference, + code_text::start as code_text, hard_break_escape::start as hard_break_escape, hard_break_trailing::start as hard_break_trailing, html_text::start as html_text, label_end::start as label_end, label_start_image::start as label_start_image, label_start_link::start as label_start_link, partial_data::start as data, @@ -28,16 +29,18 @@ use crate::construct::{ }; use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; -const MARKERS: [Code; 10] = [ +const MARKERS: [Code; 12] = [ Code::VirtualSpace, // `whitespace` Code::Char('\t'), // `whitespace` Code::Char(' '), // `hard_break_trailing`, `whitespace` Code::Char('!'), // `label_start_image` Code::Char('&'), // `character_reference` + Code::Char('*'), // `attention` Code::Char('<'), // `autolink`, `html_text` Code::Char('['), // `label_start_link` Code::Char('\\'), // `character_escape`, `hard_break_escape` Code::Char(']'), // `label_end` + Code::Char('_'), // `attention` Code::Char('`'), // `code_text` ]; @@ -55,6 +58,7 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { Code::None => (State::Ok, None), _ => tokenizer.attempt_n( vec![ + Box::new(attention), Box::new(autolink), Box::new(character_escape), Box::new(character_reference), -- cgit