Skip to content

Commit

Permalink
initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tivie committed Jan 24, 2015
1 parent fd0e98f commit 1c4c894
Show file tree
Hide file tree
Showing 18 changed files with 627 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[*.js]
indent_style = space;
indent_size = 2;
continuation_indent_size = 2;
insert_final_newline = true;
quote_type = single;
space_after_anonymous_functions = true;
space_after_control_statements = true;
spaces_around_operators = true;
trim_trailing_whitespace = true;
spaces_in_brackets = false;
curly_bracket_next_line = true;
indent_brace_style = 1TBS;
end_of_line = lf;
charset = utf-8;
90 changes: 90 additions & 0 deletions .jscs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"validateIndentation": 2,
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireOperatorBeforeLineBreak": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"validateIndentation": 2,
"validateQuoteMarks": "'",
"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"requireMultipleVarDecl": true,
"disallowKeywordsOnNewLine": ["else"],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBinaryOperators": [
"=",
"+=",
"-=",
"*=",
"/=",
"%=",
"<<=",
">>=",
">>>=",
"&=",
"|=",
"^=",
"+=",
"+",
"-",
"*",
"/",
"%",
"<<",
">>",
">>>",
"&",
"|",
"^",
"&&",
"||",
"===",
"==",
">=",
"<=",
"<",
">",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInForStatement": true,
"requireLineFeedAtFileEnd": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideParentheses": true,
"validateJSDoc": {
"checkParamNames": true,
"requireParamTypes": true
},
"disallowMultipleLineBreaks": true,
"disallowNewlineBeforeBlockStatements": true
}
28 changes: 28 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"quotmark": "single",
"undef": false,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"onevar": true,
"globals": {
"angular": true,
"module": true,
"define": true,
"window": true,
"showdown": true
}
}
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.10"

#travis build speed up
sudo: false
cache:
directories:
- node_modules
95 changes: 95 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
module.exports = function (grunt) {
'use strict';

require('shelljs/global');

var config = {
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
sourceMap: true
},
dist: {
src: ['src/*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
sourceMap: true
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js']
},
jscs: {
options: {
config: '.jscs.json',
files: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js'
]
}
},
changelog: {
options: {}
},
//Server-side tests
simplemocha: {
test: {
src: 'test/node.js',
options: {
globals: ['should'],
timeout: 3000,
ignoreLeaks: false,
reporter: 'spec'
}
}
},
// Client-side tests
mocha: {
test: {
src: ['test/browser.html'],
options: {
run: true
}
}
},
githooks: {
all: {
'pre-commit': 'pre-commit'
}
}
};

grunt.initConfig(config);

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-githooks');

grunt.registerTask('lint', ['jshint', 'jscs']);
grunt.registerTask('test', ['lint', 'mocha', 'simplemocha']);
grunt.registerTask('build', ['test', 'concat', 'uglify']);
grunt.registerTask('pre-commit', ['build', 'add-compressed-to-git']);

// Add compressed and minified files before committing
grunt.registerTask('add-compressed-to-git', function () {
exec('git add dist/');
});

grunt.registerTask('default', []);
};
62 changes: 59 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
prettify
========
Showdown's Prettify Extension
==========================

[![Build Status](https://travis-ci.org/showdownjs/prettify-extension)](https://travis-ci.org/showdownjs/prettify-extension.svg) [![npm version](https://badge.fury.io/js/showdown-prettify.svg)](http://badge.fury.io/js/showdown-prettify) [![npm version](https://badge.fury.io/bo/showdown-prettify.svg)](http://badge.fury.io/bo/showdown-prettify)

------

**An extension to add [Google Prettify](http://code.google.com/p/google-code-prettify/) hints to [showdown](https://github.com/showdownjs/showdown)'s HTML output **


## Installation

### With [npm](http://npmjs.org)

npm install showdown-prettify

### With [bower](http://bower.io/)

bower install showdown-prettify

### Manual

You can also [download the latest release zip or tarball](https://github.com/showdownjs/prettify-extension/releases) and include it in your webpage, after showdown:

<script src="showdown.min.js">
<script src="showdown-prettify.min.js">

### Enabling the extension

After including the extension in your application, you just need to enable it in showdown.

var converter = new Showdown.converter({extensions: ['prettify']});

## Example

```javascript
var converter = new Showdown.converter({extensions: ['prettify']}),
input = "Here's a simple hello world in javascript:\n" +
"\n" +
" alert('Hello World!');\n" +
"\n" +
"The `alert` function is a build-in global from `window`.";
html = converter.makeHtml(input);
console.log(html);
```

This should output the equivalent to:

```html
<p>Here's a simple hello world in javascript:</p>

<pre class="prettyprint linenums" tabIndex="0"><code data-inner="1">alert('Hello World!');
</code></pre>

<p>The <code class="prettyprint">alert</code> function is a build-in global from <code class="prettyprint">window</code>.</p>
```

## License
These files are distributed under BSD license. For more information, please check the [LICENSE file](https://github.com/showdownjs/prettify-extension/blob/master/LICENSE) in the source code.

Prettify extension for Showdown.js
34 changes: 34 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "showdown-prettify",
"description": "Add markdown prettify favor to showdown",
"homepage": "https://github.com/showdownjs/prettify-extension",
"license": "BSD",
"authors": [
"Estevão Santos (https://github.com/tivie)",
"Pascal Deschênes (https://github.com/pdeschen)",
"Corey Innis (https://github.com/coreyti)",
"John Fraser"
],
"keywords": [
"markdown",
"showdown",
"showdown extension",
"prettify"
],
"repository": {
"type": "git",
"url": "https://github.com/showdownjs/prettify-extension.git",
"web": "https://github.com/showdownjs/prettify-extension"
},
"main": ["dist/showdown-prettify.js"],
"ignore": [
"src/",
"test/",
".editorconfig",
".gitignore",
".jscs.json",
".jshintrc",
".travis.yml",
"Gruntfile.js"
]
}
39 changes: 39 additions & 0 deletions dist/showdown-prettify.js

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

1 change: 1 addition & 0 deletions dist/showdown-prettify.js.map

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

4 changes: 4 additions & 0 deletions dist/showdown-prettify.min.js

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

1 change: 1 addition & 0 deletions dist/showdown-prettify.min.js.map

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

Loading

0 comments on commit 1c4c894

Please sign in to comment.