├── test ├── fixtures │ ├── highlight.md │ ├── unescape-es6.md │ ├── file.md │ ├── linkify.md │ ├── unescape-ejs.md │ └── unescape-hbs.md ├── expected │ ├── unescape-es6.html │ ├── file.html │ ├── linkify.html │ ├── unescape-ejs.html │ ├── highlight.html │ └── unescape-hbs.html └── test.js ├── .travis.yml ├── .gitattributes ├── .editorconfig ├── .gitignore ├── utils.js ├── LICENSE ├── middleware.js ├── package.json ├── index.js ├── .verb.md ├── .eslintrc.json ├── .github └── contributing.md └── README.md /test/fixtures/highlight.md: -------------------------------------------------------------------------------- 1 | # should highlight 2 | 3 | ```js 4 | var foo = 'bar'; 5 | ``` 6 | -------------------------------------------------------------------------------- /test/fixtures/unescape-es6.md: -------------------------------------------------------------------------------- 1 | # es6 templates 2 | 3 | ${foo} 4 | ${foo.bar} 5 | ${"foo.bar"} -------------------------------------------------------------------------------- /test/fixtures/file.md: -------------------------------------------------------------------------------- 1 | # Foo 2 | 3 | > This is a blockquote 4 | 5 | This is a paragraph 6 | 7 | -------------------------------------------------------------------------------- /test/fixtures/linkify.md: -------------------------------------------------------------------------------- 1 | # should linkify 2 | 3 | https://github.com/jonschlinkert/remarkable 4 | -------------------------------------------------------------------------------- /test/expected/unescape-es6.html: -------------------------------------------------------------------------------- 1 |
${foo} 3 | ${foo.bar} 4 | ${"foo.bar"}
5 | -------------------------------------------------------------------------------- /test/expected/file.html: -------------------------------------------------------------------------------- 1 |3 |5 |This is a blockquote
4 |
This is a paragraph
6 | -------------------------------------------------------------------------------- /test/expected/linkify.html: -------------------------------------------------------------------------------- 1 |https://github.com/jonschlinkert/remarkable
3 | -------------------------------------------------------------------------------- /test/fixtures/unescape-ejs.md: -------------------------------------------------------------------------------- 1 | # ejs templates 2 | 3 | <%= foo %> 4 | <%- foo %> 5 | <% foo %> 6 | <% _.forEach(users, function(user) { %><%= foo %> 3 | <%- foo %> 4 | <% foo %> 5 | <% _.forEach(users, function(user) { %>
var foo = 'bar';
3 |
4 |
--------------------------------------------------------------------------------
/test/fixtures/unescape-hbs.md:
--------------------------------------------------------------------------------
1 | # Templates
2 |
3 | > Should fix escaped handlebars templates
4 |
5 | This is a {{template}}
6 | This is a {{template foo="bar"}}
7 |
8 | This is a {{> partial }}
9 |
10 | This is a block helper
11 | {{#each foo as |bar|}}
12 | {{bar}}
13 | {{/each}}
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | end_of_line = lf
6 | charset = utf-8
7 | indent_size = 2
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [{**/{actual,fixtures,expected,templates}/**,*.md}]
12 | trim_trailing_whitespace = false
13 | insert_final_newline = false
--------------------------------------------------------------------------------
/test/expected/unescape-hbs.html:
--------------------------------------------------------------------------------
1 | 3 |5 |Should fix escaped handlebars templates
4 |
This is a {{template}} 6 | This is a {{template foo="bar"}}
7 |This is a {{> partial }}
8 |This is a block helper 9 | {{#each foo as |bar|}} 10 | {{bar}} 11 | {{/each}}
12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # always ignore files 2 | *.DS_Store 3 | *.sublime-* 4 | 5 | # test related, or directories generated by tests 6 | test/actual 7 | actual 8 | coverage 9 | .nyc* 10 | 11 | # npm 12 | node_modules 13 | npm-debug.log 14 | 15 | # yarn 16 | yarn.lock 17 | yarn-error.log 18 | 19 | # misc 20 | _gh_pages 21 | _draft 22 | _drafts 23 | bower_components 24 | vendor 25 | temp 26 | tmp 27 | TODO.md 28 | package-lock.json -------------------------------------------------------------------------------- /utils.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var utils = require('lazy-cache')(require); 4 | var fn = require; 5 | require = utils; 6 | 7 | /** 8 | * Lazily required module dependencies 9 | */ 10 | 11 | require('extend-shallow', 'extend'); 12 | require('highlight.js', 'hljs'); 13 | require('plugin-error', 'PluginError'); 14 | require('remarkable', 'Remarkable'); 15 | require('through2', 'through'); 16 | require('unescape', 'decode'); 17 | require = fn; 18 | 19 | /** 20 | * Expose `utils` modules 21 | */ 22 | 23 | module.exports = utils; 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017, Jon Schlinkert 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /middleware.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var utils = require('./utils'); 5 | 6 | /** 7 | * convert markdown to HTML 8 | */ 9 | 10 | module.exports = function(options) { 11 | var defaults = { 12 | html: true, 13 | linkify: true, 14 | highlight: function(code, lang) { 15 | if (lang && utils.hljs.getLanguage(lang)) { 16 | try { 17 | return utils.hljs.highlight(lang, code).value; 18 | } catch (err) {} 19 | } 20 | 21 | try { 22 | return utils.hljs.highlightAuto(code).value; 23 | } catch (err) {} 24 | return code; 25 | } 26 | }; 27 | 28 | var opts = utils.extend({}, defaults, options); 29 | 30 | return function(file, next) { 31 | if (file.isNull()) { 32 | next(); 33 | return; 34 | } 35 | 36 | if (path.extname(file.history[0]) !== '.md') { 37 | next(); 38 | return; 39 | } 40 | 41 | var md = opts.remarkable || new utils.Remarkable(opts); 42 | var str = md.render(file.contents.toString()); 43 | file._renderedMarkdown = true; 44 | file.contents = new Buffer(str); 45 | file.extname = '.html'; 46 | next(); 47 | }; 48 | }; 49 | 50 | /** 51 | * Decode template delimiters that were encoded/escaped when 52 | * markdown was converted. 53 | */ 54 | 55 | module.exports.unescape = function(options) { 56 | return function(file, next) { 57 | if (file._renderedMarkdown !== true) { 58 | next(); 59 | return; 60 | } 61 | 62 | file.contents = new Buffer(unescape(file.contents.toString())); 63 | next(null, file); 64 | }; 65 | }; 66 | 67 | function unescape(str) { 68 | var regex = /(?:\{{2,4}(.+?)\}{2,4}|<%(.+)?%>|\$\{(.+)?\})/g; 69 | return str.replace(regex, function(m) { 70 | return utils.decode(m, 'all'); 71 | }); 72 | } 73 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assemble-remarkable", 3 | "description": "Assemble pipeline plugin for remarkable, the markdown converter for node.js. Can also be used with gulp.", 4 | "version": "1.1.5", 5 | "homepage": "https://github.com/assemble/assemble-remarkable", 6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)", 7 | "repository": "assemble/assemble-remarkable", 8 | "bugs": { 9 | "url": "https://github.com/assemble/assemble-remarkable/issues" 10 | }, 11 | "license": "MIT", 12 | "files": [ 13 | "index.js", 14 | "middleware.js", 15 | "utils.js" 16 | ], 17 | "main": "index.js", 18 | "engines": { 19 | "node": ">=4" 20 | }, 21 | "scripts": { 22 | "test": "mocha" 23 | }, 24 | "dependencies": { 25 | "extend-shallow": "^2.0.1", 26 | "highlight.js": "^9.12.0", 27 | "lazy-cache": "^2.0.2", 28 | "plugin-error": "^0.1.2", 29 | "remarkable": "^1.7.1", 30 | "through2": "^2.0.3", 31 | "unescape": "^1.0.1" 32 | }, 33 | "devDependencies": { 34 | "gulp-format-md": "^0.1.12", 35 | "mocha": "^3.4.2", 36 | "vinyl": "^2.0.2" 37 | }, 38 | "keywords": [ 39 | "assemble", 40 | "boilerplate", 41 | "build", 42 | "cli", 43 | "cli-app", 44 | "command-line", 45 | "create", 46 | "dev", 47 | "development", 48 | "framework", 49 | "front", 50 | "frontend", 51 | "plugin", 52 | "project", 53 | "projects", 54 | "remarkable", 55 | "scaffold", 56 | "scaffolder", 57 | "scaffolding", 58 | "template", 59 | "templates", 60 | "webapp", 61 | "yeoman", 62 | "yo" 63 | ], 64 | "verb": { 65 | "toc": false, 66 | "layout": "default", 67 | "tasks": [ 68 | "readme" 69 | ], 70 | "related": { 71 | "highlight": "gulp-breakdance", 72 | "list": [ 73 | "breakdance", 74 | "gulp-html-toc", 75 | "gulp-htmlmin", 76 | "gulp-remarkable", 77 | "remarkable" 78 | ] 79 | }, 80 | "plugins": [ 81 | "gulp-format-md" 82 | ], 83 | "lint": { 84 | "reflinks": true 85 | }, 86 | "reflinks": [ 87 | "assemble", 88 | "highlight.js", 89 | "remarkable" 90 | ] 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var utils = require('./utils'); 5 | 6 | /** 7 | * convert markdown to HTML 8 | */ 9 | 10 | module.exports = function(options) { 11 | var defaults = { 12 | html: true, 13 | linkify: true, 14 | highlight: function(code, lang) { 15 | if (lang && utils.hljs.getLanguage(lang)) { 16 | try { 17 | return utils.hljs.highlight(lang, code).value; 18 | } catch (err) {} 19 | } 20 | 21 | try { 22 | return utils.hljs.highlightAuto(code).value; 23 | } catch (err) {} 24 | return code; 25 | } 26 | }; 27 | 28 | var opts = utils.extend({}, defaults, options); 29 | 30 | return utils.through.obj(function(file, enc, next) { 31 | if (file.isNull()) { 32 | next(null, file); 33 | return; 34 | } 35 | 36 | if (path.extname(file.history[0]) !== '.md') { 37 | next(null, file); 38 | return; 39 | } 40 | 41 | try { 42 | var md = opts.remarkable || new utils.Remarkable(opts); 43 | var str = md.render(file.contents.toString()); 44 | file._renderedMarkdown = true; 45 | file.contents = new Buffer(str); 46 | file.extname = '.html'; 47 | } catch (err) { 48 | this.emit('error', new utils.PluginError('remarkable', err, {fileName: file.path})); 49 | return; 50 | } 51 | next(null, file); 52 | }); 53 | }; 54 | 55 | /** 56 | * Decode template delimiters that were encoded/escaped when 57 | * markdown was converted. 58 | */ 59 | 60 | module.exports.unescape = function(options) { 61 | return utils.through.obj(function(file, enc, next) { 62 | if (file._renderedMarkdown !== true) { 63 | next(null, file); 64 | return; 65 | } 66 | try { 67 | var str = file.contents.toString(); 68 | file.contents = new Buffer(unescapeFn(str)); 69 | } catch (err) { 70 | this.emit('error', new utils.PluginError('unescape', err, {fileName: file.path})); 71 | return; 72 | } 73 | next(null, file); 74 | }); 75 | }; 76 | 77 | function unescapeFn(str) { 78 | var regex = /(?:\{{2,4}(.+?)\}{2,4}|<%(.+)?%>|\$\{(.+)?\})/g; 79 | return str.replace(regex, function(m) { 80 | return utils.decode(m, 'all'); 81 | }); 82 | } 83 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('mocha'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var File = require('vinyl'); 7 | var assert = require('assert'); 8 | var remarkable = require('..'); 9 | 10 | var cwd = path.join.bind(path, __dirname); 11 | function read(filepath) { 12 | return fs.readFileSync(filepath, 'utf8'); 13 | } 14 | function fixture(name) { 15 | return cwd('fixtures', name + '.md'); 16 | } 17 | function expected(name) { 18 | return read(cwd('expected', name + '.html')); 19 | } 20 | 21 | describe('assemble-remarkable', function() { 22 | it('should not fail when file does not exist', function(cb) { 23 | var stream = remarkable(); 24 | var buffer = []; 25 | 26 | stream.write(new File({ 27 | base: __dirname, 28 | path: __dirname + '/file.txt' 29 | })); 30 | 31 | stream.on('data', function(file) { 32 | buffer.push(file); 33 | }); 34 | 35 | stream.on('end', function() { 36 | assert(buffer[0].extname, '.txt'); 37 | cb(); 38 | }); 39 | 40 | stream.end(); 41 | }); 42 | 43 | it('should convert a markdown file to HTML', function(cb) { 44 | unit('file', {}, cb); 45 | }); 46 | 47 | it('should unescape handlebars templates by default', function(cb) { 48 | unit('unescape-hbs', {}, cb); 49 | }); 50 | 51 | it('should unescape ejs templates by default', function(cb) { 52 | unit('unescape-ejs', {}, cb); 53 | }); 54 | 55 | it('should unescape es6 templates by default', function(cb) { 56 | unit('unescape-es6', {}, cb); 57 | }); 58 | 59 | it('should linkify by default', function(cb) { 60 | unit('linkify', {}, cb); 61 | }); 62 | 63 | it('should highlight by default', function(cb) { 64 | unit('highlight', {}, cb); 65 | }); 66 | }); 67 | 68 | function unit(filename, options, cb) { 69 | var stream = remarkable(options) 70 | var buffer = []; 71 | 72 | var filepath = fixture(filename); 73 | stream.write(new File({ 74 | base: cwd(), 75 | path: filepath, 76 | contents: fs.readFileSync(filepath) 77 | })) 78 | 79 | stream.pipe(remarkable.unescape()); 80 | stream.on('data', function(file) { 81 | buffer.push(file); 82 | }); 83 | 84 | stream.on('end', function() { 85 | assert.equal(buffer.length, 1); 86 | assert.equal(buffer[0].contents.toString(), expected(filename)); 87 | cb(); 88 | }); 89 | 90 | stream.end(); 91 | } 92 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | ## Heads up! 2 | 3 | Please report all bugs related to markdown-to-HTML conversion on the [remarkable issue tracker](https://github.com/remarkable/jonschlinkert/issues). 4 | 5 | ## Assemble usage 6 | 7 | Visit [remarkable](http://github.com/jonschlinkert/remarkable) for all available features and options. 8 | 9 | ```js 10 | var remarkable = require('{%= name %}'); 11 | var assemble = require('assemble'); 12 | var app = module.exports = assemble(); 13 | 14 | app.task('remarkable', function() { 15 | return app.src('foo/*.md') 16 | .pipe(remarkable([options])) 17 | .pipe(remarkable.unescape()) //<= optionally decode entities after converting to markdown 18 | .pipe(app.dest('bar')); 19 | }); 20 | ``` 21 | 22 | _(`.md` file extensions are automatically converted to `.html`)_ 23 | 24 | ## Gulp usage 25 | 26 | Visit [remarkable](http://github.com/jonschlinkert/remarkable) for all available features and options. 27 | 28 | ```js 29 | var gulp = require('gulp'); 30 | var remarkable = require('{%= name %}'); 31 | 32 | gulp.task('remarkable', function() { 33 | return gulp.src('foo/*.md') 34 | .pipe(remarkable([options])) 35 | .pipe(remarkable.unescape()) //<= optionally decode entities after converting to markdown 36 | .pipe(gulp.dest('bar')); 37 | }); 38 | ``` 39 | 40 | _(`.md` file extensions are automatically converted to `.html`)_ 41 | 42 | 43 | ## Options 44 | 45 | This plugin uses the following defaults: 46 | 47 | _(All options are passed to [remarkable][], and all other defaults besides those listed below are the same as remarkable's defaults.)_ 48 | 49 | ```js 50 | var defaults = { 51 | html: true, 52 | linkify: true, 53 | highlight: function(code, lang) { 54 | if (lang && hljs.getLanguage(lang)) { 55 | try { 56 | return hljs.highlight(lang, code).value; 57 | } catch (err) {} 58 | } 59 | 60 | try { 61 | return hljs.highlightAuto(code).value; 62 | } catch (err) {} 63 | return code; 64 | } 65 | }; 66 | ``` 67 | 68 | ### options.highlight 69 | 70 | _(Differs from remarkable defaults)_ 71 | 72 | [highlight.js][] is used for highlighting code examples by default. Override this or disable it by setting `options.highlight` to `false` or any value supported by remarkable. 73 | 74 | ```js 75 | // disable highlighting 76 | remarkable({highlight: false}); 77 | 78 | // custom highlighting 79 | remarkable({ 80 | highlight: function() { 81 | // do highlighting stuff 82 | } 83 | }); 84 | ``` 85 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ecmaFeatures": { 3 | "modules": true, 4 | "experimentalObjectRestSpread": true 5 | }, 6 | 7 | "env": { 8 | "browser": false, 9 | "es6": true, 10 | "node": true, 11 | "mocha": true 12 | }, 13 | 14 | "globals": { 15 | "document": false, 16 | "navigator": false, 17 | "window": false 18 | }, 19 | 20 | "rules": { 21 | "accessor-pairs": 2, 22 | "arrow-spacing": [2, { "before": true, "after": true }], 23 | "block-spacing": [2, "always"], 24 | "brace-style": [2, "1tbs", { "allowSingleLine": true }], 25 | "comma-dangle": [2, "never"], 26 | "comma-spacing": [2, { "before": false, "after": true }], 27 | "comma-style": [2, "last"], 28 | "constructor-super": 2, 29 | "curly": [2, "multi-line"], 30 | "dot-location": [2, "property"], 31 | "eol-last": 2, 32 | "eqeqeq": [2, "allow-null"], 33 | "generator-star-spacing": [2, { "before": true, "after": true }], 34 | "handle-callback-err": [2, "^(err|error)$" ], 35 | "indent": [2, 2, { "SwitchCase": 1 }], 36 | "key-spacing": [2, { "beforeColon": false, "afterColon": true }], 37 | "keyword-spacing": [2, { "before": true, "after": true }], 38 | "new-cap": [2, { "newIsCap": true, "capIsNew": false }], 39 | "new-parens": 2, 40 | "no-array-constructor": 2, 41 | "no-caller": 2, 42 | "no-class-assign": 2, 43 | "no-cond-assign": 2, 44 | "no-const-assign": 2, 45 | "no-control-regex": 2, 46 | "no-debugger": 2, 47 | "no-delete-var": 2, 48 | "no-dupe-args": 2, 49 | "no-dupe-class-members": 2, 50 | "no-dupe-keys": 2, 51 | "no-duplicate-case": 2, 52 | "no-empty-character-class": 2, 53 | "no-eval": 2, 54 | "no-ex-assign": 2, 55 | "no-extend-native": 2, 56 | "no-extra-bind": 2, 57 | "no-extra-boolean-cast": 2, 58 | "no-extra-parens": [2, "functions"], 59 | "no-fallthrough": 2, 60 | "no-floating-decimal": 2, 61 | "no-func-assign": 2, 62 | "no-implied-eval": 2, 63 | "no-inner-declarations": [2, "functions"], 64 | "no-invalid-regexp": 2, 65 | "no-irregular-whitespace": 2, 66 | "no-iterator": 2, 67 | "no-label-var": 2, 68 | "no-labels": 2, 69 | "no-lone-blocks": 2, 70 | "no-mixed-spaces-and-tabs": 2, 71 | "no-multi-spaces": 2, 72 | "no-multi-str": 2, 73 | "no-multiple-empty-lines": [2, { "max": 1 }], 74 | "no-native-reassign": 0, 75 | "no-negated-in-lhs": 2, 76 | "no-new": 2, 77 | "no-new-func": 2, 78 | "no-new-object": 2, 79 | "no-new-require": 2, 80 | "no-new-wrappers": 2, 81 | "no-obj-calls": 2, 82 | "no-octal": 2, 83 | "no-octal-escape": 2, 84 | "no-proto": 0, 85 | "no-redeclare": 2, 86 | "no-regex-spaces": 2, 87 | "no-return-assign": 2, 88 | "no-self-compare": 2, 89 | "no-sequences": 2, 90 | "no-shadow-restricted-names": 2, 91 | "no-spaced-func": 2, 92 | "no-sparse-arrays": 2, 93 | "no-this-before-super": 2, 94 | "no-throw-literal": 2, 95 | "no-trailing-spaces": 0, 96 | "no-undef": 2, 97 | "no-undef-init": 2, 98 | "no-unexpected-multiline": 2, 99 | "no-unneeded-ternary": [2, { "defaultAssignment": false }], 100 | "no-unreachable": 2, 101 | "no-unused-vars": [2, { "vars": "all", "args": "none" }], 102 | "no-useless-call": 0, 103 | "no-with": 2, 104 | "one-var": [0, { "initialized": "never" }], 105 | "operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }], 106 | "padded-blocks": [0, "never"], 107 | "quotes": [2, "single", "avoid-escape"], 108 | "radix": 2, 109 | "semi": [2, "always"], 110 | "semi-spacing": [2, { "before": false, "after": true }], 111 | "space-before-blocks": [2, "always"], 112 | "space-before-function-paren": [2, "never"], 113 | "space-in-parens": [2, "never"], 114 | "space-infix-ops": 2, 115 | "space-unary-ops": [2, { "words": true, "nonwords": false }], 116 | "spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }], 117 | "use-isnan": 2, 118 | "valid-typeof": 2, 119 | "wrap-iife": [2, "any"], 120 | "yoda": [2, "never"] 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /.github/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to assemble-remarkable 2 | 3 | First and foremost, thank you! We appreciate that you want to contribute to assemble-remarkable, your time is valuable, and your contributions mean a lot to us. 4 | 5 | ## Important! 6 | 7 | By contributing to this project, you: 8 | 9 | * Agree that you have authored 100% of the content 10 | * Agree that you have the necessary rights to the content 11 | * Agree that you have received the necessary permissions from your employer to make the contributions (if applicable) 12 | * Agree that the content you contribute may be provided under the Project license(s) 13 | 14 | ## Getting started 15 | 16 | **What does "contributing" mean?** 17 | 18 | Creating an issue is the simplest form of contributing to a project. But there are many ways to contribute, including the following: 19 | 20 | - Updating or correcting documentation 21 | - Feature requests 22 | - Bug reports 23 | 24 | If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) has a lot of useful information. 25 | 26 | **Showing support for assemble-remarkable** 27 | 28 | Please keep in mind that open source software is built by people like you, who spend their free time creating things the rest the community can use. 29 | 30 | Don't have time to contribute? No worries, here are some other ways to show your support for assemble-remarkable: 31 | 32 | - star the [project](https://github.com/jonschlinkert/assemble-remarkable) 33 | - tweet your support for assemble-remarkable 34 | 35 | ## Issues 36 | 37 | ### Before creating an issue 38 | 39 | Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. Oftentimes the readme will have advice about where to go to create issues. 40 | 41 | Try to follow these guidelines 42 | 43 | - **Avoid creating issues for implementation help**. It's much better for discoverability, SEO, and semantics - to keep the issue tracker focused on bugs and feature requests - to ask implementation-related questions on [stackoverflow.com][so] 44 | - **Investigate the issue**: 45 | - **Check the readme** - oftentimes you will find notes about creating issues, and where to go depending on the type of issue. 46 | - Create the issue in the appropriate repository. 47 | 48 | ### Creating an issue 49 | 50 | Please be as descriptive as possible when creating an issue. Give us the information we need to successfully answer your question or address your issue by answering the following in your issue: 51 | 52 | - **version**: please note the version of assemble-remarkable are you using 53 | - **extensions, plugins, helpers, etc** (if applicable): please list any extensions you're using 54 | - **error messages**: please paste any error messages into the issue, or a [gist](https://gist.github.com/) 55 | 56 | ### Closing issues 57 | 58 | The original poster or the maintainer's of assemble-remarkable may close an issue at any time. Typically, but not exclusively, issues are closed when: 59 | 60 | - The issue is resolved 61 | - The project's maintainers have determined the issue is out of scope 62 | - An issue is clearly a duplicate of another issue, in which case the duplicate issue will be linked. 63 | - A discussion has clearly run its course 64 | 65 | 66 | ## Next steps 67 | 68 | **Tips for creating idiomatic issues** 69 | 70 | Spending just a little extra time to review best practices and brush up on your contributing skills will, at minimum, make your issue easier to read, easier to resolve, and more likely to be found by others who have the same or similar issue in the future. At best, it will open up doors and potential career opportunities by helping you be at your best. 71 | 72 | The following resources were hand-picked to help you be the most effective contributor you can be: 73 | 74 | - The [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) is a great place for newcomers to start, but there is also information for experienced contributors there. 75 | - Take some time to learn basic markdown. We can't stress this enough. Don't start pasting code into GitHub issues before you've taken a moment to review this [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) 76 | - The GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/) is another great markdown resource. 77 | - Learn about [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/). And if you want to really go above and beyond, read [mastering markdown](https://guides.github.com/features/mastering-markdown/). 78 | 79 | At the very least, please try to: 80 | 81 | - Use backticks to wrap code. This ensures that it retains its formatting and isn't modified when it's rendered by GitHub, and makes the code more readable to others 82 | - When applicable, use syntax highlighting by adding the correct language name after the first "code fence" 83 | 84 | 85 | [so]: http://stackoverflow.com/questions/tagged/assemble-remarkable 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # assemble-remarkable [](https://www.npmjs.com/package/assemble-remarkable) [](https://npmjs.org/package/assemble-remarkable) [](https://npmjs.org/package/assemble-remarkable) [](https://travis-ci.org/assemble/assemble-remarkable) 2 | 3 | > Assemble pipeline plugin for remarkable, the markdown converter for node.js. Can also be used with gulp. 4 | 5 | You might also be interested in [gulp-breakdance](https://github.com/breakdance/gulp-breakdance). 6 | 7 | ## Install 8 | 9 | Install with [npm](https://www.npmjs.com/): 10 | 11 | ```sh 12 | $ npm install --save assemble-remarkable 13 | ``` 14 | 15 | ## Heads up! 16 | 17 | Please report all bugs related to markdown-to-HTML conversion on the [remarkable issue tracker](https://github.com/remarkable/jonschlinkert/issues). 18 | 19 | ## Assemble usage 20 | 21 | Visit [remarkable](http://github.com/jonschlinkert/remarkable) for all available features and options. 22 | 23 | ```js 24 | var remarkable = require('assemble-remarkable'); 25 | var assemble = require('assemble'); 26 | var app = module.exports = assemble(); 27 | 28 | app.task('remarkable', function() { 29 | return app.src('foo/*.md') 30 | .pipe(remarkable([options])) 31 | .pipe(remarkable.unescape()) //<= optionally decode entities after converting to markdown 32 | .pipe(app.dest('bar')); 33 | }); 34 | ``` 35 | 36 | _(`.md` file extensions are automatically converted to `.html`)_ 37 | 38 | ## Gulp usage 39 | 40 | Visit [remarkable](http://github.com/jonschlinkert/remarkable) for all available features and options. 41 | 42 | ```js 43 | var gulp = require('gulp'); 44 | var remarkable = require('assemble-remarkable'); 45 | 46 | gulp.task('remarkable', function() { 47 | return gulp.src('foo/*.md') 48 | .pipe(remarkable([options])) 49 | .pipe(remarkable.unescape()) //<= optionally decode entities after converting to markdown 50 | .pipe(gulp.dest('bar')); 51 | }); 52 | ``` 53 | 54 | _(`.md` file extensions are automatically converted to `.html`)_ 55 | 56 | ## Options 57 | 58 | This plugin uses the following defaults: 59 | 60 | _(All options are passed to [remarkable](https://github.com/jonschlinkert/remarkable), and all other defaults besides those listed below are the same as remarkable's defaults.)_ 61 | 62 | ```js 63 | var defaults = { 64 | html: true, 65 | linkify: true, 66 | highlight: function(code, lang) { 67 | if (lang && hljs.getLanguage(lang)) { 68 | try { 69 | return hljs.highlight(lang, code).value; 70 | } catch (err) {} 71 | } 72 | 73 | try { 74 | return hljs.highlightAuto(code).value; 75 | } catch (err) {} 76 | return code; 77 | } 78 | }; 79 | ``` 80 | 81 | ### options.highlight 82 | 83 | _(Differs from remarkable defaults)_ 84 | 85 | [highlight.js](https://highlightjs.org/) is used for highlighting code examples by default. Override this or disable it by setting `options.highlight` to `false` or any value supported by remarkable. 86 | 87 | ```js 88 | // disable highlighting 89 | remarkable({highlight: false}); 90 | 91 | // custom highlighting 92 | remarkable({ 93 | highlight: function() { 94 | // do highlighting stuff 95 | } 96 | }); 97 | ``` 98 | 99 | ## About 100 | 101 | ### Related projects 102 | 103 | * [breakdance](https://www.npmjs.com/package/breakdance): Breakdance is a node.js library for converting HTML to markdown. Highly pluggable, flexible and easy… [more](http://breakdance.io) | [homepage](http://breakdance.io "Breakdance is a node.js library for converting HTML to markdown. Highly pluggable, flexible and easy to use. It's time for your markup to get down.") 104 | * [gulp-html-toc](https://www.npmjs.com/package/gulp-html-toc): Gulp plugin for html-toc, for generating a HTML table of contents. | [homepage](https://github.com/jonschlinkert/gulp-html-toc "Gulp plugin for html-toc, for generating a HTML table of contents.") 105 | * [gulp-htmlmin](https://www.npmjs.com/package/gulp-htmlmin): gulp plugin to minify HTML. | [homepage](https://github.com/jonschlinkert/gulp-htmlmin#readme "gulp plugin to minify HTML.") 106 | * [gulp-remarkable](https://www.npmjs.com/package/gulp-remarkable): Gulp plugin for Remarkable - Markdown parser done right. Fast and easy to extend. Supports… [more](https://github.com/johnotander/gulp-remarkable) | [homepage](https://github.com/johnotander/gulp-remarkable "Gulp plugin for Remarkable - Markdown parser done right. Fast and easy to extend. Supports CommonMark.") 107 | * [remarkable](https://www.npmjs.com/package/remarkable): Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in… [more](https://github.com/jonschlinkert/remarkable) | [homepage](https://github.com/jonschlinkert/remarkable "Markdown parser, done right. 100% Commonmark support, extensions, syntax plugins, high speed - all in one.") 108 | 109 | ### Contributing 110 | 111 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). 112 | 113 | Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards. 114 | 115 | ### Building docs 116 | 117 | _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ 118 | 119 | To generate the readme, run the following command: 120 | 121 | ```sh 122 | $ npm install -g verbose/verb#dev verb-generate-readme && verb 123 | ``` 124 | 125 | ### Running tests 126 | 127 | Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: 128 | 129 | ```sh 130 | $ npm install && npm test 131 | ``` 132 | 133 | ### Author 134 | 135 | **Jon Schlinkert** 136 | 137 | * [github/jonschlinkert](https://github.com/jonschlinkert) 138 | * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) 139 | 140 | ### License 141 | 142 | Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). 143 | Released under the [MIT License](LICENSE). 144 | 145 | *** 146 | 147 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 22, 2017._ --------------------------------------------------------------------------------