From 59be4f386c3803aeab7a9b2bc9bca49f1fe113db Mon Sep 17 00:00:00 2001
From: Alec Theriault <alec.theriault@gmail.com>
Date: Sat, 7 Jul 2018 19:46:17 -0700
Subject: Support (and flatten) inline markup in image links

Inline markup is supported in image links but, as per the [commonmark
recommendation][0], it is stripped back to a plain text representation.

  [0]: https://spec.commonmark.org/0.28/#example-547
---
 html-test/src/Bug865.hs | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 html-test/src/Bug865.hs

(limited to 'html-test')

diff --git a/html-test/src/Bug865.hs b/html-test/src/Bug865.hs
new file mode 100644
index 00000000..71a6add1
--- /dev/null
+++ b/html-test/src/Bug865.hs
@@ -0,0 +1,9 @@
+module Bug865 where
+
+-- | An emphasized link [yes /this/ is emphasized while this is
+-- @monospaced@](https://www.haskell.org/). And here is an image:
+--
+-- ![/emphasis/ stripped](https://www.haskell.org/static/img/haskell-logo.svg)
+--
+link :: ()
+link = ()
-- 
cgit v1.2.3


From 7c77914a3d47b78e690c820b0964a8f14b886cc9 Mon Sep 17 00:00:00 2001
From: Alec Theriault <alec.theriault@gmail.com>
Date: Fri, 20 Jul 2018 00:21:48 -0700
Subject: Accept test case

---
 .../src/Documentation/Haddock/Parser.hs            |  2 +-
 html-test/ref/Bug865.html                          | 84 ++++++++++++++++++++++
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 html-test/ref/Bug865.html

(limited to 'html-test')

diff --git a/haddock-library/src/Documentation/Haddock/Parser.hs b/haddock-library/src/Documentation/Haddock/Parser.hs
index 0992dbbc..f6c12d46 100644
--- a/haddock-library/src/Documentation/Haddock/Parser.hs
+++ b/haddock-library/src/Documentation/Haddock/Parser.hs
@@ -796,7 +796,7 @@ hyperlink = choice' [ angleBracketLink, markdownLink, autoUrl ]
 
 angleBracketLink :: Parser (DocH mod a)
 angleBracketLink =
-    DocHyperlink . flip Hyperlink Nothing . T.unpack . removeEscapes
+    DocHyperlink . makeLabeled (\s -> Hyperlink s . fmap DocString)
     <$> disallowNewline ("<" *> takeUntil ">")
 
 markdownLink :: Parser (DocH mod Identifier)
diff --git a/html-test/ref/Bug865.html b/html-test/ref/Bug865.html
new file mode 100644
index 00000000..6630a88d
--- /dev/null
+++ b/html-test/ref/Bug865.html
@@ -0,0 +1,84 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+  ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+     /><title
+    >Bug865</title
+    ><link href="#" rel="stylesheet" type="text/css" title="Ocean"
+     /><link rel="stylesheet" type="text/css" href="#"
+     /><script src="haddock-bundle.min.js" async="async" type="text/javascript"
+    ></script
+    ><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
+    ></script
+    ></head
+  ><body
+  ><div id="package-header"
+    ><ul class="links" id="page-menu"
+      ><li
+	><a href="#"
+	  >Contents</a
+	  ></li
+	><li
+	><a href="#"
+	  >Index</a
+	  ></li
+	></ul
+      ><p class="caption empty"
+      ></p
+      ></div
+    ><div id="content"
+    ><div id="module-header"
+      ><table class="info"
+	><tr
+	  ><th
+	    >Safe Haskell</th
+	    ><td
+	    >Safe</td
+	    ></tr
+	  ></table
+	><p class="caption"
+	>Bug865</p
+	></div
+      ><div id="synopsis"
+      ><details id="syn"
+	><summary
+	  >Synopsis</summary
+	  ><ul class="details-toggle" data-details-id="syn"
+	  ><li class="src short"
+	    ><a href="#"
+	      >link</a
+	      > :: ()</li
+	    ></ul
+	  ></details
+	></div
+      ><div id="interface"
+      ><h1
+	>Documentation</h1
+	><div class="top"
+	><p class="src"
+	  ><a id="v:link" class="def"
+	    >link</a
+	    > :: () <a href="#" class="selflink"
+	    >#</a
+	    ></p
+	  ><div class="doc"
+	  ><p
+	    >An emphasized link <a href="#"
+	      >yes <em
+		>this</em
+		> is emphasized while this is
+ <code
+		>monospaced</code
+		></a
+	      >. And here is an image:</p
+	    ><p
+	    ><img src="https://www.haskell.org/static/img/haskell-logo.svg" title="emphasis stripped"
+	       /></p
+	    ></div
+	  ></div
+	></div
+      ></div
+    ><div id="footer"
+    ></div
+    ></body
+  ></html
+>
\ No newline at end of file
-- 
cgit v1.2.3