8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/middleman-core/renderers/asciidoc.rb', line 8
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.before_configuration do
template_extensions :adoc => :html
end
app.after_configuration do
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|
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')
page = {}
page[:title] = doc.doctitle
page[:date] = (doc.attr 'date') unless (doc.attr 'date').nil?
page[:author] = (doc.attr 'author') unless (doc.attr 'author').nil?
{:options => opts, :page => ::Middleman::Util.recursively_enhance(page)}
end
end
end
|