Skip to content

Commit 8171397

Browse files
committed
for wikilink [directory/bla/blo/mypage]() display myPage instead of directory/bla/blo/mypage
1 parent 5f16b36 commit 8171397

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Network/Gitit2/WikiPage.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ contentToWikiPage' title contents converter defaultFormat =
104104
doc = reader $ toString b
105105
Pandoc _ blocks = sanitizePandoc $ addWikiLinks doc
106106
convertWikiLinks :: Inline -> Inline
107-
convertWikiLinks (Link ref ("", "")) = Link ref (converter ref, "")
107+
convertWikiLinks (Link ref ("", "")) = Link (linkTitle ref) (converter ref, "")
108108
convertWikiLinks (Image ref ("", "")) = Image ref (converter ref, "")
109109
convertWikiLinks x = x
110110

111+
linkTitle [Str refStr] = [Str $ T.unpack $ last . T.splitOn "/" $ T.pack refStr]
112+
linkTitle x = x
113+
111114
addWikiLinks :: Pandoc -> Pandoc
112115
addWikiLinks = bottomUp (convertWikiLinks)
113116

@@ -142,4 +145,3 @@ contentToWikiPage' title contents converter defaultFormat =
142145
sanitizeAttr (x,y) = case sanitizeAttribute (T.pack x, T.pack y) of
143146
Just (w,z) -> Just (T.unpack w, T.unpack z)
144147
Nothing -> Nothing
145-

0 commit comments

Comments
 (0)