YamYam

0.3.0 • Public • Published

YamYam

YamYam is a simple kind of markdown compiler.

Syntax

Basic things

# Headline

## Headline 2

Text, *Text with accent*, _more of this_
and even **more**... (and `code`)

* list item
* list item
 * list item

[ ] check list item
[X] check list item

( ) radio list item
(*) radio list item

http://www.google.com
[google](http://www.google.com)

a block of code with ```

| A table | B1
| A2 | B2 |
| A3
 | B3

YamYam supports annotations in the markdown, which can be used for app-specific things

[section-annotation name="value" name2=value2 name3='value3']

Annotations with following empty line mark sections of the document

[annotation name = value]
[annotation name = value2]
Annotations direct before a element annotated it.
Multiple annotations supported

API

var YamYam = require("YamYam");
 
// YamYam.parse(source, function(err, result) {
// YamYam.parse(source, options, function(err, result) {
YamYam.parse(source, options, formater, function(err, result) {
    // ...
});

options

var options = {
    parser: {
        // Nothing yet
    },
    format: {
        // Options for the formater
        // depend on the used formater
    }
}
 
var formatOptions = { // For HtmlFormater (default)
    annotations: {
        // maps annotation name to a function proccessing this type
        // example:
        "@annotation": function(attrs, annotation) {
            // annotation.name === "@annotation"
            attrs["class"] = annotation.params["class"];
        }
    },
    block: undefined, // specify how sections are handled
    /*
        block: false
            the sections are emitted
            [ { annotations: [ ... ],
                content: "..." }, ... ]
        block: 4 // number
            only section number X will be returned
        block: "..." // string
            only sections which has an annotation named "..."
        block: function(section, number) { ... } // function
            true, sections is included
    */
    inline: false, // true, use only inline tags, no block level
    /* Tags config:
        { tag: "a", href: "http://www.google.com" } // full config
    or: "a" // only tagname
    or: { // things with power: *xx*, `xx`, # xx
            "1": { tag: "em", ... },
            "2": "strong",
            "default": "em" // "default" is required!
        }
    or: "" // no tag
    */
    // Example for list
    "list": "ul",
    "listItem", "li",
    // other tag config options:
    /*
        # elements
        text: simple text
        checklist, checklistItem
        radiolist, radiolistItem
        code
        codeContainer
        codeLine
        codeText
        headline
        headlineText
        table, tableBody, tableHead
        tableRow, tableCell, tableHeadCell
        line: a line when multiline is possible (text, tableCell)
        # Inline
        textItem
        link
        accent
        codeItem
        img
    */
    /* advanced options:
        line: { tag:"", _prepend: "<br/>", _prependStart: "" }
        "checklistItem", {tag: "div", _prependContent: function(buffer, item) {
            buffer.push(item.checked?"&#9745;":"&#9744;");
            buffer.push("&nbsp;");
        }}
    */
    /* see lib/HtmlFormater.js for defaults */
}

Readme

Keywords

none

Package Sidebar

Install

npm i YamYam

Weekly Downloads

1

Version

0.3.0

License

none

Last publish

Collaborators

  • sokra