Sha256: 2c3d57d09a10db1d6818417a24d8adf7bec3cc50a965db658cad988eeca63977

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module HTML
  class Pipeline

    class LinuxFr
      CONTEXT = {
        toc_minimal_length: 5000,
        toc_header: "<h2 class=\"sommaire\">Sommaire</h2>\n",
        svgtex_url: "http://localhost:16000",
        host: "linuxfr.org"
      }.freeze

      def self.render(text, context = {})
        pipeline = HTML::Pipeline.new [
          HTML::Pipeline::SVGTeX::PreFilter,
          HTML::Pipeline::MarkdownFilter,
          HTML::Pipeline::SanitizationFilter,
          HTML::Pipeline::TableOfContentsFilter,
          HTML::Pipeline::SVGTeX::PostFilter,
          HTML::Pipeline::SyntaxHighlightFilter,
          HTML::Pipeline::NoFollowLinksFilter,
          HTML::Pipeline::RelativeLinksFilter,
          HTML::Pipeline::CustomLinksFilter,
        ], CONTEXT
        result = pipeline.call text, context
        result[:output].to_s
      end

      def self.sanitize(html)
        return "" if html.nil?
        pipeline = HTML::Pipeline.new [HTML::Pipeline::SanitizationFilter]
        result = pipeline.call html
        result[:output].to_s
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html-pipeline-linuxfr-0.15.7 lib/html/pipeline/linuxfr.rb