aboutsummaryrefslogtreecommitdiffstats
path: root/src/content/text.rs
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-14 18:57:28 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-06-14 18:57:28 +0200
commitb00fafbdcba39e7e17144b07834702629b891062 (patch)
tree3351cc3ad2bb126d8a93e1ff6b1731bc00cb45c3 /src/content/text.rs
parent129ea34b18aaf7f5a01d404effbdc78cbbe67a74 (diff)
downloadmarkdown-rs-b00fafbdcba39e7e17144b07834702629b891062.tar.gz
markdown-rs-b00fafbdcba39e7e17144b07834702629b891062.tar.bz2
markdown-rs-b00fafbdcba39e7e17144b07834702629b891062.zip
Fix support for deep subtokenization
* Fix a couple of forgotten line ending handling in html (text) * Fix missing initial case for html (text) not having a `<` 😬 * Add line ending handling to `text` construct
Diffstat (limited to '')
-rw-r--r--src/content/text.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/content/text.rs b/src/content/text.rs
index 73c2d55..433d030 100644
--- a/src/content/text.rs
+++ b/src/content/text.rs
@@ -52,12 +52,19 @@ pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
/// |qwe
/// ```
fn before_data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
- if let Code::None = code {
- (State::Ok, None)
- } else {
- tokenizer.enter(TokenType::Data);
- tokenizer.consume(code);
- (State::Fn(Box::new(in_data)), None)
+ match code {
+ Code::None => (State::Ok, None),
+ Code::CarriageReturnLineFeed | Code::Char('\r' | '\n') => {
+ tokenizer.enter(TokenType::LineEnding);
+ tokenizer.consume(code);
+ tokenizer.exit(TokenType::LineEnding);
+ (State::Fn(Box::new(start)), None)
+ }
+ _ => {
+ tokenizer.enter(TokenType::Data);
+ tokenizer.consume(code);
+ (State::Fn(Box::new(in_data)), None)
+ }
}
}
@@ -73,7 +80,7 @@ fn in_data(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult {
(State::Ok, None)
}
// To do: somehow get these markers from constructs.
- Code::Char('&' | '\\' | '<') => {
+ Code::CarriageReturnLineFeed | Code::Char('\r' | '\n' | '&' | '\\' | '<') => {
tokenizer.exit(TokenType::Data);
start(tokenizer, code)
}