Skip to content
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

## Unreleased

- `plainify`: Fix double scanning of inlines of wiki-links
- Fixes
- `plainify`
- Fix double scanning of inlines of wiki-links
- Remove footnotes (\#3)

## 0.1.0.0

Expand Down
10 changes: 9 additions & 1 deletion src/Commonmark/Extensions/WikiLink.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,15 @@ wikilinkSpec =
TODO: extend on top of plainify from heist-extra
-}
plainify :: [B.Inline] -> Text
plainify = W.query $ \case
plainify = W.query plainify' . W.walk (mapMaybe removeInlineNotes)
where
removeInlineNotes :: B.Inline -> Maybe B.Inline
removeInlineNotes = \case
B.Note {} -> Nothing
a -> Just a

plainify' :: [B.Inline] -> Text
plainify' = W.query $ \case
B.Str x -> x
B.Code _attr x -> x
B.Space -> " "
Expand Down
3 changes: 1 addition & 2 deletions test/Commonmark/Extensions/WikiLinkSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ spec = do
plainify <$> parseMdPara1 "[Hello](https://example.com)" `shouldBe` Right "Hello"
it "with wikilink" $ do
plainify <$> parseMdPara1 "[[World]]" `shouldBe` Right "[[World]]"
-- FIXME
xit "with footnote" $ do
it "with footnote" $ do
plainify <$> parseMdPara1 "Hello[^1] World.\n\n[^1]: Some footnote." `shouldBe` Right "Hello World."

-- | Parse Markdown with our wikilink parser enabled
Expand Down