Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
88 lines (65 sloc) 2.61 KB

tent-markdown-js Build Status

Tent Dialect for markdown-js.


npm install tent-markdown


### Node

var markdown = require( "tent-markdown" ).markdown;
console.log( markdown.toHTML( "Hello *World*! #firstwords", "Tent", { footnotes: [], hashtagURITemplate: '{hashtag}' } ) );
<p>Hello <strong>World</strong>! <a href="" rel="hashtag">#firstwords</a></p>

### Browser

<!DOCTYPE html>
    <textarea id="text-input" oninput="this.editor.update()"
              rows="6" cols="60">^[You](0), Type _Tent_ **Markdown** here.</textarea>
    <div id="preview"> </div>
    <script src="lib/tent-markdown.js"></script>
      function Editor(input, preview) {
        this.update = function () {
          preview.innerHTML = markdown.toHTML(input.value, 'Tent', { footnotes: [""] });
        input.editor = this;
      var $ = function (id) { return document.getElementById(id); };
      new Editor($("text-input"), $("preview"));

The above example is adapted from markdown-js.

Simply put,

  var source = "^[Example Mention](0), *Bold*, _Italic_, ~Strikethrough~, [Regular link](",
      entity_uris = [""];
  window.markdown.toHTML( source, 'Tent', { footnotes: entity_uris } )

where entity_uris is an Array of entity uris with indices mapping to integer links in the markdown source.


The jsonml may be manipulated using preprocessors before it is translated into html.

addAttributeToLinks = function ( jsonml ) {
  // Skip over anything that isn't a link
  if (jsonml[0] !== 'link') return jsonml;

  jsonml[1]['data-my-attribute'] = 'Hello World';

  return jsonml;

var markdown = require( "tent-markdown" ).markdown;
console.log( markdown.toHTML( "", "Tent", { preprocessors: [addAttributeToLinks] } ) );
<p><a href="" data-my-attribute="Hello World"></a></p>


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request