-
-
Notifications
You must be signed in to change notification settings - Fork 274
/
webgen.config
52 lines (43 loc) · 2 KB
/
webgen.config
1
2
3
4
5
6
7
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
# -*- ruby -*-
website.config['website.base_url'] = 'http://kramdown.gettalong.org/'
website.config['sources'] =[['/', :file_system, 'doc']]
website.config['destination'] = [:file_system, 'htmldoc']
website.config['website.tmpdir'] = 'webgen-tmp'
####
# tag options
website.config.define_option('tag.options.items', [])
website.ext.tag.register('options', :mandatory => ['items'],
:config_prefix => 'tag.options') do |tag, body, context|
options = context[:config]['tag.options.items']
options = if options == 'all'
Kramdown::Options.definitions.sort.map {|k,v| v}
else
options.collect {|opt| Kramdown::Options.definitions[opt.intern]}
end
options.collect do |term|
lines = term.desc.gsub(/\[|{::/, "\\\\\\&").split(/\n/)
first = lines.shift
rest = lines[0..-2].collect {|l| " " + l}.join("\n") << "\\\\\n #{lines[-1]}"
"`#{term.name}`{:\#option-#{term.name.to_s.tr('_', '-')}}\n: #{first}\n#{rest}\n\n"
end.join("\n")
end
####
# tag kdexample
require 'cgi'
website.ext.tag.register('kdexample', :config_prefix => 'tag.kdexample') do |tag, body, context|
body.strip!
result = ::Kramdown::Document.new(body, :auto_ids => false).to_html
before = "<pre class='kdexample-before'><code>#{CGI::escapeHTML(body)}\n</code></pre>"
after = "<pre class='kdexample-after-source'><code>#{CGI::escapeHTML(result)}\n</code></pre>"
afterhtml = "<div class='kdexample-after-live'>#{result}</div>"
"<table class='kdexample'><tr><td>#{before}</td><td>#{after}#{afterhtml}</td></tr></table>"
end
####
# tag kdlink
website.config.define_option('tag.kdlink.oid', nil)
website.config.define_option('tag.kdlink.part', nil)
website.ext.tag.register('kdlink', :mandatory => ['oid', 'part'],
:config_prefix => 'tag.kdlink') do |tag, body, context|
link = "<a href='syntax.html##{context[:config]['tag.kdlink.oid']}'>→ Syntax for #{context[:config]['tag.kdlink.part']}</a>"
"<div class='kdsyntaxlink'>#{link}\n</div>"
end