From be62b2e29a61774100f676cfdd9b100cadf1905f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 30 Jun 2022 16:35:13 +0200 Subject: Add support for trimming whitespace around string, text This commit introduces trimming initial and final whitespace around the whole string or text, or around line endings inside that string or text. * Add `register_resolver_before`, to run resolvers earlier than others, used for labels * Add resolver to merge `data` events, which are the most frequent token that occurs, and can happen adjacently. In `micromark-js` this sped up parsing a lot * Fix a bug where a virtual space was not seen as an okay event * Refactor to enable all turned off whitespace tests --- tests/heading_setext.rs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'tests/heading_setext.rs') diff --git a/tests/heading_setext.rs b/tests/heading_setext.rs index ecf22a8..e7ee9ff 100644 --- a/tests/heading_setext.rs +++ b/tests/heading_setext.rs @@ -24,7 +24,7 @@ fn heading_setext() { // "should support line endings in setext headings" // ); - // To do: attention, trim. + // To do: attention. // assert_eq!( // micromark(" Foo *bar\nbaz*\t\n===="), // "

Foo bar\nbaz

", @@ -85,19 +85,17 @@ fn heading_setext() { "should support whitespace before underline" ); - // To do: trim paragraphs. - // assert_eq!( - // micromark("Foo\n ="), - // "

Foo\n=

", - // "should not support too much whitespace before underline (1)" - // ); + assert_eq!( + micromark("Foo\n ="), + "

Foo\n=

", + "should not support too much whitespace before underline (1)" + ); - // To do: trim paragraphs. - // assert_eq!( - // micromark("Foo\n\t="), - // "

Foo\n=

", - // "should not support too much whitespace before underline (2)" - // ); + assert_eq!( + micromark("Foo\n\t="), + "

Foo\n=

", + "should not support too much whitespace before underline (2)" + ); assert_eq!( micromark("Foo\n= ="), @@ -111,12 +109,11 @@ fn heading_setext() { "should not support whitespace in the underline (2)" ); - // To do: trim setext. - // assert_eq!( - // micromark("Foo \n-----"), - // "

Foo

", - // "should not support a hard break w/ spaces at the end" - // ); + assert_eq!( + micromark("Foo \n-----"), + "

Foo

", + "should not support a hard break w/ spaces at the end" + ); assert_eq!( micromark("Foo\\\n-----"), -- cgit