Code Monkey home page Code Monkey logo

angular-markdown-text's Introduction

angular-markdown-text

An easy to use markdown directive with static outlining, html escaping/sanitization, resource loading and model binding.

Demo

A demonstration can be found here.

Dependencies

Installation

Either copy the contents of the dist folder found on GitHub or install with Bower.

$ bower install angular-markdown-text
$ bower install angular-sanitize

Installation of angular-sanitize is recommended but optional; the module will detect if it's available.

Usage

The markdown directive can work with static content, model binding and external resources.

Static Content

The simplest form is wrapping the markdown directive around your text. The directive will automatically outline the content so that you don't have to worry about spaces or tabs in your html markup.

<markdown>
  # Hello World!
</markdown>

Model Binding

Provide the markdown-model attribute a model expression to convert its value to html.

<textarea ng-model="my.model"></textarea>
<markdown markdown-model="my.model"></markdown>

External Resources

The directive allows you to load markdown files from a server by specifying a url expression in the markdown-src attribute. Note that, like the ng-include attribute, this is an expression; static values should be surrounded by a single quote (').

<markdown markdown-src="'my/external/resource.md'"></markdown>

Other Attributes

These attributes are simply overrides of the configuration. If no value (true/false) is provided the default found in the markdownConfig is used.

markdown-escape-html - escape any html content.

markdown-sanitize - sanitize the html output.

markdown-outline - outline the markup.

Configuration

Global configuration can be modified by injecting the markdownConfig at the config phase of your module.

angular.module('myApp').config(function(markdownConfig){
  // Disable sanitization.
  markdownConfig.sanitize = false;
});

Configuration Properties

markdownConfig = {
  // Outline static markup
  outline: true,
  // Escape html
  escapeHtml: false,
  // Sanitize html,
  sanitize: true,
  // Showdown options
  showdown: {
    extensions: []
  }
};

angular-markdown-text's People

Contributors

mcnull avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.