Skip to content

markwoodhall/marge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marge

Markdown generation for Clojure and ClojureScript.

Status

Build Status Clojars Project

Usage

(require '[marge.core :as marge])

Headings

(marge/markdown 
 [:h4 "My Heading"])

My Heading

Quotes

(marge/markdown
 [:blockquote "Something quote worthy!"])

Something quote worthy!

Normal

(marge/markdown
 [:normal "Done this!"])

Done this!

Strikethrough

(marge/markdown
 [:strikethrough "Done this!"])

Done this!

Strong

(marge/markdown
 [:strong "Done this!"])

Done this!

Emphasis

(marge/markdown
 [:em "Done this!"])

Done this!

Lists

(marge/markdown
 [:ol ["Item 1" "Item 2"]])
  1. Item 1
  2. Item 2
(marge/markdown
 [:ul ["Item 1" "Item 2"]])
  • Item 1
  • Item 2
(marge/markdown
 [:ol ["Item 1" 
       [:ul "Sub Item 1" "Sub Item 2"]
       "Item 2"]])
  1. Item 1
  • Sub Item 1
  • Sub Item 2
  1. Item 2
(marge/markdown
 [:ul [{:done? true :task "Item 1"} {:done? false :task "Item 2"}]])
  • Item 1
  • Item 2

Links

(marge/markdown 
 [:link 
  {:text "I'm an inline-style link" 
   :title "Google Homepage"
   :url "https://www.google.com"}])

I'm an inline-style link

Anchors

Sometimes you might want to place an anchor that you link to later.

(marge/markdown 
 [:anchor "Anchor"])

Test Anchor Link

Horizontal Rule

(marge/markdown 
 [:hr])

Code

(marge/markdown 
 [:code
  {:clojure "(def data [1 2 3])"}])
(def data [1 2 3])

Tables

(markdown 
  [:table
   ["Product" 
    ["Coke" "Fanta" "Lilt"] 
    "Quantity" 
    ["100" "10000000" "1"]
    "Price"
    ["$70" "$7000000" "$2"]]])
Product Quantity Price
Coke 100 $70
Fanta 10000000 $7000000
Lilt 1 $2

Markdown in a table

(markdown 
  [:table
   ["Title" 
    ["link"]
    "Links" 
    [:link {:url "url" :text "text"}]]])
Title Links
link text

HTML Inside Markdown

You can generate html inside your markdown using Hiccup syntax, the rendering for this uses Hiccup for Clojure or Hiccups for ClojureScript.

(markdown [:p 
           [:normal "When I want to search for things I go to "
            :html [:a {:href "http://google.com"} "google"]]])

When I want to search for things I go to google

Composition

(markdown [:p 
           [:normal "When I want to search for things I go to "
            :em [:link {:url "http://google.com" :text "google"}]]])