• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ember component to render markdown into HTML.

ember-cli-showdown

Ember Observer Score

This addon provides a component that transforms Markdown into valid HTML.

  • Fastboot compatible

Compatibility

  • Ember.js v3.12 or above
  • Ember CLI v3.12 or above
  • Node.js v16 or above

Installation

  • ember install ember-cli-showdown

Usage

Passing a markdown string inline:

{{markdown-to-html "#Markdown is cool [link](http://emberjs.com)"}}
<!-- Output -->
<h1>Markdown is cool <a href="http://emberjs.com">link</a></h1>

You can also pass a bound value:

{{markdown-to-html postContent}}

Showdown Options

You can use configuration settings from Showdown:

{{markdown-to-html
  markdown=postContent
  strikethrough=true
  literalMidWordUnderscores=true
  simplifiedAutoLink=true}}

Global Showdown Options

Global options are supported as of 2.11.x. This lets you define options that will be used for showdown options that were not provided as an attribute.

An example where you always want to auto link:

// config/environment.js
module.exports = function(environment) {
  var ENV = {
    showdown: {
      simplifiedAutoLink: true
    }
  }

  return ENV;
}

Showdown Extensions

You can load Showdown Extensions by specifying the "extensions" property when initializing your component:

{{markdown-to-html
  markdown=postContent
  extensions=myExtensionList}}
{{markdown-to-html
  markdown=postContent
  extensions='foo bar baz'}}

(myExtensionList can be an array of strings or a space separated string)

Note that you'll have to register your extensions with Showdown first. For example, in an initializer:

// app/initializers/register-showdown-extensions.js
import showdown from 'showdown';

export function initialize() {
  showdown.extension("myExtensionName", function() {
    return [{
      type: 'html',
      regex: '<blockquote>',
      replace: '<blockquote class="blockquote">'
    }];
  });
}

export default {
  name: 'register-showdown-extensions',
  initialize
};

3.x to 4.3 migration

  • Global showdown is no longer supported. Must be imported via import showdown from 'showdown'
  • Remove any use of FastBoot.require('require') with import showdown from 'showdown'

Dependencies

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

More Repositories

1

empress-blog

Fully-functional, SEO friendly static site implementation of a blog system built on Ember
JavaScript
179
star
2

empress-blog-casper-template

A static site version of the default personal blogging theme for Ghost - no server required
CSS
39
star
3

broccoli-static-site-json

Build static markdown files into JSON
JavaScript
32
star
4

guidemaker

A fully-functional, static site implementation of a documentation site and is built on EmberJS and using Empress technologies
JavaScript
23
star
5

field-guide

SEO friendly static site implementation of a design system documentation site
JavaScript
17
star
6

ember-showdown-prism

JavaScript
10
star
7

empress-blog-netlify-casper-template

Repo used for the "Deploy to Netlify" button
JavaScript
8
star
8

bottled-ember

JavaScript
5
star
9

create-empress-blog-template

Utility designed to help get started quickly with an Ember Ghost Template
JavaScript
4
star
10

documentation

JavaScript
3
star
11

ecad-migrator

Designed to allow you to migrate your documentation from ember-cli-addon-docs to Field Guide
JavaScript
3
star
12

open-slide

JavaScript
2
star
13

static-postcss-addon-tree

JavaScript
2
star
14

field-guide-addon-docs-template

SEO friendly static site implementation of a documentation site
JavaScript
2
star
15

field-guide-netlify-default-template

JavaScript
1
star
16

empress-blueprint-helpers

JavaScript
1
star
17

rfc-process-mdbook-template

CSS
1
star
18

open-slide-reveal-template

JavaScript
1
star
19

guidemaker-default-template

CSS
1
star
20

training-buddy

An implementation of a "sidecar app" to be used during live-trainings, built with Empress technologies
JavaScript
1
star
21

field-guide-default-template

JavaScript
1
star
22

ember-ghost-netlify-casper-template

Repo used for the "Deploy to Netlify" button
JavaScript
1
star
23

ember-cli-deploy-prember-algolia

Algolia Indexer as ember-cli-deploy plugin
JavaScript
1
star