showoff 0.20.1 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +24 -12
- data/bin/showoff +47 -24
- data/lib/showoff.rb +43 -20
- data/lib/showoff/compiler.rb +106 -0
- data/lib/showoff/compiler/downloads.rb +91 -0
- data/lib/showoff/compiler/fixups.rb +142 -0
- data/lib/showoff/compiler/form.rb +236 -0
- data/lib/showoff/compiler/glossary.rb +164 -0
- data/lib/showoff/compiler/i18n.rb +24 -0
- data/lib/showoff/compiler/notes.rb +73 -0
- data/lib/showoff/compiler/table_of_contents.rb +51 -0
- data/lib/showoff/compiler/variables.rb +71 -0
- data/lib/showoff/config.rb +218 -0
- data/lib/showoff/locale.rb +132 -0
- data/lib/showoff/logger.rb +15 -0
- data/lib/showoff/monkeypatches.rb +28 -0
- data/lib/showoff/presentation.rb +181 -0
- data/lib/showoff/presentation/section.rb +70 -0
- data/lib/showoff/presentation/slide.rb +113 -0
- data/lib/showoff/state.rb +89 -0
- data/lib/showoff/version.rb +2 -2
- data/lib/showoff_ng.rb +99 -0
- data/lib/showoff_utils.rb +21 -19
- data/public/css/showoff.css +14 -1
- data/public/js/highlight.pack-9.15.10.js +22614 -0
- data/public/js/showoff.js +3 -3
- data/views/header.erb +3 -3
- data/views/header_mini.erb +2 -2
- data/views/onepage.erb +4 -10
- data/views/presenter.erb +5 -5
- data/views/slide.erb +29 -0
- metadata +24 -21
- data/locales/id.yml +0 -2
- data/public/js/highlight.pack-9.2.0.js +0 -15448
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f61b9fc523ec9e56d30f4b62952fb0de93ffbba83f588fd9e753165cfb40fb3f
|
4
|
+
data.tar.gz: 9518221ae954431b7ac93a70e9f4fd6cd3e9fa6f0488993bd02b6602eb79bc67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5689f7fa30e67f3ad90699ef5611efe9809cbe20ac30a48fcfd65170632f2b4dc44b6292f4848f41ee04034a096c705860b11ec2f2f9ac49fd0ec1e22c0ebe2
|
7
|
+
data.tar.gz: 21b8af225ff1582354b3c82f4345b76fa354d249a3eedb1bf35c771073fbb8f6a43ccb442cf2dc8f60d8a7cce8ab42dac835b22e6cade3023dcb196b18c7a0e1
|
data/Rakefile
CHANGED
@@ -67,21 +67,33 @@ task 'doc:website' => [:doc] do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
# These tests are currently unmaintained.
|
71
|
+
# @todo: port and delete
|
72
|
+
#
|
73
|
+
# desc "Run tests"
|
74
|
+
# task :test do
|
75
|
+
# require 'rake/testtask'
|
76
|
+
#
|
77
|
+
# Rake::TestTask.new do |t|
|
78
|
+
# t.libs << 'lib'
|
79
|
+
# t.pattern = 'test/**/*_test.rb'
|
80
|
+
# t.verbose = false
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
84
|
+
# sh "turn test/*_test.rb #{suffix}"
|
85
|
+
# end
|
86
|
+
|
87
|
+
desc "Run RSpec unit tests"
|
88
|
+
task :spec do
|
89
|
+
ENV["LOG_SPEC_ORDER"] = "true"
|
90
|
+
if ENV['verbose'] == 'true'
|
91
|
+
sh %{rspec #{ENV['TEST'] || ENV['TESTS'] || 'spec'} -fd}
|
92
|
+
else
|
93
|
+
sh %{rspec #{ENV['TEST'] || ENV['TESTS'] || 'spec'}}
|
78
94
|
end
|
79
|
-
|
80
|
-
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
81
|
-
sh "turn test/*_test.rb #{suffix}"
|
82
95
|
end
|
83
96
|
|
84
|
-
|
85
97
|
desc 'Validate translation files'
|
86
98
|
task 'lang:check' do
|
87
99
|
require 'yaml'
|
data/bin/showoff
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
-
require 'showoff'
|
4
|
+
#require 'showoff'
|
5
5
|
require 'showoff/version'
|
6
6
|
require 'rubygems'
|
7
7
|
require 'fidget'
|
@@ -16,7 +16,7 @@ module Wrapper
|
|
16
16
|
program_desc <<-desc
|
17
17
|
A web based presentation engine with awesome interaction features.
|
18
18
|
|
19
|
-
|
19
|
+
Showoff uses Markdown files with a few custom extensions to generate slides
|
20
20
|
that are served locally for presentation via web browser. Your audience can
|
21
21
|
view presentations directly as well, and interact with you in many ways.
|
22
22
|
|
@@ -28,7 +28,8 @@ module Wrapper
|
|
28
28
|
The simplest use case is to run `showoff serve` from the directory containing
|
29
29
|
the showoff.json file.
|
30
30
|
desc
|
31
|
-
|
31
|
+
switch :dev, :desc => "Use the next-gen development version of Showoff"
|
32
|
+
switch :debug, :desc => "Show application backtraces on crash"
|
32
33
|
|
33
34
|
desc 'Create new showoff presentation'
|
34
35
|
long_desc 'This command helps start a new showoff presentation by setting up the proper directory structure for you. It takes the directory name you would like showoff to create for you.'
|
@@ -43,9 +44,9 @@ module Wrapper
|
|
43
44
|
|
44
45
|
c.action do |global_options,options,args|
|
45
46
|
dir_name = args.first || '.'
|
46
|
-
|
47
|
+
ShowoffUtils.create(dir_name,!options[:n],options[:d])
|
47
48
|
if options[:n]
|
48
|
-
puts "Add slides and update #{dir_name}/#{
|
49
|
+
puts "Add slides and update #{dir_name}/#{ShowoffUtils.presentation_config_file}"
|
49
50
|
end
|
50
51
|
if args.empty?
|
51
52
|
puts "Run 'showoff serve' to see your new slideshow"
|
@@ -63,7 +64,7 @@ module Wrapper
|
|
63
64
|
c.flag [:f,:file]
|
64
65
|
|
65
66
|
c.action do |global_options,options,args|
|
66
|
-
|
67
|
+
ShowoffUtils.skeleton(options[:f])
|
67
68
|
puts "done. run 'showoff serve' to see your slideshow"
|
68
69
|
end
|
69
70
|
end
|
@@ -79,7 +80,7 @@ module Wrapper
|
|
79
80
|
c.switch [:j,:json]
|
80
81
|
|
81
82
|
c.action do |global_options,options,args|
|
82
|
-
|
83
|
+
ShowoffUtils.info(options[:f], options[:j])
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
@@ -91,7 +92,7 @@ module Wrapper
|
|
91
92
|
c.flag [:f,:file]
|
92
93
|
|
93
94
|
c.action do |global_options,options,args|
|
94
|
-
|
95
|
+
ShowoffUtils.validate(options[:f])
|
95
96
|
end
|
96
97
|
end
|
97
98
|
|
@@ -100,7 +101,7 @@ module Wrapper
|
|
100
101
|
command :github do |c|
|
101
102
|
c.action do |global_options,options,args|
|
102
103
|
puts "Generating static content"
|
103
|
-
|
104
|
+
ShowoffUtils.github
|
104
105
|
puts "I've updated your 'gh-pages' branch with the static version of your presentation."
|
105
106
|
puts "Push it to GitHub to publish it. Probably something like:"
|
106
107
|
puts
|
@@ -126,16 +127,16 @@ module Wrapper
|
|
126
127
|
raise "Name must start with a letter and can only contain lowercase letters, numbers, and dashes." unless args.first =~ /^[a-z][a-z1-9-]*$/
|
127
128
|
|
128
129
|
unless system('git remote get-url heroku')
|
129
|
-
|
130
|
+
ShowoffUtils.command("heroku create #{args[0]}", "Please ensure that the heroku gem is installed and you're logged in.")
|
130
131
|
end
|
131
132
|
|
132
|
-
if
|
133
|
-
|
133
|
+
if ShowoffUtils.heroku(args[0],options[:f],options[:p])
|
134
|
+
ShowoffUtils.command('bundle install', 'Please ensure that the bundler gem is installed.')
|
134
135
|
|
135
136
|
begin
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
ShowoffUtils.command('git add Procfile Gemfile Gemfile.lock config.ru')
|
138
|
+
ShowoffUtils.command('git commit -m "Herokuized by Showoff"')
|
139
|
+
ShowoffUtils.command('git push heroku master')
|
139
140
|
rescue => e
|
140
141
|
puts 'Git operations failed. Please correct issues, then manually commit the following files:'
|
141
142
|
puts ' * Procfile'
|
@@ -212,7 +213,7 @@ module Wrapper
|
|
212
213
|
|
213
214
|
# This is gross. A serious revamp in config file parsing is due.
|
214
215
|
config = JSON.parse(File.read(options[:f])) rescue {}
|
215
|
-
if Gem::Version.new(config['version']) > Gem::Version.new(SHOWOFF_VERSION) then
|
216
|
+
if Gem::Version.new(config['version'].to_s) > Gem::Version.new(SHOWOFF_VERSION) then
|
216
217
|
raise "This presentation requires Showoff version #{config['version']} or greater."
|
217
218
|
end
|
218
219
|
|
@@ -239,7 +240,7 @@ module Wrapper
|
|
239
240
|
puts "
|
240
241
|
-------------------------
|
241
242
|
|
242
|
-
Your
|
243
|
+
Your Showoff presentation is now starting up.
|
243
244
|
|
244
245
|
To view it plainly, visit [ #{url} ]
|
245
246
|
|
@@ -255,8 +256,8 @@ module Wrapper
|
|
255
256
|
end
|
256
257
|
|
257
258
|
if options[:url]
|
258
|
-
|
259
|
-
|
259
|
+
ShowoffUtils.clone(options[:git_url], options[:git_branch], options[:git_path]) do
|
260
|
+
Showoff.run!(options) do |server|
|
260
261
|
if options[:ssl]
|
261
262
|
server.ssl = true
|
262
263
|
server.ssl_options = ssl_options
|
@@ -265,7 +266,7 @@ module Wrapper
|
|
265
266
|
end
|
266
267
|
|
267
268
|
else
|
268
|
-
|
269
|
+
Showoff.run!(options) do |server|
|
269
270
|
if options[:ssl]
|
270
271
|
server.ssl = true
|
271
272
|
server.ssl_options = ssl_options
|
@@ -302,7 +303,7 @@ module Wrapper
|
|
302
303
|
|
303
304
|
c.action do |global_options,options,args|
|
304
305
|
title = args.join(" ")
|
305
|
-
|
306
|
+
ShowoffUtils.add_slide(:dir => options[:d],
|
306
307
|
:name => options[:n],
|
307
308
|
:title => title,
|
308
309
|
:number => !options[:u],
|
@@ -323,7 +324,7 @@ module Wrapper
|
|
323
324
|
c.flag [:l, :lang, :language, :locale]
|
324
325
|
|
325
326
|
c.action do |global_options,options,args|
|
326
|
-
|
327
|
+
Showoff.do_static(args, options)
|
327
328
|
end
|
328
329
|
end
|
329
330
|
|
@@ -331,15 +332,37 @@ module Wrapper
|
|
331
332
|
arg_name 'name'
|
332
333
|
long_desc 'Creates a PDF version of the presentation as {name}.pdf'
|
333
334
|
command [:pdf] do |c|
|
335
|
+
c.desc 'JSON file used to describe presentation'
|
336
|
+
c.default_value "showoff.json"
|
337
|
+
c.flag [:f, :file, :pres_file]
|
338
|
+
|
339
|
+
c.desc 'Language code to generate.'
|
340
|
+
c.flag [:l, :lang, :language, :locale]
|
341
|
+
|
334
342
|
c.action do |global_options,options,args|
|
335
|
-
|
343
|
+
Showoff.do_static(['pdf'].concat(args), options)
|
336
344
|
end
|
337
345
|
end
|
338
346
|
|
339
347
|
pre do |global,command,options,args|
|
340
348
|
# Pre logic here
|
341
|
-
# Return true to proceed; false to
|
349
|
+
# Return true to proceed; false to abort and not call the
|
342
350
|
# chosen command
|
351
|
+
|
352
|
+
if global[:debug]
|
353
|
+
ENV['GLI_DEBUG'] = 'true'
|
354
|
+
end
|
355
|
+
|
356
|
+
if global[:dev]
|
357
|
+
require 'showoff_ng'
|
358
|
+
|
359
|
+
if options[:file]
|
360
|
+
Showoff::Config.load(options[:file])
|
361
|
+
end
|
362
|
+
else
|
363
|
+
require 'showoff'
|
364
|
+
end
|
365
|
+
|
343
366
|
true
|
344
367
|
end
|
345
368
|
|
data/lib/showoff.rb
CHANGED
@@ -28,7 +28,7 @@ end
|
|
28
28
|
|
29
29
|
require 'tilt'
|
30
30
|
|
31
|
-
class
|
31
|
+
class Showoff < Sinatra::Application
|
32
32
|
|
33
33
|
attr_reader :cached_image_size
|
34
34
|
|
@@ -92,13 +92,13 @@ class ShowOff < Sinatra::Application
|
|
92
92
|
|
93
93
|
settings.pres_dir = File.expand_path(settings.pres_dir)
|
94
94
|
if (settings.pres_file and settings.pres_file != 'showoff.json')
|
95
|
-
|
95
|
+
ShowoffUtils.presentation_config_file = settings.pres_file
|
96
96
|
end
|
97
97
|
|
98
98
|
# Load configuration for page size and template from the
|
99
99
|
# configuration JSON file
|
100
|
-
if File.exist?(
|
101
|
-
showoff_json = JSON.parse(File.read(
|
100
|
+
if File.exist?(ShowoffUtils.presentation_config_file)
|
101
|
+
showoff_json = JSON.parse(File.read(ShowoffUtils.presentation_config_file))
|
102
102
|
settings.showoff_config = showoff_json
|
103
103
|
|
104
104
|
# Set options for encoding, template and page size
|
@@ -205,7 +205,7 @@ class ShowOff < Sinatra::Application
|
|
205
205
|
Thread.new do
|
206
206
|
loop do
|
207
207
|
sleep 30
|
208
|
-
|
208
|
+
Showoff.flush
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -214,7 +214,7 @@ class ShowOff < Sinatra::Application
|
|
214
214
|
MarkdownConfig::setup(settings.pres_dir)
|
215
215
|
|
216
216
|
# Process renderer config options
|
217
|
-
@engine_options =
|
217
|
+
@engine_options = ShowoffUtils.showoff_renderer_options(settings.pres_dir)
|
218
218
|
|
219
219
|
end
|
220
220
|
# save stats to disk
|
@@ -245,7 +245,7 @@ class ShowOff < Sinatra::Application
|
|
245
245
|
|
246
246
|
def self.pres_dir_current
|
247
247
|
opt = {:pres_dir => Dir.pwd}
|
248
|
-
|
248
|
+
Showoff.set opt
|
249
249
|
end
|
250
250
|
|
251
251
|
def require_ruby_files
|
@@ -369,7 +369,7 @@ class ShowOff < Sinatra::Application
|
|
369
369
|
|
370
370
|
# Parse the context string for options and content classes
|
371
371
|
if context and context.match(/(\[(.*?)\])?(.*)/)
|
372
|
-
options =
|
372
|
+
options = ShowoffUtils.parse_options($2)
|
373
373
|
@tpl = options["tpl"] if options["tpl"]
|
374
374
|
@bg = options["bg"] if options["bg"]
|
375
375
|
@classes += $3.strip.chomp('>').split if $3
|
@@ -573,7 +573,21 @@ class ShowOff < Sinatra::Application
|
|
573
573
|
|
574
574
|
# Now check for any kind of options
|
575
575
|
content.scan(/(~~~CONFIG:(.*?)~~~)/).each do |match|
|
576
|
-
|
576
|
+
parts = match[1].split('.') # Use dots ('.') to separate Hash keys
|
577
|
+
if parts.size > 1
|
578
|
+
value = settings.showoff_config.dig(parts[0]).to_h.dig(*parts[1..-1])
|
579
|
+
else
|
580
|
+
value = settings.showoff_config.fetch(parts[0],nil)
|
581
|
+
end
|
582
|
+
|
583
|
+
unless value.is_a?(String)
|
584
|
+
msg = "#{match[0]} refers to a non-String data type (#{value.class})"
|
585
|
+
msg = "#{match[0]}: not found in settings data" if value.nil?
|
586
|
+
@logger.warn(msg)
|
587
|
+
next
|
588
|
+
end
|
589
|
+
|
590
|
+
result.gsub!(match[0], value)
|
577
591
|
end
|
578
592
|
|
579
593
|
# Load and replace any file tags
|
@@ -1151,7 +1165,7 @@ class ShowOff < Sinatra::Application
|
|
1151
1165
|
def get_slides_html(opts={:static=>false, :pdf=>false, :toc=>false, :supplemental=>nil, :section=>nil})
|
1152
1166
|
sections = nil
|
1153
1167
|
Dir.chdir(get_locale_dir('locales', @locale)) do
|
1154
|
-
sections =
|
1168
|
+
sections = ShowoffUtils.showoff_sections(settings.pres_dir, settings.showoff_config, @logger)
|
1155
1169
|
end
|
1156
1170
|
|
1157
1171
|
if sections
|
@@ -1219,9 +1233,9 @@ class ShowOff < Sinatra::Application
|
|
1219
1233
|
|
1220
1234
|
def index(static=false)
|
1221
1235
|
if static
|
1222
|
-
@title =
|
1236
|
+
@title = ShowoffUtils.showoff_title(settings.pres_dir)
|
1223
1237
|
@slides = get_slides_html(:static=>static)
|
1224
|
-
@pause_msg =
|
1238
|
+
@pause_msg = ShowoffUtils.pause_msg
|
1225
1239
|
end
|
1226
1240
|
|
1227
1241
|
# Display favicon in the window if configured
|
@@ -1303,7 +1317,7 @@ class ShowOff < Sinatra::Application
|
|
1303
1317
|
@logger.info "Generating locale: #{@locale}"
|
1304
1318
|
|
1305
1319
|
# If we're displaying from a repository, let's update it
|
1306
|
-
|
1320
|
+
ShowoffUtils.update(settings.verbose) if settings.url
|
1307
1321
|
|
1308
1322
|
@@slide_titles = []
|
1309
1323
|
content = get_slides_html(:static=>static, :merged=>merged)
|
@@ -1450,7 +1464,7 @@ class ShowOff < Sinatra::Application
|
|
1450
1464
|
|
1451
1465
|
# PDFKit.new takes the HTML and any options for wkhtmltopdf
|
1452
1466
|
# run `wkhtmltopdf --extended-help` for a full list of options
|
1453
|
-
kit = PDFKit.new(html,
|
1467
|
+
kit = PDFKit.new(html, ShowoffUtils.showoff_pdf_options(settings.pres_dir))
|
1454
1468
|
|
1455
1469
|
# Save the PDF to a file
|
1456
1470
|
kit.to_file(name)
|
@@ -1464,11 +1478,11 @@ class ShowOff < Sinatra::Application
|
|
1464
1478
|
what = args[0] || "index"
|
1465
1479
|
opt = args[1]
|
1466
1480
|
|
1467
|
-
|
1481
|
+
ShowoffUtils.presentation_config_file = opts[:f]
|
1468
1482
|
|
1469
1483
|
# Sinatra now aliases new to new!
|
1470
1484
|
# https://github.com/sinatra/sinatra/blob/v1.3.3/lib/sinatra/base.rb#L1369
|
1471
|
-
showoff =
|
1485
|
+
showoff = Showoff.new!
|
1472
1486
|
|
1473
1487
|
name = showoff.instance_variable_get(:@pres_name)
|
1474
1488
|
path = showoff.instance_variable_get(:@root_path)
|
@@ -1504,6 +1518,8 @@ class ShowOff < Sinatra::Application
|
|
1504
1518
|
["js", "css"].each { |dir|
|
1505
1519
|
FileUtils.copy_entry("#{my_path}/#{dir}", "#{out}/#{dir}", false, false, true)
|
1506
1520
|
}
|
1521
|
+
|
1522
|
+
# @todo: uh. I don't know how this ever worked. my_path is showoff and name is presentation.
|
1507
1523
|
# And copy the directory
|
1508
1524
|
Dir.glob("#{my_path}/#{name}/*").each { |subpath|
|
1509
1525
|
base = File.basename(subpath)
|
@@ -1519,7 +1535,12 @@ class ShowOff < Sinatra::Application
|
|
1519
1535
|
|
1520
1536
|
# ..., copy all user-defined styles and javascript files
|
1521
1537
|
showoff.css_files.each { |path|
|
1522
|
-
dest = File.join(
|
1538
|
+
dest = File.join(out, path)
|
1539
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
1540
|
+
FileUtils.copy(path, dest)
|
1541
|
+
}
|
1542
|
+
showoff.js_files.each { |path|
|
1543
|
+
dest = File.join(out, path)
|
1523
1544
|
FileUtils.mkdir_p(File.dirname(dest))
|
1524
1545
|
FileUtils.copy(path, dest)
|
1525
1546
|
}
|
@@ -1950,8 +1971,8 @@ class ShowOff < Sinatra::Application
|
|
1950
1971
|
# gawd, this whole routing scheme is bollocks
|
1951
1972
|
get %r{/([^/]*)/?([^/]*)} do
|
1952
1973
|
@locale = locale(request.cookies['locale'])
|
1953
|
-
@title =
|
1954
|
-
@pause_msg =
|
1974
|
+
@title = ShowoffUtils.showoff_title(settings.pres_dir)
|
1975
|
+
@pause_msg = ShowoffUtils.pause_msg
|
1955
1976
|
what = params[:captures].first
|
1956
1977
|
opt = params[:captures][1]
|
1957
1978
|
what = 'index' if "" == what
|
@@ -1966,6 +1987,8 @@ class ShowOff < Sinatra::Application
|
|
1966
1987
|
if (what != "favicon.ico")
|
1967
1988
|
if ['supplemental', 'print'].include? what
|
1968
1989
|
data = send(what, opt)
|
1990
|
+
elsif File.file? what
|
1991
|
+
data = File.open(what)
|
1969
1992
|
else
|
1970
1993
|
data = send(what)
|
1971
1994
|
end
|
@@ -1989,7 +2012,7 @@ class ShowOff < Sinatra::Application
|
|
1989
2012
|
end
|
1990
2013
|
|
1991
2014
|
at_exit do
|
1992
|
-
|
2015
|
+
Showoff.flush
|
1993
2016
|
end
|
1994
2017
|
|
1995
2018
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'tilt/erb'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
class Showoff::Compiler
|
6
|
+
require 'showoff/compiler/form'
|
7
|
+
require 'showoff/compiler/variables'
|
8
|
+
require 'showoff/compiler/fixups'
|
9
|
+
require 'showoff/compiler/i18n'
|
10
|
+
require 'showoff/compiler/notes'
|
11
|
+
require 'showoff/compiler/glossary'
|
12
|
+
require 'showoff/compiler/downloads'
|
13
|
+
require 'showoff/compiler/table_of_contents'
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
@options = options
|
17
|
+
@profile = profile
|
18
|
+
end
|
19
|
+
|
20
|
+
# Configures Tilt with the selected engine and options.
|
21
|
+
#
|
22
|
+
# Returns render options profile hash
|
23
|
+
#
|
24
|
+
# Source:
|
25
|
+
# https://github.com/puppetlabs/showoff/blob/3f43754c84f97be4284bb34f9bc7c42175d45226/lib/showoff_utils.rb#L671-L720
|
26
|
+
# TODO: per slide profiles of render options
|
27
|
+
def profile
|
28
|
+
renderer = Showoff::Config.get('markdown')
|
29
|
+
profile = Showoff::Config.get(renderer)
|
30
|
+
|
31
|
+
begin
|
32
|
+
# Load markdown configuration
|
33
|
+
case renderer
|
34
|
+
when 'rdiscount'
|
35
|
+
Tilt.prefer Tilt::RDiscountTemplate, "markdown"
|
36
|
+
|
37
|
+
when 'maruku'
|
38
|
+
Tilt.prefer Tilt::MarukuTemplate, "markdown"
|
39
|
+
# Now check if we can go for latex mode
|
40
|
+
require 'maruku'
|
41
|
+
require 'maruku/ext/math'
|
42
|
+
|
43
|
+
if profile[:use_tex]
|
44
|
+
MaRuKu::Globals[:html_math_output_mathml] = false
|
45
|
+
MaRuKu::Globals[:html_math_output_png] = true
|
46
|
+
MaRuKu::Globals[:html_math_engine] = 'none'
|
47
|
+
MaRuKu::Globals[:html_png_engine] = 'blahtex'
|
48
|
+
MaRuKu::Globals[:html_png_dir] = profile[:png_dir]
|
49
|
+
MaRuKu::Globals[:html_png_url] = profile[:html_png_url]
|
50
|
+
end
|
51
|
+
|
52
|
+
when 'bluecloth'
|
53
|
+
Tilt.prefer Tilt::BlueClothTemplate, "markdown"
|
54
|
+
|
55
|
+
when 'kramdown'
|
56
|
+
Tilt.prefer Tilt::KramdownTemplate, "markdown"
|
57
|
+
|
58
|
+
when 'commonmarker', 'commonmark'
|
59
|
+
Tilt.prefer Tilt::CommonMarkerTemplate, "markdown"
|
60
|
+
|
61
|
+
when 'redcarpet', :default
|
62
|
+
Tilt.prefer Tilt::RedcarpetTemplate, "markdown"
|
63
|
+
|
64
|
+
else
|
65
|
+
raise 'Unsupported markdown renderer'
|
66
|
+
|
67
|
+
end
|
68
|
+
rescue LoadError
|
69
|
+
puts "ERROR: The #{renderer} markdown rendering engine does not appear to be installed correctly."
|
70
|
+
exit! 1
|
71
|
+
end
|
72
|
+
|
73
|
+
profile
|
74
|
+
end
|
75
|
+
|
76
|
+
# Compiles markdown and all Showoff extensions into the final HTML output and notes.
|
77
|
+
#
|
78
|
+
# @param content [String] markdown content.
|
79
|
+
# @return [[String, Array<String>]] A tuple of (html content, array of notes contents)
|
80
|
+
#
|
81
|
+
# @todo I think the update_image_paths() malarky is redundant. Verify that.
|
82
|
+
def render(content)
|
83
|
+
Variables::interpolate!(content)
|
84
|
+
I18n.selectLanguage!(content)
|
85
|
+
|
86
|
+
html = Tilt[:markdown].new(nil, nil, @profile) { content }.render
|
87
|
+
doc = Nokogiri::HTML::DocumentFragment.parse(html)
|
88
|
+
|
89
|
+
Form.render!(doc, @options)
|
90
|
+
Fixups.updateClasses!(doc)
|
91
|
+
Fixups.updateLinks!(doc)
|
92
|
+
Fixups.updateSyntaxHighlighting!(doc)
|
93
|
+
Fixups.updateCommandlineBlocks!(doc)
|
94
|
+
Fixups.updateImagePaths!(doc, @options)
|
95
|
+
Glossary.render!(doc)
|
96
|
+
Downloads.scanForFiles!(doc, @options)
|
97
|
+
|
98
|
+
# This call must be last in the chain because it separates notes from the
|
99
|
+
# content and returns them separately. If it's not last, then the notes
|
100
|
+
# won't have all the compilation steps applied to them.
|
101
|
+
#
|
102
|
+
# must pass in extra context because this will render markdown itself
|
103
|
+
Notes.render!(doc, @profile, @options)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|