ssb-markdown
patchwork's markdown parser
Last updated 8 months ago by christianbundy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ssb-markdown 
SYNC missed versions from official npm registry.

ssb-markdown

render patchwork/ssb messages to markdown.

patchwork has a few changes from standard markdown.

  • emoji - everybody hearts emoji
  • ssb links - links to cryptographic objects see ssb-ref
  • mentions - @mentions like on twitter or github. mentions allow people to convieniently talk to each other, but are written as both the name used, plus the cryptographic reference.

api

var md = require('ssb-markdown')

md.block(source, opts)

Render raw markdown source to html. The output will be html content without a surrounding tag.

md.inline (source, opts)

Render raw markdown to a single line of test, suitable for a one line preview that is opened to a view rendered with block.

opts

An object containing custom markdown rendering functions. opts are the same for both md.block and md.inline

toUrl is a function which accepts an ssb-ref or @-mention string, and whether it is for an image or not, and returns a url string.

imageLink is a function which accepts an ssb-ref and will be used to generate links to wrap any images.

emoji is a function which accepts an emoji as markup and over-rides the default emoji rendering behavior.

usage

const opts = {
  toUrl: ref => renderUrlRef(ref),
  imageLink: ref => renderImageRef(ref),
  emoji: emojiAsMarkup => renderEmoji(emojiAsMarkup)
}

md.block(source, opts)

md.inline(source, opts)

License

MIT

Current Tags

  • 6.0.7                                ...           latest (8 months ago)

35 Versions

  • 6.0.7                                ...           8 months ago
  • 6.0.6                                ...           8 months ago
  • 6.0.5                                ...           8 months ago
  • 6.0.4                                ...           9 months ago
  • 6.0.3                                ...           10 months ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.1.3                                ...           a year ago
  • 5.1.2                                ...           a year ago
  • 5.1.1                                ...           a year ago
  • 5.1.0                                ...           a year ago
  • 5.0.2                                ...           a year ago
  • 5.0.1                                ...           a year ago
  • 5.0.0                                ...           a year ago
  • 4.1.2                                ...           a year ago
  • 4.1.1                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.6.0                                ...           3 years ago
  • 3.5.0                                ...           3 years ago
  • 3.3.1                                ...           3 years ago
  • 3.3.0                                ...           4 years ago
  • 3.2.1                                ...           4 years ago
  • 3.1.1                                ...           4 years ago
  • 3.2.0                                ...           4 years ago
  • 3.1.0                                ...           4 years ago
  • 3.0.0                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago

Copyright 2014 - 2016 © taobao.org |