aboutsummaryrefslogtreecommitdiffstats
path: root/src/content/text.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-16 12:55:50 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-16 12:55:50 +0200
commit7350acc692a79d9d4cf56afbc53ac3c9f2a6237c (patch)
tree02f8b83230a40b509adf4b4872e313544c7fc80f /src/content/text.rs
parent58ba69452a25c3d4b2059c01cc6cd837159d2f90 (diff)
downloadmarkdown-rs-7350acc692a79d9d4cf56afbc53ac3c9f2a6237c.tar.gz
markdown-rs-7350acc692a79d9d4cf56afbc53ac3c9f2a6237c.tar.bz2
markdown-rs-7350acc692a79d9d4cf56afbc53ac3c9f2a6237c.zip
Add support for hard break (trailing)
Diffstat (limited to 'src/content/text.rs')
-rw-r--r--src/content/text.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/content/text.rs b/src/content/text.rs
index d4d5493..f61b390 100644
--- a/src/content/text.rs
+++ b/src/content/text.rs
@@ -8,7 +8,8 @@
//! * [Autolink][crate::construct::autolink]
//! * Attention
//! * [HTML (text)][crate::construct::html_text]
-//! * [Hard break escape][crate::construct::hard_break_escape]
+//! * [Hard break (escape)][crate::construct::hard_break_escape]
+//! * [Hard break (trailing)][crate::construct::hard_break_trailing]
//! * [Code (text)][crate::construct::code_text]
//! * Line ending
//! * Label start (image)
@@ -19,7 +20,8 @@
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, html_text::start as html_text,
+ hard_break_escape::start as hard_break_escape,
+ hard_break_trailing::start as hard_break_trailing, html_text::start as html_text,
};
use crate::tokenizer::{Code, State, StateFnResult, TokenType, Tokenizer};
@@ -35,10 +37,11 @@ use crate::tokenizer::{Code, State, StateFnResult, TokenType, Tokenizer};
pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
Code::None => (State::Ok, None),
- _ => tokenizer.attempt_6(
+ _ => tokenizer.attempt_7(
character_reference,
character_escape,
hard_break_escape,
+ hard_break_trailing,
autolink,
html_text,
code_text,
@@ -78,12 +81,12 @@ fn before_data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// ```
fn in_data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
match code {
- Code::None => {
+ Code::None | Code::CarriageReturnLineFeed | Code::Char('\r' | '\n') => {
tokenizer.exit(TokenType::Data);
- (State::Ok, None)
+ before_data(tokenizer, code)
}
// To do: somehow get these markers from constructs.
- Code::CarriageReturnLineFeed | Code::Char('\r' | '\n' | '&' | '<' | '\\' | '`') => {
+ Code::Char(' ' | '&' | '<' | '\\' | '`') => {
tokenizer.exit(TokenType::Data);
start(tokenizer, code)
}