From bcc848d773f9b0f968e7ecb69739adea0432045e Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sat, 15 Apr 2017 13:32:28 +0200
Subject: [PATCH] Avoid parsing "Notes:**" as a bare URI.

This avoids parsing bare URIs that start with a scheme
+ colon + `*`, `_`, or `]`.

Closes #3570.
---
 src/Text/Pandoc/Parsing.hs | 2 ++
 test/command/3570.md       | 6 ++++++
 2 files changed, 8 insertions(+)
 create mode 100644 test/command/3570.md

diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index a84535875..e985f3d32 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -463,6 +463,8 @@ uri :: Stream [Char] m Char => ParserT [Char] st m (String, String)
 uri = try $ do
   scheme <- uriScheme
   char ':'
+  -- Avoid parsing e.g. "**Notes:**" as a raw URI:
+  notFollowedBy (oneOf "*_]")
   -- We allow sentence punctuation except at the end, since
   -- we don't want the trailing '.' in 'http://google.com.' We want to allow
   -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)
diff --git a/test/command/3570.md b/test/command/3570.md
new file mode 100644
index 000000000..8c08a881d
--- /dev/null
+++ b/test/command/3570.md
@@ -0,0 +1,6 @@
+```
+% pandoc -f markdown+autolink_bare_uris
+**Notes:**
+^D
+<p><strong>Notes:</strong></p>
+```