Skip to content

Commit

Permalink
Merge pull request #11 from showdownjs/develop
Browse files Browse the repository at this point in the history
ng-showdown 1.0.0
  • Loading branch information
SyntaxRules committed Jul 18, 2015
2 parents 0995d83 + a1d25d2 commit a4de859
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 61 deletions.
10 changes: 8 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ module.exports = function (grunt) {
reporter: 'spec'
}
}
},
karma: {
unit: {
configFile: 'karma.conf.js'
}
}
};

Expand All @@ -82,10 +87,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-karma');

grunt.registerTask('lint', ['jshint', 'jscs']);
grunt.registerTask('test', ['lint', 'concat', 'simplemocha']);
grunt.registerTask('test-without-building', ['simplemocha']);
grunt.registerTask('test', ['lint', 'concat', 'karma']);
grunt.registerTask('test-without-building', ['karma']);
grunt.registerTask('build', ['lint', 'test', 'uglify']);

// Default task(s).
Expand Down
72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,70 @@
ng-showdown
================
# ng-showdown

Angular integration for [Showdown](https://github.com/showdownjs/showdown)

## How to use it

1. Install it

a. via bower:
```
bower install --save ng-showdown
```
b. via npm
```
npm install --save ng-showdown
```
2. Include `'ng-showdown'` in your module dependencies
3. Use it
```
<p markdown-to-html="vm.mymarkdown"></p>
```

## API

#### `$showdown`

`$showdown.makeHtml(markdown)` - Converts a markdown text into HTML

Input: *string* - markdown to be parsed

Output: *string* - html output from showdown

`$showdown.stripHtml` - Strips a text of it's HTML tags. See http://stackoverflow.com/questions/17289448/angularjs-to-output-plain-text-instead-of-html

Input: *string* - html to be striped

Output: *string* - string without `<html>` tags

#### `markdownToHtml` directive

Example usage:
```
<p markdown-to-html="vm.mymarkdown"></p>
```

Input: *string* - markdown to be parsed

Output: *string* - html output from showdown

#### `stripHtml` filter

Example usage:
```
<p ng-bind="vm.someText | stripHtml"></p>
```

Input: *string* - Input to be stripped of html

Output: *string* - stripped html

## Configuration

You can configure the options and extensions passed to showdown by useing the `$showdownProvider`. To see these options, visit the [Showdown page](https://github.com/showdownjs/showdown).

`$showdownProvider.setOption(key, value)` - sets the passed in option as a configuration option in showdown

`$showdownProvider.getOption(key)` - get the option as determined by the passed in key.

`$showdownProvider.loadExtension(extensionName)` - loads the extension into showdown as determined by the passed in extension name

Angular integration for Showdown
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
".*",
"Gruntfile.js",
"package.json",
"karma.conf.js",
"src",
"test"
],
Expand All @@ -21,13 +22,14 @@
"url": "https://github.com/showdownjs/ng-showdown.git"
},
"dependencies": {
"showdown": "1.0.*",
"showdown": "1.x",
"angular": ">=1.3.0 <2.0.0",
"angular-sanitize": ">=1.3.0 <2.0.0"
},
"keywords": [
"markdown",
"showdown",
"ng-showdown",
"md",
"mdown",
"angular"
Expand Down
47 changes: 22 additions & 25 deletions dist/ng-showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ng-showdown.js.map

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = function (config) {
'use strict';
config.set({

basePath: '',

frameworks: ['mocha', 'chai'],

files: [
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/showdown/dist/showdown.js',
'src/*.js',
'test/**/*.spec.js'
],

reporters: ['coverage'],

preprocessors: {
'src/**/*.js' : ['progress', 'coverage']
},

//plugins: [
// 'karma-chai',
// 'karma-coverage',
// 'karma-mocha',
// 'karma-phantomjs-launcher'
//],

coverageReporter: {
type: 'html',
dir: 'coverage'
},

port: 9876,
colors: true,
autoWatch: false,
singleRun: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

browsers: ['PhantomJS']

});
};
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"name": "ng-showdown",
"version": "1.0.0",
"description": "Official Showdown integration with AngularJS",
"author": "Estevão Santos",
"contributors": [
"Estevão Santos",
"Devyn Stott"
"authors": [
"Estevão Santos (https://github.com/tivie)",
"SyntaxRules (https://github.com/SyntaxRules)"
],
"repository": {
"type": "git",
Expand All @@ -19,7 +18,7 @@
},
"dependencies": {
"angular": "^1.3.2",
"showdown": "1.0.x",
"showdown": "1.x",
"angular-sanitize": "^1.3.2"
},
"devDependencies": {
Expand All @@ -30,9 +29,16 @@
"grunt-contrib-uglify": "^0.6.0",
"grunt-conventional-changelog": "^1.1.0",
"grunt-jscs": "^1.2.0",
"grunt-karma": "^0.11.2",
"grunt-simple-mocha": "^0.4.0",
"jscs": "^1.10.0",
"karma": "^0.12.37",
"karma-chai": "^0.1.0",
"karma-coverage": "^0.4.2",
"karma-mocha": "^0.2.0",
"karma-phantomjs-launcher": "^0.2.0",
"mocha": "*",
"phantomjs": "^1.9.17",
"should": "^4.4.2",
"source-map-support": "^0.2.9"
}
Expand Down
Loading

0 comments on commit a4de859

Please sign in to comment.