Code Monkey home page Code Monkey logo

html-pipeline-rouge_filter's Introduction

This repository is no longer actively maintained.

HTML::Pipeline::RougeFilter Build Status

Rouge integration for HTML::Pipeline.

This RubyGem requires Ruby 2.0+.

Installation

Add this line to your application's Gemfile:

gem 'html-pipeline-rouge_filter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install html-pipeline-rouge_filter

Usage

require 'html/pipeline'
require 'html/pipeline/rouge_filter'

pipeline = HTML::Pipeline.new [
  HTML::Pipeline::MarkdownFilter,
  HTML::Pipeline::RougeFilter
]

result = pipeline.call <<-CODE.gsub(/^\s*/,'')

    ```ruby
    def foo
      puts "foo"
    end
    ```

    CODE

puts result[:output]

Prints (without the linebreaks):

<pre class="highlight highlight-ruby">
  <code>
    <span class="k">def</span>
    <span class="nf">foo</span>
    <span class="nb">puts</span>
    <span class="s2">"foo"</span>
    <span class="k">end</span>
  </code>
</pre>

You can specify following options in context hash:

line_numbers: Line numbers will be displayed if set to true.

replace_br: <br> tags in the code will be replaced with new line characters (\n) if set to true.

Contributing

  1. Fork it ( https://github.com/juanitofatas/html-pipeline-rouge_filter/fork )
  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 a new Pull Request

License, Contributor's Guidelines and Code of Conduct

This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs.

This project subscribes to the Moya Contributors Guidelines which TLDR: means we give out push access easily and often.

Contributors subscribe to the Contributor Code of Conduct based on the Contributor Covenant version 1.4.

html-pipeline-rouge_filter's People

Contributors

hibariya avatar juanitofatas avatar lowjoel avatar townsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

html-pipeline-rouge_filter's Issues

code doesn't retain structure

Hi,
I am using this gem and when I render the result, it looks broken:
screenshot 2015-10-30 22 00 09

the code i'm using to render this is:

def markdownify(content)
    pipeline_context = { gfm: true, asset_root: "public/images" }
    pipeline = HTML::Pipeline.new [
      HTML::Pipeline::MarkdownFilter,
      HTML::Pipeline::SanitizationFilter,
      HTML::Pipeline::RougeFilter,
      HTML::Pipeline::MentionFilter,
      HTML::Pipeline::EmojiFilter,
    ], pipeline_context
    pipeline.call(content)[:output].to_s.html_safe
  end

and I call it on:

.media-body
    .media-heading
      %small.pull-right.text-muted= time_ago_in_words comment.created_at
      %h5= comment.user.username
    %p= markdownify comment.comment

any idea what might be the issue?
BTW - inspecting the styles in DevTools doesn't show any additional paddings, spaces, margins or whatever added
Thanks

HTML entities in input to Rouge

Continuation from #6.

In HTML, editors like to use &nbsp; &nbsp; to preserve whitespace. Non-breaking space isn't recognised by Rouge to be same as space, so it does not recognise the syntax properly.

untitled
(look at the pink whitespace)

Maybe we should extend the "replace_br" configuration to be more general, "preprocess HTML" or some configuration setting like that, where contiguous non-breaking whitespace is replaced with normal spaces instead?

This is getting pretty nasty.

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.