diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-07-14 17:46:51 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-07-14 17:46:51 +0200 |
commit | f3371fc97016a6012433319c46f3945fbfaeb9fc (patch) | |
tree | a46ea7dd24bf8f7f607b90eb49f130aec03e7d8f | |
parent | 8183323c432fc1359c634feb68bc372e13f0bd03 (diff) | |
download | markdown-rs-f3371fc97016a6012433319c46f3945fbfaeb9fc.tar.gz markdown-rs-f3371fc97016a6012433319c46f3945fbfaeb9fc.tar.bz2 markdown-rs-f3371fc97016a6012433319c46f3945fbfaeb9fc.zip |
Fix html (flow) whitespace again
Diffstat (limited to '')
-rw-r--r-- | src/construct/html_flow.rs | 13 | ||||
-rw-r--r-- | tests/html_flow.rs | 84 |
2 files changed, 51 insertions, 46 deletions
diff --git a/src/construct/html_flow.rs b/src/construct/html_flow.rs index 3300d2f..c749679 100644 --- a/src/construct/html_flow.rs +++ b/src/construct/html_flow.rs @@ -102,7 +102,7 @@ use crate::constant::{HTML_BLOCK_NAMES, HTML_RAW_NAMES, HTML_RAW_SIZE_MAX, TAB_S use crate::construct::{ blank_line::start as blank_line, partial_non_lazy_continuation::start as partial_non_lazy_continuation, - partial_space_or_tab::space_or_tab_min_max, + partial_space_or_tab::{space_or_tab_with_options, Options as SpaceOrTabOptions}, }; use crate::token::Token; use crate::tokenizer::{Code, State, StateFnResult, Tokenizer}; @@ -208,7 +208,16 @@ struct Info { pub fn start(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { tokenizer.enter(Token::HtmlFlow); // To do: allow arbitrary when code (indented) is turned off. - tokenizer.go(space_or_tab_min_max(0, TAB_SIZE - 1), before)(tokenizer, code) + tokenizer.go( + space_or_tab_with_options(SpaceOrTabOptions { + kind: Token::HtmlFlowData, + min: 0, + max: TAB_SIZE - 1, + connect: false, + content_type: None, + }), + before, + )(tokenizer, code) } /// After optional whitespace, before `<`. diff --git a/tests/html_flow.rs b/tests/html_flow.rs index 6f32133..d35a570 100644 --- a/tests/html_flow.rs +++ b/tests/html_flow.rs @@ -244,12 +244,11 @@ fn html_flow_2_comment() { "should end a comment at four dashes (`---->`)" ); - // To do: html (flow) whitespace. - // assert_eq!( - // micromark_with_options(" <!-- foo -->", DANGER), - // " <!-- foo -->", - // "should support comments w/ indent" - // ); + assert_eq!( + micromark_with_options(" <!-- foo -->", DANGER), + " <!-- foo -->", + "should support comments w/ indent" + ); assert_eq!( micromark_with_options(" <!-- foo -->", DANGER), @@ -481,12 +480,11 @@ okay.", "should support html of type 6 (1)" ); - // To do: html (flow) whitespace. - // assert_eq!( - // micromark_with_options(" <div>\n *hello*\n <foo><a>", DANGER), - // " <div>\n *hello*\n <foo><a>", - // "should support html of type 6 (2)" - // ); + assert_eq!( + micromark_with_options(" <div>\n *hello*\n <foo><a>", DANGER), + " <div>\n *hello*\n <foo><a>", + "should support html of type 6 (2)" + ); assert_eq!( micromark_with_options("</div>\n*foo*", DANGER), @@ -566,12 +564,11 @@ okay.", "should support basic tags w/o ending in containers (2)" ); - // To do: html (flow) whitespace. - // assert_eq!( - // micromark_with_options(" <div>", DANGER), - // " <div>", - // "should support basic tags w/ indent" - // ); + assert_eq!( + micromark_with_options(" <div>", DANGER), + " <div>", + "should support basic tags w/ indent" + ); assert_eq!( micromark_with_options(" <div>", DANGER), @@ -612,32 +609,31 @@ okay.", "should support blank lines between adjacent html" ); - // To do: html (flow) whitespace. - // assert_eq!( - // micromark_with_options( - // "<table> - - // <tr> - - // <td> - // Hi - // </td> - - // </tr> - - // </table>", - // DANGER - // ), - // "<table> - // <tr> - // <pre><code><td> - // Hi - // </td> - // </code></pre> - // </tr> - // </table>", - // "should not support indented, blank-line delimited, adjacent html" - // ); + assert_eq!( + micromark_with_options( + "<table> + + <tr> + + <td> + Hi + </td> + + </tr> + +</table>", + DANGER + ), + "<table> + <tr> +<pre><code><td> + Hi +</td> +</code></pre> + </tr> +</table>", + "should not support indented, blank-line delimited, adjacent html" + ); assert_eq!( micromark_with_options("</1>", DANGER), |