|
1 | 1 | module Spec.Markdown (markdownSpec) where
|
2 | 2 |
|
3 |
| -import CMark.Extended (extractMetaDescription, linkifyHeaders, renderMarkdown) |
| 3 | +import CMark.Extended (extractMetaDescription, linkifyHeaders, reifyFootnotes, renderMarkdown) |
4 | 4 | import Protolude
|
5 | 5 | import Test.Tasty.Hspec (Spec, describe, it, shouldReturn)
|
6 | 6 |
|
@@ -47,3 +47,25 @@ markdownSpec = do
|
47 | 47 | it "returns modified" $
|
48 | 48 | runLinkifyHeaders "## [Foo](https://foo.com)"
|
49 | 49 | `shouldReturn` "## <a class=\"h-anchor\" id=\"foo\" href=\"#foo\">#</a>[Foo](https://foo.com)"
|
| 50 | + describe "Reify Footnotes" $ do |
| 51 | + let runReifyFootnotes = pure . reifyFootnotes |
| 52 | + it "returns unmodified" $ |
| 53 | + runReifyFootnotes "" `shouldReturn` "" |
| 54 | + it "returns unmodified" $ |
| 55 | + runReifyFootnotes "foo" `shouldReturn` "foo" |
| 56 | + it "returns unmodified" $ |
| 57 | + runReifyFootnotes "foo\n\n" `shouldReturn` "foo\n\n" |
| 58 | + it "returns with empty footnote block" $ |
| 59 | + -- must be prefixed with \n\n (block) |
| 60 | + -- without references generated footnote block is empty |
| 61 | + runReifyFootnotes "[^foo]: hey\n\n[^bar]: you" |
| 62 | + `shouldReturn` "[^foo]: hey\n\n---\n\n<ol></ol>" |
| 63 | + it "returns with empty footnote block" $ |
| 64 | + runReifyFootnotes "\n\n[^foo]: hey\n\n[^bar]: you" |
| 65 | + `shouldReturn` "\n\n---\n\n<ol></ol>" |
| 66 | + it "returns with correct footnote block" $ |
| 67 | + runReifyFootnotes "foo.[^foo]\n\nbar.[^bar]\n\n[^foo]: hey\n\n[^bar]: you" |
| 68 | + `shouldReturn` "foo.<sup><a id=\"fn-1\" href=\"#fnr-1\">1</a></sup>\n\nbar.<sup><a id=\"fn-2\" href=\"#fnr-2\">2</a></sup>\n\n---\n\n<ol><li id=\"fnr-1\"><p>hey <a class=\"rfn\" href=\"#fn-1\">\8617</a></p>\n</li>\n<li id=\"fnr-2\"><p>you <a class=\"rfn\" href=\"#fn-2\">\8617</a></p>\n</li>\n</ol>" |
| 69 | + it "returns with correct footnote block" $ |
| 70 | + runReifyFootnotes "foo.[^foo]\n\n[^foo]: hey\n\n[^bar]: you\n\nbar.[^bar]\n\n" |
| 71 | + `shouldReturn` "foo.<sup><a id=\"fn-1\" href=\"#fnr-1\">1</a></sup>\n\nbar.<sup><a id=\"fn-2\" href=\"#fnr-2\">2</a></sup>\n\n---\n\n<ol><li id=\"fnr-1\"><p>hey <a class=\"rfn\" href=\"#fn-1\">\8617</a></p>\n</li>\n<li id=\"fnr-2\"><p>you <a class=\"rfn\" href=\"#fn-2\">\8617</a></p>\n</li>\n</ol>" |
0 commit comments