Merge pull request #1238 from bhollis/asciidoc
Remove Asciidoc support in favor of a middleman-asciidoc extension
This commit is contained in:
commit
1c37cc6a34
1
Gemfile
1
Gemfile
|
@ -18,7 +18,6 @@ gem 'slim', require: false
|
||||||
gem 'liquid', require: false
|
gem 'liquid', require: false
|
||||||
gem 'less', '~> 2.3.0', require: false
|
gem 'less', '~> 2.3.0', require: false
|
||||||
gem 'stylus', require: false
|
gem 'stylus', require: false
|
||||||
gem 'asciidoctor', require: false
|
|
||||||
|
|
||||||
platforms :ruby do
|
platforms :ruby do
|
||||||
gem 'therubyracer'
|
gem 'therubyracer'
|
||||||
|
|
|
@ -1,155 +0,0 @@
|
||||||
Feature: AsciiDoc Support
|
|
||||||
In order to test included AsciiDoc support
|
|
||||||
|
|
||||||
Scenario: Rendering html
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!
|
|
||||||
Middleman, I am in you.</p>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Rendering html with default layout
|
|
||||||
Given a fixture app "asciidoc-app"
|
|
||||||
And a file named "config.rb" with:
|
|
||||||
"""
|
|
||||||
set :layout, :default
|
|
||||||
"""
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Fallback</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!
|
|
||||||
Middleman, I am in you.</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Rendering html with explicit layout
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello-with-layout.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Fallback</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Rendering html with no layout
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello-no-layout.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!</p>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Rendering html using title from document
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello-with-title.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Page Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Page Title</h1>
|
|
||||||
<div id="preamble">
|
|
||||||
<div class="sectionbody">
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Rendering html with title and layout from front matter
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/hello-with-front-matter.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Page Title</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="paragraph">
|
|
||||||
<p>Hello, AsciiDoc!</p>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Including a file relative to source root
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/master.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<div class="literalblock">
|
|
||||||
<div class="content">
|
|
||||||
<pre>I'm included content.</pre>
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Linking to an image
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/gallery.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<div class="imageblock">
|
|
||||||
<div class="content">
|
|
||||||
<img src="/images/tiger.gif" alt="tiger">
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
|
|
||||||
Scenario: Configuring custom AsciiDoc attributes
|
|
||||||
Given a fixture app "asciidoc-app"
|
|
||||||
And a file named "config.rb" with:
|
|
||||||
"""
|
|
||||||
set :asciidoc_attributes, %w(foo=bar)
|
|
||||||
"""
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/custom-attribute.html"
|
|
||||||
Then I should see "bar"
|
|
||||||
|
|
||||||
Scenario: Highlighting source code
|
|
||||||
Given a fixture app "asciidoc-app"
|
|
||||||
And a file named "config.rb" with:
|
|
||||||
"""
|
|
||||||
set :asciidoc_attributes, %w(source-highlighter=html-pipeline)
|
|
||||||
"""
|
|
||||||
Given the Server is running at "asciidoc-app"
|
|
||||||
When I go to "/code.html"
|
|
||||||
Then I should see:
|
|
||||||
"""
|
|
||||||
<div class="listingblock">
|
|
||||||
<div class="content">
|
|
||||||
<pre lang="ruby"><code>puts "Is this mic on?"</code></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
"""
|
|
|
@ -1 +0,0 @@
|
||||||
I'm included content.
|
|
|
@ -1,3 +0,0 @@
|
||||||
```ruby
|
|
||||||
puts "Is this mic on?"
|
|
||||||
```
|
|
|
@ -1,3 +0,0 @@
|
||||||
++++
|
|
||||||
{foo}
|
|
||||||
++++
|
|
|
@ -1 +0,0 @@
|
||||||
image::tiger.gif[]
|
|
|
@ -1,2 +0,0 @@
|
||||||
:page-layout: false
|
|
||||||
Hello, AsciiDoc!
|
|
|
@ -1,5 +0,0 @@
|
||||||
---
|
|
||||||
title: Page Title
|
|
||||||
layout: default
|
|
||||||
---
|
|
||||||
Hello, AsciiDoc!
|
|
|
@ -1,2 +0,0 @@
|
||||||
:page-layout: default
|
|
||||||
Hello, AsciiDoc!
|
|
|
@ -1,4 +0,0 @@
|
||||||
= Page Title
|
|
||||||
:page-layout: default
|
|
||||||
|
|
||||||
Hello, AsciiDoc!
|
|
|
@ -1,4 +0,0 @@
|
||||||
Hello, AsciiDoc!
|
|
||||||
ifdef::env-middleman[]
|
|
||||||
Middleman, I am in you.
|
|
||||||
endif::env-middleman[]
|
|
Binary file not shown.
Before Width: | Height: | Size: 43 B |
|
@ -1,9 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title><%= current_resource.data.title || asciidoc[:title] || 'Fallback' %></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<%= yield %>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,3 +0,0 @@
|
||||||
....
|
|
||||||
include::_include.adoc[]
|
|
||||||
....
|
|
|
@ -48,13 +48,6 @@ module Middleman
|
||||||
require 'middleman-core/renderers/markdown'
|
require 'middleman-core/renderers/markdown'
|
||||||
app.send :include, Middleman::Renderers::Markdown
|
app.send :include, Middleman::Renderers::Markdown
|
||||||
|
|
||||||
# AsciiDoc Support
|
|
||||||
begin
|
|
||||||
require 'middleman-core/renderers/asciidoc'
|
|
||||||
app.send :include, Middleman::Renderers::AsciiDoc
|
|
||||||
rescue LoadError
|
|
||||||
end
|
|
||||||
|
|
||||||
# Liquid Support
|
# Liquid Support
|
||||||
begin
|
begin
|
||||||
require 'middleman-core/renderers/liquid'
|
require 'middleman-core/renderers/liquid'
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
require 'asciidoctor'
|
|
||||||
|
|
||||||
module Middleman
|
|
||||||
module Renderers
|
|
||||||
module AsciiDoc
|
|
||||||
class << self
|
|
||||||
|
|
||||||
def registered(app)
|
|
||||||
app.config.define_setting :asciidoc, {
|
|
||||||
:safe => :safe,
|
|
||||||
:backend => :html5,
|
|
||||||
:attributes => %W(showtitle env=middleman env-middleman middleman-version=#{::Middleman::VERSION})
|
|
||||||
}, 'AsciiDoc engine options (Hash)'
|
|
||||||
app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)'
|
|
||||||
|
|
||||||
app.after_configuration do
|
|
||||||
# QUESTION should base_dir be equal to docdir instead?
|
|
||||||
config[:asciidoc][:base_dir] = source_dir
|
|
||||||
config[:asciidoc][:attributes].concat(config[:asciidoc_attributes] || [])
|
|
||||||
config[:asciidoc][:attributes] << %(imagesdir=#{File.join((config[:http_prefix] || '/').chomp('/'), config[:images_dir])})
|
|
||||||
sitemap.provides_metadata(/\.adoc$/) do |path|
|
|
||||||
# read the AsciiDoc header only to set page options and data
|
|
||||||
# header values can be accessed via app.data.page.<name> in the layout
|
|
||||||
doc = Asciidoctor.load_file path, :safe => :safe, :parse_header_only => true
|
|
||||||
|
|
||||||
opts = {}
|
|
||||||
if doc.attr? 'page-layout'
|
|
||||||
case (layout = (doc.attr 'page-layout'))
|
|
||||||
when '', 'false'
|
|
||||||
opts[:layout] = false
|
|
||||||
else
|
|
||||||
opts[:layout] = layout
|
|
||||||
end
|
|
||||||
end
|
|
||||||
opts[:layout_engine] = (doc.attr 'page-layout-engine') if (doc.attr? 'page-layout-engine')
|
|
||||||
# TODO override attributes to set docfile, docdir, docname, etc
|
|
||||||
# alternative is to set :renderer_options, which get merged into options by the rendering extension
|
|
||||||
#opts[:attributes] = config[:asciidoc][:attributes].dup
|
|
||||||
#opts[:attributes].concat %W(docfile=#{path} docdir=#{File.dirname path} docname=#{(File.basename path).sub(/\.adoc$/, '')})
|
|
||||||
|
|
||||||
page = {}
|
|
||||||
page[:title] = doc.doctitle
|
|
||||||
page[:date] = (doc.attr 'date') unless (doc.attr 'date').nil?
|
|
||||||
# TODO grab all the author information
|
|
||||||
page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil?
|
|
||||||
|
|
||||||
{ :options => opts, :locals => { :asciidoc => page } }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
alias :included :registered
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue