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/link_reference.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'tests/link_reference.rs') diff --git a/tests/link_reference.rs b/tests/link_reference.rs index 0904995..372bea5 100644 --- a/tests/link_reference.rs +++ b/tests/link_reference.rs @@ -66,7 +66,7 @@ fn link_reference() { ); assert_eq!( - micromark_with_options("[ref]: /uri\n\n[foo ", &DANGER), + micromark_with_options("[ref]: /uri\n\n[foo ", DANGER), "

[foo

", "should prefer HTML over link references" ); @@ -161,12 +161,11 @@ fn link_reference() { "should not support empty references" ); - // To do: trimming whitespace. - // assert_eq!( - // micromark("[\n ]: /uri\n\n[\n ]"), - // "

[\n]: /uri

\n

[\n]

", - // "should not support blank references" - // ); + assert_eq!( + micromark("[\n ]: /uri\n\n[\n ]"), + "

[\n]: /uri

\n

[\n]

", + "should not support blank references" + ); assert_eq!( micromark("[foo]: /url \"title\"\n\n[foo][]"), @@ -187,12 +186,11 @@ fn link_reference() { "should match references to definitions case-insensitively" ); - // To do: trimming whitespace. - // assert_eq!( - // micromark("[foo]: /url \"title\"\n\n[foo] \n[]"), - // "

foo\n[]

", - // "should not support whitespace between label and collaped reference" - // ); + assert_eq!( + micromark("[foo]: /url \"title\"\n\n[foo] \n[]"), + "

foo\n[]

", + "should not support whitespace between label and collaped reference" + ); assert_eq!( micromark("[foo]: /url \"title\"\n\n[foo]"), -- cgit