GithubHelp home page GithubHelp logo

content-pipeline's Introduction

Content Pipeline.

Build Status Coverage Status Code Climate Dependency Status

Content pipeline is like html-pipeline except it's less restrictive.

Installing

gem install content-pipeline
gem 'content-pipeline', '~> <VERSION>'

Usage

Content Pipeline is extremely simple to use out of the box:

# ---------------------------------------------------------------------
# With custom filters and global-filter options + per-filter options.
# ---------------------------------------------------------------------

pipeline = Content::Pipeline.new([ MyFilter ], {
  :my_filter => {
    :o1 => true
  }
})

pipeline.filter('# Markdown', {
  :my_filter => {
    :o1 => false
  }
})

# ---------------------------------------------------------------------
# With only global-filter options + per-filter options.
# ---------------------------------------------------------------------

pipeline = Content::Pipeline.new({
  :my_filter => {
    :o1 => true
  }
})

pipeline.filter("# Markdown", {
  :my_filter => {
    :o1 => false
  }
})
Content::Pipeline.new.filter('# Markdown')
  • Supports global options with overrides.
  • By default uses CodeHighlight, Markdown, Gemoji.
  • Supports multiple Markdowns.

It should be noted that if you send a list of filters you wish to use, it will not use the default filters at all. So where you see [ MyFilter ] that will be the only filter that is ran, since it automatically assumes this is the pipeline you wish to use.

Filter Options

Filter options are set globally and can be overriden each time the filter is ran, this allows for you to setup a single pipeline and then adjust it on the fly on a per-content basis, for example if you wish to run Markdown :safe on user comments but not on posts, then you would simply setup the global pipeline and then each time you parse a user comment send the content with the hash { :markdown => { :safe => true }}.

All options are keyed based on their class name, so MyFilter would have the option key :my_filter but it also supports :myfilter

Content::Pipeline::Filters::Markdown

The Markdown filter allows you to choose between github-markdown and kramdown, and by default will use kramdown on jRuby and github-markdown on any other Ruby that supports it. These dependencies are loose, which means you must install the one you wish to use.

Options:

  • :type => [:gfm, :markdown, md, :kramdown]
  • :safe => [true, false]

You should not need to adjust any of your "```" because the Markdown filter will automatically convert those to ~~~ if you choose Kramdown. This is not done because one way is better than the other, it's done so that people can remain agnostic.

Content::Pipeline::Filters::CodeHighlight

The code highlight filter allows you to highlight code, with or without Pygments. If Pygments is supported it will require it and syntax highlight, otherwise it will simply wrap your code in the normal code style and not syntax highlight it. You will still have the line numbers, just not the fancy syntax highlight.

Options:

  • :default - :ruby

Content::Pipeline::Filters::Gemoji

The Gemoji filter allows you to convert :gemoji: into image tags, liquid asset tags and if you really really need it, a custom tag by sending a proc. By default it will use the path /asset which can be overriden.

  • :as_liquid_asset - nil
  • :tag - Proc - 2args - path, name.
  • :asset_path - /assets

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.