Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-marked

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-marked

AngularJS Markdown using marked.

  • 0.0.18
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
decreased by-20.18%
Maintainers
1
Weekly downloads
 
Created
Source

angular-marked Bower version

===

AngularJS Markdown using marked.

Please note: neither this directive nor marked (by default) implement sanitization. As always, sanitizing is necessary for user-generated content.

get this with bower

Usage

  1. bower install angular-marked or bower install Hypercubed/angular-marked
  2. Include the marked.js script into your app. By default should be at bower_components/marked/lib/marked.js.
  3. Include the angular-marked.js into your app. By default should be at bower_components/angular-marked/angular-marked.js.
  4. Add hc.marked as a module dependency to your app.

Set default options (optional)

    app.config(['markedProvider', function(markedProvider) {
      markedProvider.setOptions({gfm: true});
    }]);

Example using highlight.js Javascript syntax highlighter (must include highlight.js script).

    markedProvider.setOptions({
      gfm: true,
      tables: true,
      highlight: function (code) {
        return hljs.highlightAuto(code).value;
      }
    });

Example overriding the way custom markdown links are displayed to open in new windows:

    app.config(['markedProvider', function(markedProvider) {
      markedProvider.setRenderer({
        link: function(href, title, text) {
          return "<a href='" + href + "' title='" + title + "' target='_blank'>" + text + "</a>";
        }
      });
    }]);

As a directive

    <marked>
         #Markdown directive
         *It works!*  
    </marked>

Bind the markdown input to a scope variable:

    <div marked="my_markdown">
    </div>
    <!-- Uses $scope.my_markdown -->

Include a markdown file:

    <div marked ng-include="'README.md'">
    </div>
    <!-- Uses markdown content from README.md -->

As a service

    app.controller('myCtrl', ['marked', function(marked) {
      $scope.html = marked('#TEST');
    }]);

Testing

Install npm and bower dependencies:

    npm install
    bower install
    npm test

Why?

I wanted to use marked instead of showdown as used in angular-markdown-directive as well as expose the option to globally set defaults. Yes, it is probably best to avoid creating a bunch of angular wrapper modules... but I use this enough across multiple projects to make it worth while for me. Use it if you like. Pull requests are welcome.

Acknowledgments

Based on angular-markdown-directive by briantford which, in turn, is based on this excellent tutorial by @johnlinquist.

License

Copyright (c) 2013 Jayson Harshbarger Gittip donate button Paypal donate button

MIT License

Keywords

FAQs

Package last updated on 15 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc