From cba5baa42729da2574edb72592c48eef795d51f7 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Mon, 21 Sep 2020 09:44:37 +1000 Subject: [PATCH] FIX: compensate for typographer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typographer can change " to ” leading to breakages in parser At least codify this. Longer term we want to re-prioritize typographer so it always runs after bbcode parsing. --- .../engines/discourse-markdown/bbcode-block.js | 2 +- spec/components/pretty_text_spec.rb | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js index 4c0413358de..4160d7986dc 100644 --- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js +++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/bbcode-block.js @@ -15,7 +15,7 @@ function trailingSpaceOnly(src, start, max) { return true; } -const ATTR_REGEX = /^\s*=(.+)$|((([a-z0-9]*)\s*)=)([“”].*?[“”]|['].*[']|["].*?["]|\S+)/gi; +const ATTR_REGEX = /^\s*=(.+)$|((([a-z0-9]*)\s*)=)([“”"][^“”"]*[“”"]|['][^']*[']|[^"'“”]\S*)/gi; // parse a tag [test a=1 b=2] to a data structure // {tag: "test", attrs={a: "1", b: "2"} diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index f5cca52d5c4..78c480af070 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -1711,17 +1711,20 @@ HTML end it "wraps the [wrap] tag in block" do + # can interfere with parsing + SiteSetting.enable_markdown_typographer = true + md = <<~MD - [wrap=toc] - taco + [wrap=toc id="a” aa='b"' bb="f'"] + taco1 [/wrap] MD cooked = PrettyText.cook(md) html = <<~HTML -
-

taco

+
+

taco1

HTML