gjtorikian / html-pipeline

HTML processing filters and utilities
MIT License
2.27k stars 382 forks source link

Github Flavoured Markdown table support #269

Closed jaykilleen closed 6 years ago

jaykilleen commented 7 years ago

Sorry if I am missing something obvious here but I have tried implementing the GFM syntax for tables into one of my projects.

I have set gfm => true in my application helper and am able to successfully render code blocks, emojis, links and other functionality.

  def markdownify(content)
    pipeline_context = {gfm: true, asset_root: "https://a248.e.akamai.net/assets.github.com/images/icons/"}
    pipeline = HTML::Pipeline.new [
        HTML::Pipeline::MarkdownFilter,
        HTML::Pipeline::EmojiFilter,
        HTML::Pipeline::SanitizationFilter
        ], pipeline_context
        pipeline.call(content)[:output].to_s.html_safe
  end

Is there something else I need to have this functionality?

amitpatra commented 6 years ago

Try to add :commonmarker_extensions => [ :table].

gjtorikian commented 6 years ago

Yes, we ought to do a better job documenting here, but @amitpatra is correct (based on https://github.com/jch/html-pipeline/blob/010a6bdeace506725d619b95812eb6c4c55ca4c0/lib/html/pipeline/markdown_filter.rb#L11) and you can pass any of the Commonmarker extensions through.