html-pipeline-asciidoc_filter is an AsciiDoc processing filter for html-pipeline based on Asciidoctor.
This filter is used to render AsciiDoc files in GitHub repositories, among other uses. Keep in mind that an HTML sanitization filter is run after this filter, so not all elements in the AsciiDoc document render correctly. We need to improve the output generated by this filter to get better results.
require 'html/pipeline'
require 'html/pipeline/asciidoc_filter'
filters = [
HTML::Pipeline::AsciiDocFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::ImageMaxWidthFilter,
HTML::Pipeline::EmojiFilter,
HTML::Pipeline::MentionFilter,
HTML::Pipeline::AutolinkFilter,
HTML::Pipeline::TableOfContentsFilter,
HTML::Pipeline::SyntaxHighlightFilter
]
context = {
:asset_root => 'https://assets-cdn.github.com/images/icons'
}
pipeline = HTML::Pipeline.new filters, context
pipeline.setup_instrumentation
input = <<-EOS
= Sample Document
Author Name
Preamble paragraph.
== Sample Section
Section content.
.GitHub usernames
- @jch
- @rtomayko
- @mojavelinux
[source]
....
require 'asciidoctor'
puts Asciidoctor.convert('This filter brought to you by http://asciidoctor.org[Asciidoctor].')
....
See <<Sample Section>>.
[normal]
:shipit:
EOS
puts pipeline.call(input)[:output]
You’ll need the following dependencies in your Gemfile which aren’t declared by html-pipeline or this filter.
gem 'html-pipeline-asciidoc_filter'
# gemoji needed for EmojiFilter
gem 'gemoji', '~> 1.0'
# rinku needed for AutolinkFilter
gem 'rinku', '~> 1.7'
# sanitize needed for Sanitization Filter
gem 'sanitize', '~> 2.0'
# github-linguist needed for SyntaxHighlightFilter
gem 'github-linguist', (RUBY_VERSION < '2.1.0' ? '~> 2.6.2', '~> 2.10')
-
remove
<p>
from text-only list items by defining custom block_paragraph template -
preserve ToC (likely through subsequent filter)
-
enable font-based icons
Copyright © 2014-2015 Dan Allen Free use of this software is granted under the terms of the MIT License.
See the LICENSE file for details.