Landmark is a small but extensible JavaScript library that allows to render Markdown documents into HTML. It's the primary engine for Sitemark and some other projects.
Landmark features only 2 methods:
Landmark.render(text)
- takes the Markdown source and returns ready HTML code (you'll only need this most of the time)Landmark.addRule(regexp, replacement)
- adds a new processing rule that allows you to specify custom Markdown tags:regexp
must be an escaped regular expression string in JavaScript syntax, andreplacement
can be either a string, or a function (see string replacement documentation for the reference)
Markdown syntax used in Landmark resembles both classical and GitHub-flavored Markdown versions, however it does not support some advanced features such as tables or reference-style links. Supported tags are:
- Headings, single-line form:
# Heading level 1
,## Heading level 2
and so on - Headings of levels 1 and 2, two-line form:
Heading level 1 =============== Heading level 2 ---------------
- Inline formatting:
**bold**
or__bold__
,*italic*
or_italic_
,~~strike~~
,:"quote":
and even non-standard___underline___
(triple underscore) tag! - Preformatted inline blocks:
`inline code`
- Preformatted multiline blocks:
```
first line of preformatted text
second line of preformatted text
etc...
```
- Block quotes:
> first line of quote
> second line of quote
> etc...
- Lists:
- unordered item 1
- unordered item 2
* another unordered item 1
* another unordered item 2
* another unordered item 3
1. ordered item 1
2. ordered item 2
3. ordered item 3
4. ordered item 4
- Links:
[link text](http://example.com)
- Images:
![alt text](http://example.com/flower.jpg)
- Horizontal rules:
****************
(5 and more asterisks on a new line) - Paragraphs: just like in standard Markdown, any non-special text is enclosed into paragraphs by default, just surround it with newlines.
Of course, you can use plain old HTML in Markdown documents, and it will pass as is, unless it's enclosed into inline or multiline preformatted blocks, in which case it will be escaped appropriately.