Jira: add support for "smart" links

Support has been added for the new
`[alias|https://example.com|smart-card]` syntax.
This commit is contained in:
Albert Krewinkel 2021-05-25 16:54:42 +02:00
parent 8511f6fdf6
commit d46ea7d7da
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
6 changed files with 22 additions and 2 deletions

View file

@ -470,7 +470,7 @@ library
http-client-tls >= 0.2.4 && < 0.4,
http-types >= 0.8 && < 0.13,
ipynb >= 0.1 && < 0.2,
jira-wiki-markup >= 1.3.5 && < 1.4,
jira-wiki-markup >= 1.4 && < 1.5,
mtl >= 2.2 && < 2.3,
network >= 2.6,
network-uri >= 2.6 && < 2.8,

View file

@ -172,6 +172,8 @@ jiraLinkToPandoc linkType alias url =
Jira.Email -> link ("mailto:" <> url') "" alias'
Jira.Attachment -> linkWith ("", ["attachment"], []) url' "" alias'
Jira.User -> linkWith ("", ["user-account"], []) url' "" alias'
Jira.SmartCard -> linkWith ("", ["smart-card"], []) url' "" alias'
Jira.SmartLink -> linkWith ("", ["smart-link"], []) url' "" alias'
-- | Get unicode representation of a Jira icon.
iconUnicode :: Jira.Icon -> Text

View file

@ -280,6 +280,8 @@ toJiraLink (_, classes, _) (url, _) alias = do
| Just email <- T.stripPrefix "mailto:" url' = (Jira.Email, email)
| "user-account" `elem` classes = (Jira.User, dropTilde url)
| "attachment" `elem` classes = (Jira.Attachment, url)
| "smart-card" `elem` classes = (Jira.SmartCard, url)
| "smart-link" `elem` classes = (Jira.SmartLink, url)
| otherwise = (Jira.External, url)
dropTilde txt = case T.uncons txt of
Just ('~', username) -> username

View file

@ -9,7 +9,7 @@ packages:
extra-deps:
- hslua-1.3.0
- hslua-module-path-0.1.0
- jira-wiki-markup-1.3.5
- jira-wiki-markup-1.4.0
- random-1.2.0
- unicode-collation-0.1.3
- citeproc-0.4

View file

@ -167,6 +167,14 @@ tests =
, "user with description" =:
"[John Doe|~johndoe]" =?>
para (linkWith ("", ["user-account"], []) "~johndoe" "" "John Doe")
, "'smart' link" =:
"[x|http://example.com|smart-link]" =?>
para (linkWith ("", ["smart-link"], []) "http://example.com" "" "x")
, "'smart' card" =:
"[x|http://example.com|smart-card]" =?>
para (linkWith ("", ["smart-card"], []) "http://example.com" "" "x")
]
, "image" =:

View file

@ -61,6 +61,14 @@ tests =
, "user link with user as description" =:
linkWith ("", ["user-account"], []) "~johndoe" "" "~johndoe" =?>
"[~johndoe]"
, "'smart' link" =:
para (linkWith ("", ["smart-link"], []) "http://example.com" "" "x") =?>
"[x|http://example.com|smart-link]"
, "'smart' card" =:
para (linkWith ("", ["smart-card"], []) "http://example.org" "" "x") =?>
"[x|http://example.org|smart-card]"
]
, testGroup "spans"