GithubHelp home page GithubHelp logo

markdown-clj's Introduction

#Markdown parser written in Clojure

A markdown parser which compiles to both Clojure and ClojureScript.

Continuous Integration status

Installation

Leiningen

[markdown-clj "0.9.19"]

Maven

<dependency>
  <groupId>markdown-clj</groupId>
  <artifactId>markdown-clj</artifactId>
  <version>0.9.19</version>
</dependency>

Building

To build the Clojure jar

lein install

To compile the ClojureScript portion

lein cljsbuild once

Usage

Markdown-clj can be invoked either by calling md-to-html which takes two parameters, which will be passed to a reader and writer respectively, eg:

(ns foo
  (:use markdown.core))
  
(md-to-html "input.md" "output.html")

(md-to-html (input-stream "input.md") (output-stream "test.txt"))

or by calling md-to-html-string which accepts a string with markdown content and returns a string with the resulting HTML:

(md-to-html-string "# This is a test\nsome code follows\n```clojure\n(defn foo [])\n```")
<h1> This is a test</h1>some code follows<pre><code class="brush: clojure;">
&#40;defn foo &#91;&#93;&#41;
</code></pre>

Finally, md-to-html and md-to-html-string can accept optional parameters:

Specifying :heading-anchors will create anchors for the heading tags, eg:

(markdown/md-to-html-string "###foo bar BAz" :heading-anchors true)
<h3><a name=\"heading\" class=\"anchor\" href=\"#foo&#95;bar&#95;baz></a>foo bar BAz</h3>

Specifying :code-style will override the default code class formatting for code blocks, eg:

(md-to-html-string "# This is a test\nsome code follows\n```clojure\n(defn foo [])\n```" 
                   :code-style #(str "class=\"" % "\""))
<h1> This is a test</h1>some code follows<pre><code class="clojure">
&#40;defn foo &#91;&#93;&#41;
</code></pre>

Supported syntax

Control characters can be escaped using \

\*
\`
\_
\(
\)
\[
\]
\{
\}

Basic Elements

Blockquote, Bold, Emphasis, Heading, Italics, Line, Paragraph, Strikethrough

Links

Image, Link

Lists

Ordered List, Unordered List

Code

Code Block, Indented Code, Inline Code


Heading

the number of hashes indicates the level of the heading

# Heading

##Sub-heading 

### Sub-sub-heading 

Line

***

* * *

*****

- - -

Emphasis

*foo*

Italics

_foo_

Bold

**foo**
__foo__

Blockquote

>This is a blockquote
with some content

>this is another blockquote

Paragraph

This is a paragraph, it's
split into separate lines.

This is another paragraph.

Unordered List

indenting an item makes it into a sublist of the item above it, ordered and unordered lists can be nested within one another. List items can be split over multiple lines.

* Foo
* Bar
 * Baz
* foo
* bar

   * baz
     1. foo
     2. bar
        more content 
        ## subheading 
        ***
        **bold text** in the list

   * fuzz

      * blah
      * blue
* brass

Ordered List

1. Foo
2. Bar
3. Baz

Inline Code

Any special characters in code will be escaped with their corresponding HTML codes.

Here's some code `x + y = z` that's inlined.

Code block

Using three backquotes indicates a start of a code block, the next three backquotes ends the code block section. Optionally, the language name can be put after the backquotes to produce a tag compatible with the Syntax Highlighter, eg:

```clojure

(defn foo [bar] "baz")

```

Indented Code

indenting by at least 4 spaces creates a code block

some
code 
here

note: XML is escaped in code sections

Strikethrough

~~foo~~

Superscript

a^2 + b^2 = c^2

Link

[github](http://github.com)

Image

![Alt text](http://server/path/to/img.jpg)
![Alt text](/path/to/img.jpg "Optional Title")

Image Link

[![Continuous Integration status](https://secure.travis-ci.org/yogthos/markdown-clj.png)](http://travis-ci.org/yogthos/markdown-clj)

License

Copyright (C) 2012 Yogthos

Distributed under the Eclipse Public License, the same as Clojure.

markdown-clj's People

Contributors

johansson avatar yogthos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.