Git Product home page Git Product logo

gulp-remarkable's Introduction

Gulp Remarkable NPM version Build Status Dependency Status

A gulp plugin for Remarkable - Markdown parser, done right. Fast and easy to extend. Supports CommonMark.

Installation

Install using npm:

$ npm install gulp-remarkable

See gulp-remarkable on npm.

Options

  • remarkableOptions {Object} Options to be passed to Remarkable
  • disable [Array] Options to be passed to md.core.ruler.disable
    • to use it, first remarkableOptions.typographer must be set to true
  • preset {String} Remarkable's preset, default full

Usage

Default Example

var gulp = require('gulp'),
    name = require('gulp-rename'),
    md   = require('gulp-remarkable');

gulp.task('md', function() {
  return gulp.src('file.md')
    .pipe(md({preset: 'commonmark'}))
    .pipe(name('file.html'))
    .pipe(gulp.dest('dist'));
});

gulp.task('default', ['md']);

Extended Example

var gulp = require('gulp'),
    name = require('gulp-rename'),
    md   = require('gulp-remarkable');

gulp.task('md', function() {
  return gulp.src('file.md')
    .pipe(md({
      preset: 'full',
      disable: ['replacements'],
      remarkableOptions: {
        typographer: true,
        linkify: true,
        breaks: true
      }
    }))
    .pipe(name('file.html'))
    .pipe(gulp.dest('dist'));
});

gulp.task('default', ['md']);

Using Plugins

gulp-remarkable accepts one or two parameters: options and an optional function that accepts gulpRemarkable object.

var gulp = require('gulp')
var md = require('gulp-remarkable')

return gulp.src(globMarkdown)
    .pipe(md(opts, (m=>{
      m.renderer.rules.heading_open = headingAnchorRendererPlugin
    })))

function headingAnchorRendererPlugin(tokens, idx ) {
  if (tokens[idx+1].type == 'inline') {
    let heading_anchor = slug(tokens[idx+1].content, {lower: true})
    return '<h' + tokens[idx].hLevel + ' id="' + heading_anchor + '">';
  }
  return '<h' + tokens[idx].hLevel + '>';
}

Run tests

$ npm test

Authors & Contributors

John Otander

Charlike Mike Reagent author tips

Evans Jahja

License MIT license

Copyright (c) 2014 John Otander, contributors.
Released under the MIT license.

Acknowledgements

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

gulp-remarkable's People

Contributors

evansjahja avatar johno avatar thedancingcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-remarkable's Issues

Plugin support?

@johno Has there been any progress with plugins support as described in #8 ?

The solution in #14 and #15 did not work. The example in the README only covers using the second parameter of gulp-remarkable when using with an included function, not with a third-party plugin.

In the example provides in #14, it is not clear how to support multiple plugins or if those changes were merged into the repository or not.

Here is the code I'm using, my attempt at extrapolating from previous examples:

// Markdown
const markdown = require('gulp-remarkable');
// Remarkable plugins
const admonitions = require('remarkable-admonitions');
const remarkableFigure = require('remarkable-figure-plugin');
const headingId = require('remarkable-plugin-heading-id');
const extLink = require('remarkable-extlink');

gulp.task('markdown', () => {
  const opts = {
    preset: 'commonmark',
    remarkableOptions: {
      typographer: true,
      linkify: true,
      breaks: false,
    },
  };

  return gulp.src('./src/md-content/*.md')
      .pipe(markdown(opts, ((markdown) => {
        markdown.use(admonitions);
        markdown.use(remarkableFigure);
        markdown.use(headingId);
        markdown.use(extLink);
      })))
      .pipe(gulp.dest('./src/html-content'));
});

Blockquote

Is blockquote supported? Doesn't appear to be.

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.