Skip to content

Commit 140f203

Browse files
committed
Improve reference link rendering
This changes the way references are rendered from: [example](http://example.com/) [example with title](http://example.com/ "title") To: [example]: http://example.com/ [example with title]: http://example.com/ title This easier to read and more coherent with Pandoc markdown.
1 parent e77899f commit 140f203

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/Patat/Presentation/Display.hs

+2-3
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,11 @@ prettyReferences ds =
469469
"[" <>
470470
themed ds themeLinkText
471471
(prettyInlines ds $ newlineToSpace text) <>
472-
"](" <>
472+
"]: " <>
473473
themed ds themeLinkTarget (PP.text target) <>
474474
(if T.null title
475475
then mempty
476-
else PP.space <> "\"" <> PP.text title <> "\"")
477-
<> ")"
476+
else PP.space <> PP.text title)
478477

479478
newlineToSpace :: [Inline] -> [Inline]
480479
newlineToSpace = runIdentity . dftInlines (pure . pure) work

tests/golden/outputs/links.md.dump

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
Let's talk about [foo]
99

10-
[inline link](/url)
11-
[one with a title](http://fsf.org "click here for a good time!")
12-
[foo](http://foo.com/)
10+
[inline link]: /url
11+
[one with a title]: http://fsf.org click here for a good time!
12+
[foo]: http://foo.com/
1313
 1 / 2 
1414

1515
{slide}
@@ -23,8 +23,8 @@
2323
4. A [shortcut reference] link
2424
5. A [titled] link
2525

26-
[inline one](http://example.com#2)
27-
[reference](http://example.com#3)
28-
[shortcut reference](http://example.com#4)
29-
[titled](http://example.com#5 "The title")
26+
[inline one]: http://example.com#2
27+
[reference]: http://example.com#3
28+
[shortcut reference]: http://example.com#4
29+
[titled]: http://example.com#5 The title
3030
 2 / 2 

0 commit comments

Comments
 (0)