npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-cli-marked-down

v3.16.0

Published

This addon provides a means to generate html formatted markup from markdown source.

Downloads

157

Readme

ember-cli-marked-down

npm version downloads Code Climate

ember-observer-badge License

This addon provides a means to generate html formatted markup from markdown source. The ShowdownJS library is leveraged to generate the html and this addon has been designed to be globally configured at the application's environment.js level.

It is worth mentioning that Markdown was created by John Gruber and the ShowdownJS library was authored by John Fraser and is a vanilla port of Gruber's original works.

Compatibility

  • Ember.js v3.12 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install ember-cli-marked-down

Demo

Check out the demo application.

Cross-Side Scripting (XSS) Vulnerability

Notice: this addon will be converting Markdown source in the client (browser). The produced HTML is passed to Ember.String.htmlSafe(...) to attempt to filter any XSS attempts. This is not fool-proof. Know your user audience and assume all risks.

ShowdownJS

Check out ShowdownJS's wiki post about XSS for additional information.

Usage

Helpers

{{marked-down "Some __markdown__ text"}}

The helper that produces html from the supplied markdown. Override Showdown's options by passing named arguments to the helper.

Arguments

  • The markdown source String is the only unnamed argument passed into the helper.
  • Use the helper's hash to supply all other markdown options that need be applied to the cooked html. See the options listed above in the ShowdownJS Configuration section.

Examples

{{marked-down 'Some __markdown__ text'}}

...yields:

<p>Some <strong>markdown</strong> text</p>

Passing in a Showdown option:

{{marked-down 'Some ~~struck~~ markdown text' strikethrough=true}}

...yields

<p>Some <del>struck</del> markdown text</p>

Components

{{set-links-target}}

This component surrounds some html markup, searches the surrounded markup for <a> elements (links), and then proceeds to add a specified target attribute to the link should it not already have a target.

The component by default will not assign the target attribute to links that it finds that belong to the host that the application is running in. That is to say, if an app is running at http://example.com and the component find a link that starts with http://example.com, then that link will NOT have a target attribute assigned. This default behaviour can be overridden by setting the excludeSelfLinks? argument to false.

Arguments

  • excludeSelfLinks? - when true (DEFAULT) any links that are found in the component's yield that share the same host url as the Ember application will NOT have the target attribute assigned. When false all found links will have the target attribute assigned.
  • targetValue - one of the valid target values that can be passed to the target attribute of an anchor/link element. One of: _blank, _self, _parent, _top, or the name of a frame in the page. See W3Schools reference.

Examples

Default Behaviour:

{{#set-links-target excludeSelfLinks?=true targetValue='_blank'}}
  <a href='http://github.com'>GitHub</a>
{{/set-links-target}}

... will result in the following html markup:

<div class="set-links-target">
  <a href="http://github.com" target="_blank">GitHub</a>
</div>

Services

ShowdownConverter

This service sets the Showdown libraries globals from the environment.js settings; see the sample configuration above.

Initializers

ShowdownConverter

An initializer that makes sure the ShowdownConverter service is initialized for all scopes. This forces the Showdown globals to be set to the settings found in the environment.js.

ShowdownJS Configuration (Optional)

Inside the Ember application's config/environment.js, set ShowdownJS' global option preferences. Use the following example as a template:

// config/environment.js

module.exports = function (environment) {
  var ENV = {
    // ...
    APP: {
      // ...
      /**
       * Showdown global configuration settings.
       * @see https://github.com/showdownjs/showdown#valid-options
       */
      showdown: {
        /**
         * (boolean) [default false] Omit the trailing newline in a code block.
         */
        omitExtraWLInCodeBlocks: false,
        /**
         * (boolean) [default false] Disable the automatic generation of header ids. Setting to true
         * overrides prefixHeaderId
         */
        noHeaderId: false,
        /**
         * (boolean) [default false] Generate header ids compatible with github style (spaces are
         * replaced with dashes and a bunch of non alphanumeric chars are removed) (since showdown-1.5.5).
         */
        ghCompatibleHeaderId: false,
        /**
         * (string/boolean) [default false] Add a prefix to the generated header ids. Passing a
         * string will prefix that string to the header id. Setting to true will add a generic 'section' prefix.
         */
        prefixHeaderId: false,
        /**
         * (boolean) [default false] Enable support for setting image dimensions from within markdown syntax.
         */
        parseImgDimensions: false,
        /**
         * (integer) [default 1] Set the header starting level.
         */
        headerLevelStart: 1,
        /**
         * (boolean) [default false] Turning this on will enable GFM autolink style.
         */
        simplifiedAutoLink: false,
        /**
         * (boolean) [default false] This option excludes trailing punctuation from
         * autolinking urls. Punctuation excluded: . ! ? ( ). Only applies if
         * simplifiedAutoLink option is set to true.
         */
        excludeTrailingPunctuationFromURLs: false,
        /**
         * (boolean) [default false] Turning this on will stop showdown from interpreting underscores
         * in the middle of words as <em> and <strong> and instead treat them as literal underscores.
         */
        literalMidWordUnderscores: false,
        /**
         * (boolean) [default false] Enable support for strikethrough syntax.
         */
        strikethrough: false,
        /**
         * (boolean) [default false] Enable support for tables syntax.
         */
        tables: false,
        /**
         * (boolean) [default false] If enabled adds an id property to table headers tags.
         */
        tablesHeaderId: false,
        /**
         * (boolean) [default true] Enable support for GFM code block style.
         */
        ghCodeBlocks: true,
        /**
         * (boolean) [default false] Enable support for GFM takslists.
         */
        tasklists: false,
        /**
         * (boolean) [default false] Prevents weird effects in live previews due to incomplete input.
         */
        smoothLivePreview: false,
        /**
         * (boolean) [default false] Tries to smartly fix indentation problems related to es6
         * template strings in the midst of indented code.
         */
        smartIndentationFix: false,
        /**
         * (boolean) [default false] Disables the requirement of indenting sublists by
         * 4 spaces for them to be nested, effectively reverting to the old behavior where
         * 2 or 3 spaces were enough. (since showdown-1.5.0).
         */
        disableForced4SpacesIndentedSublists: false,
        /**
         * (boolean) [default false] Parses line breaks as like GitHub does, without
         * needing 2 spaces at the end of the line (since showdown-1.5.1).
         */
        simpleLineBreaks: false,
        /**
         * (boolean) [default false] Makes adding a space between # and the header text
         * mandatory (since showdown-1.5.3).
         */
        requireSpaceBeforeHeadingText: false,
        /**
         * (boolean) [default false] Enables github @mentions, which link to the username
         * mentioned (since showdown-1.6.0).
         */
        ghMentions: false,
      },
    },
  };
  // ...
  return ENV;
};

License

This project is licensed under the MIT License.