-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46eccfb
commit d0dda06
Showing
11 changed files
with
797 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.class | ||
.lsp/ | ||
yarn-error.log | ||
junit.xml | ||
/.cpcache | ||
/.lein-* | ||
/.nrepl-history | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(ns cybermonday.test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[cybermonday.ir :as ir] | ||
[cybermonday.core :as cm] | ||
[clojure.edn :as edn] | ||
[clojure.java.io :as io])) | ||
|
||
(def test-document (slurp (io/resource "test-document.md"))) | ||
(def test-frontmatter-document (slurp (io/resource "test-frontmatter.md"))) | ||
|
||
(def expected-ir (edn/read-string (slurp (io/resource "expected-ir.edn")))) | ||
(def expected-html (edn/read-string (slurp (io/resource "expected-html.edn")))) | ||
|
||
(deftest ir | ||
(testing "Parsing to IR" | ||
(is (= expected-ir (ir/md-to-ir test-document))))) | ||
|
||
(deftest frontmatter | ||
(testing "Parsing frontmatter" | ||
(let [{:keys [frontmatter body]} (cm/parse-md test-frontmatter-document)] | ||
(is (= {:title "Test Frontmatter" | ||
:author (list "Kiran Shila") | ||
:code "data" | ||
:tags (list "cybermonday" "unit-tests")} | ||
frontmatter)) | ||
(is (= [:div {} | ||
[:h1 {:id "test"} "Test"] | ||
[:p {} "This file contains " [:em {} "markdown"]]] | ||
body))))) | ||
|
||
(deftest html | ||
(testing "Parsing to HTML" | ||
(is (= expected-html (cm/parse-body test-document))))) | ||
|
||
(cm/parse-body test-document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
[:div | ||
{} | ||
[:h1 {:id "cybermonday-test-document"} "Cybermonday Test Document"] | ||
[:p | ||
{} | ||
"This document will hopefully cover all the different AST node types that are" | ||
"available in commonmark + the enabled features in Cybermonday."] | ||
[:h2 {:id "easy-stuff"} "Easy stuff"] | ||
[:p {} "Here are two different kinds of lists:"] | ||
[:p {} "An ordered list"] | ||
[:ol {} [:li {} [:p {} "Foo"]] [:li {} [:p {} "Bar"]] [:li {} [:p {} "Baz"]]] | ||
[:p {} "And unordered list"] | ||
[:ul | ||
{} | ||
[:li {} [:p {} "Test1"]] | ||
[:li {} [:p {} "Test2"]] | ||
[:li {} [:p {} "Test3"]]] | ||
[:p {} "We can nest the lists"] | ||
[:ol | ||
{} | ||
[:li {} [:p {} "First item"]] | ||
[:li {} [:p {} "Second item"]] | ||
[:li | ||
{} | ||
[:p {} "Third item"] | ||
[:ol {} [:li {} [:p {} "Indented item"]] [:li {} [:p {} "Indented item"]]]] | ||
[:li {} [:p {} "Fourth item"]]] | ||
[:ul | ||
{} | ||
[:li {} [:p {} "First item"]] | ||
[:li {} [:p {} "Second item"]] | ||
[:li | ||
{} | ||
[:p {} "Third item"] | ||
[:ul {} [:li {} [:p {} "Indented item"]] [:li {} [:p {} "Indented item"]]]] | ||
[:li {} [:p {} "Fourth item"]]] | ||
[:ol | ||
{} | ||
[:li {} [:p {} "First item"]] | ||
[:li {} [:p {} "Second item"]] | ||
[:li | ||
{} | ||
[:p {} "Third item"] | ||
[:ul {} [:li {} [:p {} "Indented item"]] [:li {} [:p {} "Indented item"]]]] | ||
[:li {} [:p {} "Fourth item"]]] | ||
[:p {} "All heading levels"] | ||
[:h1 {:id "heading-level-1"} "Heading level 1"] | ||
[:h2 {:id "heading-level-2"} "Heading level 2"] | ||
[:h3 {:id "heading-level-3"} "Heading level 3"] | ||
[:h4 {:id "heading-level-4"} "Heading level 4"] | ||
[:h5 {:id "heading-level-5"} "Heading level 5"] | ||
[:h6 {:id "heading-level-6"} "Heading level 6"] | ||
[:p {} "####### This shouldn't be a heading"] | ||
[:h1 | ||
{:id "alternative-heading-syntaxheading-level-1"} | ||
"Alternative heading syntax" | ||
"Heading level 1"] | ||
[:h2 {:id "heading-level-2"} "Heading level 2"] | ||
[:p | ||
{} | ||
"This should be one paragraph." | ||
"Even though they are on different lines"] | ||
[:p {} "This however is a new paragraph."] | ||
[:p {} "We can create an hr with"] | ||
[:hr {}] | ||
[:p | ||
{} | ||
"Here is text with " | ||
[:strong {} "Bold"] | ||
", " | ||
[:strong {} "bold"] | ||
", " | ||
[:em {} "italic"] | ||
", " | ||
[:em {} "italic"] | ||
", " | ||
[:strong {} [:em {} "bold_italic"]] | ||
"."] | ||
[:blockquote {} [:p {} "This is a quote"]] | ||
[:blockquote {} [:p {} "This is a quote with " [:em {} "markdown"] " in it."]] | ||
[:blockquote | ||
{} | ||
[:p | ||
{} | ||
"This is a quote with " | ||
[:em {} "markdown"] | ||
" and " | ||
[:p {:class "my-class"} "HTML"] | ||
" in it"]] | ||
[:blockquote | ||
{} | ||
[:p {} "This is a quote"] | ||
[:blockquote {} [:p {} "With another quote in it"]]] | ||
[:p {} [:img {:src "image_url.png", :alt "An Image!", :title nil}]] | ||
[:p {} "Here is some code"] | ||
[:pre {} [:code {:class "language-julia"} "using LinearAlgebra\n"]] | ||
[:p {} "Also some " [:code {} "inline code stuff"] "."] | ||
[:h1 {:id "links"} "Links"] | ||
[:p | ||
{} | ||
"My favorite search engine is " | ||
[:a {:href "https://duckduckgo.com", :title nil} "Duck Duck Go"] | ||
"."] | ||
[:p | ||
{} | ||
"My favorite search engine is " | ||
[:a | ||
{:href "https://duckduckgo.com", | ||
:title "The best search engine for privacy"} | ||
"Duck Duck Go"] | ||
"."] | ||
[:p | ||
{} | ||
[:a {:href "https://www.markdownguide.org"} "https://www.markdownguide.org"] | ||
[:a {:href "mailto:[email protected]"}]] | ||
[:p | ||
{} | ||
"You can markdown links too: I love supporting the " | ||
[:strong {} [:a {:href "https://eff.org", :title nil} "EFF"]] | ||
"." | ||
[:a | ||
{:href "https://en.wikipedia.org/wiki/Hobbit#Lifestyle", :title nil} | ||
"hobbit-hole"]] | ||
[:p | ||
{} | ||
"Here is an image link:" | ||
[:a | ||
{:href | ||
"https://www.flickr.com/photos/beaurogers/31833779864/in/photolist-Qv3rFw-34mt9F-a9Cmfy-5Ha3Zi-9msKdv-o3hgjr-hWpUte-4WMsJ1-KUQ8N-deshUb-vssBD-6CQci6-8AFCiD-zsJWT-nNfsgB-dPDwZJ-bn9JGn-5HtSXY-6CUhAL-a4UTXB-ugPum-KUPSo-fBLNm-6CUmpy-4WMsc9-8a7D3T-83KJev-6CQ2bK-nNusHJ-a78rQH-nw3NvT-7aq2qf-8wwBso-3nNceh-ugSKP-4mh4kh-bbeeqH-a7biME-q3PtTf-brFpgb-cg38zw-bXMZc-nJPELD-f58Lmo-bXMYG-bz8AAi-bxNtNT-bXMYi-bXMY6-bXMYv", | ||
:title nil} | ||
[:img | ||
{:src "/assets/images/shiprock.jpg", | ||
:alt "An old rock in the desert", | ||
:title "Shiprock, New Mexico by Beau Rogers"}]]] | ||
[:p | ||
{} | ||
"We should be able to escape stuff like: You use backticks (\\`code\\`) to write" | ||
"inline code."] | ||
[:h1 {:id "non-commonmark-stuff"} "Non-commonmark stuff"] | ||
[:p {} "Checkboxes from github"] | ||
[:ul | ||
{} | ||
[:li | ||
{} | ||
[:input {:checked true, :disabled true, :type "checkbox"}] | ||
[:p {} "#739"]] | ||
[:li | ||
{} | ||
[:input {:checked false, :disabled true, :type "checkbox"}] | ||
[:p {} "https://github.com/octo-org/octo-repo/issues/740"]] | ||
[:li | ||
{} | ||
[:input {:checked false, :disabled true, :type "checkbox"}] | ||
[:p {} "Add delight to the experience when all tasks are complete :tada:"]]] | ||
[:p {} "Tables"] | ||
[:table | ||
{} | ||
[:thead {} [:tr {} [:th {} "First Header"] [:th {} "Second Header"]]] | ||
[:tbody | ||
{} | ||
[:tr {} [:td {} "Content Cell"] [:td {} "Content Cell"]] | ||
[:tr {} [:td {} "Content Cell"] [:td {} "Content Cell"]]]] | ||
[:p {} "We can do inline math with " [:code {} "y=mx+b"]] | ||
[:p {} "We can do block math with just a code block"] | ||
[:pre {} [:code {:class "language-math"} "E=mc^2\n"]] | ||
[:p {} "Finally, we can do footnotes"] | ||
[:p | ||
{} | ||
"Paragraph with a footnote reference" | ||
[:sup {:id "fnref-1"} [:a {:href "#fn-1"}]]] | ||
[:li | ||
{:id "fn-1"} | ||
[:p | ||
[:span "Footnote text added at the bottom of the document\n"] | ||
[:a {:href "#fnref-1"} "↩"]]]] |
Oops, something went wrong.