Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track wikilinks with a class instead of the title #160

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class HasWikilinks il where
wikilink :: Text -> il -> il

instance Rangeable (Html a) => HasWikilinks (Html a) where
wikilink url il = link url "wikilink" il
wikilink url il = addAttribute ("class", "wikilink") $ link url "" il

instance (HasWikilinks il, Semigroup il, Monoid il)
=> HasWikilinks (WithSourceMap il) where
Expand Down
10 changes: 5 additions & 5 deletions commonmark-extensions/test/wikilinks_title_after_pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ With this version of wikilinks, the title comes after the pipe.
```````````````````````````````` example
[[https://example.org]]
.
<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
<p><a class="wikilink" href="https://example.org">https://example.org</a></p>
````````````````````````````````

```````````````````````````````` example
[[https://example.org|title]]
.
<p><a href="https://example.org" title="wikilink">title</a></p>
<p><a class="wikilink" href="https://example.org">title</a></p>
````````````````````````````````

```````````````````````````````` example
[[Name of page]]
.
<p><a href="Name%20of%20page" title="wikilink">Name of page</a></p>
<p><a class="wikilink" href="Name%20of%20page">Name of page</a></p>
````````````````````````````````

```````````````````````````````` example
[[Name of page|Title]]
.
<p><a href="Name%20of%20page" title="wikilink">Title</a></p>
<p><a class="wikilink" href="Name%20of%20page">Title</a></p>
````````````````````````````````

HTML entities are recognized both in the name of page and in the link title.

```````````````````````````````` example
[[Gesch&uuml;tztes Leerzeichen|&#xDC;ber &amp;nbsp;]]
.
<p><a href="Gesch%C3%BCtztes%20Leerzeichen" title="wikilink">Über &amp;nbsp;</a></p>
<p><a class="wikilink" href="Gesch%C3%BCtztes%20Leerzeichen">Über &amp;nbsp;</a></p>
````````````````````````````````
10 changes: 5 additions & 5 deletions commonmark-extensions/test/wikilinks_title_before_pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ With this version of wikilinks, the title comes before the pipe.
```````````````````````````````` example
[[https://example.org]]
.
<p><a href="https://example.org" title="wikilink">https://example.org</a></p>
<p><a class="wikilink" href="https://example.org">https://example.org</a></p>
````````````````````````````````

```````````````````````````````` example
[[title|https://example.org]]
.
<p><a href="https://example.org" title="wikilink">title</a></p>
<p><a class="wikilink" href="https://example.org">title</a></p>
````````````````````````````````

```````````````````````````````` example
[[Name of page]]
.
<p><a href="Name%20of%20page" title="wikilink">Name of page</a></p>
<p><a class="wikilink" href="Name%20of%20page">Name of page</a></p>
````````````````````````````````

```````````````````````````````` example
[[Title|Name of page]]
.
<p><a href="Name%20of%20page" title="wikilink">Title</a></p>
<p><a class="wikilink" href="Name%20of%20page">Title</a></p>
````````````````````````````````

Regular links should still work!
Expand All @@ -44,5 +44,5 @@ HTML entities are recognized both in the name of page and in the link title.
```````````````````````````````` example
[[&#xDC;ber &amp;nbsp;|Gesch&uuml;tztes Leerzeichen]]
.
<p><a href="Gesch%C3%BCtztes%20Leerzeichen" title="wikilink">Über &amp;nbsp;</a></p>
<p><a class="wikilink" href="Gesch%C3%BCtztes%20Leerzeichen">Über &amp;nbsp;</a></p>
````````````````````````````````
2 changes: 1 addition & 1 deletion commonmark-pandoc/src/Commonmark/Pandoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ instance HasEmoji (Cm b B.Inlines) where
$ B.text t

instance HasWikilinks (Cm b B.Inlines) where
wikilink t il = Cm $ B.link t "wikilink" $ unCm il
wikilink t il = Cm $ B.linkWith (mempty, ["wikilink"], mempty) t "" $ unCm il

instance HasPipeTable (Cm a B.Inlines) (Cm a B.Blocks) where
pipeTable aligns headerCells rows =
Expand Down