git.iko.soy/typeable/pandoc
on master help sign in
Revert "Markdown reader: support GitHub wiki's internal links (#2923) (#6458)"

This reverts commit 6efd3460a776620fdb93812daa4f6831e6c332ce. Since this extension is designed to be used with GitHub markdown (gfm), we need to implement the parser as a commonmark extension (commonmark-extensions), rather than in pandoc's markdown reader. When that is done, we can add it here.

commitc841bcf3b01548b2f9b462b39d8edda4c10be534 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 16 Jan 2021, 16:22 (6 years ago) parent6efd346
3 files changed−58
src/Text/Pandoc/Extensions.hs−3 src/Text/Pandoc/Readers/Markdown.hs−25 test/Tests/Readers/Markdown.hs−30
src/Text/Pandoc/Extensions.hs−3
@@ -118,7 +118,6 @@ data Extension =
118118 | Ext_literate_haskell -- ^ Enable literate Haskell conventions
119119 | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown iff
120120 -- container has attribute 'markdown'
121− | Ext_wikilinks -- ^ Interpret a markdown wiki link
122121 | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks
123122 | Ext_mmd_header_identifiers -- ^ Multimarkdown style header identifiers [myid]
124123 | Ext_mmd_link_attributes -- ^ MMD style reference link attributes
@@ -259,7 +258,6 @@ githubMarkdownExtensions = extensionsFromList
259258 , Ext_emoji
260259 , Ext_fenced_code_blocks
261260 , Ext_backtick_code_blocks
262− , Ext_wikilinks
263261 ]
264262
265263-- | Extensions to be used with multimarkdown.
@@ -446,7 +444,6 @@ getAllExtensions f = universalExtensions <> getAll f
446444 , Ext_tex_math_single_backslash
447445 , Ext_tex_math_double_backslash
448446 , Ext_markdown_attribute
449− , Ext_wikilinks
450447 , Ext_mmd_title_block
451448 , Ext_abbreviations
452449 , Ext_autolink_bare_uris
src/Text/Pandoc/Readers/Markdown.hs−25
@@ -21,7 +21,6 @@ module Text.Pandoc.Readers.Markdown (
2121import Control.Monad
2222import Control.Monad.Except (throwError)
2323import Data.Char (isAlphaNum, isPunctuation, isSpace)
24−import Data.Functor (($>))
2524import Data.List (transpose, elemIndex, sortOn)
2625import qualified Data.Map as M
2726import Data.Maybe
@@ -1486,7 +1485,6 @@ inline = choice [ whitespace
14861485 , note
14871486 , cite
14881487 , bracketedSpan
1489− , githubWikiLink
14901488 , link
14911489 , image
14921490 , math
@@ -1782,29 +1780,6 @@ source = do
17821780linkTitle :: PandocMonad m => MarkdownParser m Text
17831781linkTitle = quotedTitle '"' <|> quotedTitle '\''
17841782
1785−-- Github wiki style link, with optional title
1786−-- syntax documented under https://help.github.com/en/github/building-a-strong-community/editing-wiki-content
1787−githubWikiLink :: PandocMonad m => MarkdownParser m (F Inlines)
1788−githubWikiLink = try $ guardEnabled Ext_wikilinks >> wikilink
1789− where
1790− wikilink = try $ do
1791− string "[["
1792− firstPart <- fmap mconcat . sequence <$> wikiText
1793− (char '|' *> complexWikilink firstPart)
1794− <|> (string "]]" $> (B.link
1795− <$> (stringify <$> firstPart)
1796− <*> return "wikilink"
1797− <*> firstPart))
1798−
1799− complexWikilink firstPart = do
1800− url <- fmap stringify . sequence <$> wikiText
1801− string "]]"
1802− return $ B.link <$> url
1803− <*> return "wikilink"
1804− <*> firstPart
1805−
1806− wikiText = many (whitespace <|> bareURL <|> str <|> endline <|> escapedChar)
1807−
18081783link :: PandocMonad m => MarkdownParser m (F Inlines)
18091784link = try $ do
18101785 st <- getState
test/Tests/Readers/Markdown.hs−30
@@ -307,36 +307,6 @@ tests = [ testGroup "inline code"
307307 "[https://example.org(](url)" =?>
308308 para (link "url" "" (text "https://example.org("))
309309 ]
310− , testGroup "Github wiki links"
311− [ test markdownGH "autolink" $
312− "[[https://example.org]]" =?>
313− para (link "https://example.org" "wikilink" (text "https://example.org"))
314− , test markdownGH "link with title" $
315− "[[title|https://example.org]]" =?>
316− para (link "https://example.org" "wikilink" (text "title"))
317− , test markdownGH "bad link with title" $
318− "[[title|random string]]" =?>
319− para (link "random-string" "wikilink" (text "title"))
320− , test markdownGH "autolink not being a link" $
321− "[[Name of page]]" =?>
322− para (link "Name-of-page" "wikilink" (text "Name of page"))
323− , test markdownGH "autolink not being a link with a square bracket" $
324− "[[Name of ]page]]" =?>
325− para (link "Name-of-]page" "wikilink" (text "Name of ]page"))
326− , test markdownGH "formatting (strong and emphasis) should not be interpreted" $
327− "[[***a**b **c**d*|https://example.org]]" =?>
328− para (text "[[" <> emph (strong (str "a") <> str "b" <> space
329− <> strong (str "c") <> str "d") <> text "|https://example.org]]")
330− , test markdownGH "inlined code should not make a link" $
331− "[[ti`|`le|https://example.org]]" =?>
332− para (text "[[ti" <> code "|" <> text "le|https://example.org]]")
333− , test markdownGH "link with title and a cut should take the middle part as link" $
334− "[[tit|le|https://example.org]]" =?>
335− para (link "le" "wikilink" (text "tit"))
336− , test markdownGH "link with inline start should be a link" $
337− "[[t`i*t_le|https://example.org]]" =?>
338− para (link "https://example.org" "wikilink" (text "t`i*t_le"))
339− ]
340310 , testGroup "Headers"
341311 [ "blank line before header" =:
342312 "\n# Header\n"