nanoc3 3.2.0a4 → 3.2.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.md +20 -2
- data/README.md +7 -3
- data/bin/nanoc3 +1 -3
- data/lib/nanoc3.rb +1 -13
- data/lib/nanoc3/base/compilation/filter.rb +21 -0
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +1 -3
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +1 -1
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -2
- data/lib/nanoc3/base/compilation/rules_collection.rb +37 -13
- data/lib/nanoc3/base/directed_graph.rb +3 -3
- data/lib/nanoc3/base/memoization.rb +6 -9
- data/lib/nanoc3/base/source_data/code_snippet.rb +2 -1
- data/lib/nanoc3/base/source_data/configuration.rb +7 -3
- data/lib/nanoc3/base/source_data/item.rb +52 -10
- data/lib/nanoc3/base/source_data/layout.rb +28 -1
- data/lib/nanoc3/base/source_data/site.rb +14 -3
- data/lib/nanoc3/cli.rb +98 -6
- data/lib/nanoc3/cli/{base.rb → command.rb} +117 -153
- data/lib/nanoc3/cli/commands/autocompile.rb +20 -48
- data/lib/nanoc3/cli/commands/compile.rb +32 -48
- data/lib/nanoc3/cli/commands/create_item.rb +21 -37
- data/lib/nanoc3/cli/commands/create_layout.rb +18 -36
- data/lib/nanoc3/cli/commands/create_site.rb +15 -34
- data/lib/nanoc3/cli/commands/debug.rb +17 -31
- data/lib/nanoc3/cli/commands/info.rb +14 -29
- data/lib/nanoc3/cli/commands/nanoc.rb +37 -0
- data/lib/nanoc3/cli/commands/update.rb +21 -44
- data/lib/nanoc3/cli/commands/view.rb +18 -44
- data/lib/nanoc3/cli/commands/watch.rb +16 -31
- data/lib/nanoc3/data_sources/filesystem.rb +25 -6
- data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
- data/lib/nanoc3/extra/auto_compiler.rb +1 -0
- data/lib/nanoc3/extra/file_proxy.rb +0 -1
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/filters/asciidoc.rb +16 -36
- data/lib/nanoc3/filters/bluecloth.rb +2 -2
- data/lib/nanoc3/filters/coderay.rb +2 -2
- data/lib/nanoc3/filters/colorize_syntax.rb +18 -5
- data/lib/nanoc3/filters/erb.rb +2 -2
- data/lib/nanoc3/filters/erubis.rb +2 -2
- data/lib/nanoc3/filters/haml.rb +2 -2
- data/lib/nanoc3/filters/kramdown.rb +2 -2
- data/lib/nanoc3/filters/less.rb +32 -1
- data/lib/nanoc3/filters/markaby.rb +2 -2
- data/lib/nanoc3/filters/maruku.rb +2 -2
- data/lib/nanoc3/filters/mustache.rb +2 -2
- data/lib/nanoc3/filters/rainpress.rb +2 -2
- data/lib/nanoc3/filters/rdiscount.rb +4 -3
- data/lib/nanoc3/filters/rdoc.rb +10 -6
- data/lib/nanoc3/filters/redcarpet.rb +2 -2
- data/lib/nanoc3/filters/redcloth.rb +2 -2
- data/lib/nanoc3/filters/rubypants.rb +2 -2
- data/lib/nanoc3/filters/sass.rb +44 -52
- data/lib/nanoc3/filters/slim.rb +2 -2
- data/lib/nanoc3/filters/typogruby.rb +2 -2
- data/lib/nanoc3/filters/uglify_js.rb +42 -0
- data/nanoc3.gemspec +1 -1
- data/tasks/test.rake +6 -0
- data/test/base/core_ext/array_spec.rb +0 -2
- data/test/base/core_ext/hash_spec.rb +0 -2
- data/test/base/core_ext/pathname_spec.rb +0 -2
- data/test/base/core_ext/string_spec.rb +0 -2
- data/test/base/test_checksum_store.rb +0 -2
- data/test/base/test_code_snippet.rb +0 -2
- data/test/base/test_compiler.rb +2 -4
- data/test/base/test_compiler_dsl.rb +1 -3
- data/test/base/test_context.rb +0 -2
- data/test/base/test_data_source.rb +0 -2
- data/test/base/test_dependency_tracker.rb +0 -2
- data/test/base/test_directed_graph.rb +0 -2
- data/test/base/test_filter.rb +0 -2
- data/test/base/test_item.rb +19 -4
- data/test/base/test_item_rep.rb +0 -2
- data/test/base/test_layout.rb +19 -4
- data/test/base/test_memoization.rb +39 -2
- data/test/base/test_notification_center.rb +0 -2
- data/test/base/test_outdatedness_checker.rb +31 -2
- data/test/base/test_plugin.rb +0 -2
- data/test/base/test_rule.rb +0 -2
- data/test/base/test_rule_context.rb +0 -2
- data/test/base/test_site.rb +30 -3
- data/test/cli/commands/test_compile.rb +24 -3
- data/test/cli/commands/test_create_item.rb +5 -3
- data/test/cli/commands/test_create_layout.rb +4 -4
- data/test/cli/commands/test_create_site.rb +5 -5
- data/test/cli/commands/test_help.rb +3 -3
- data/test/cli/commands/test_info.rb +2 -3
- data/test/cli/commands/test_update.rb +0 -2
- data/test/cli/test_cli.rb +40 -0
- data/test/cli/test_logger.rb +0 -2
- data/test/data_sources/test_filesystem.rb +0 -2
- data/test/data_sources/test_filesystem_unified.rb +32 -58
- data/test/data_sources/test_filesystem_verbose.rb +0 -2
- data/test/extra/core_ext/test_enumerable.rb +0 -2
- data/test/extra/core_ext/test_time.rb +0 -2
- data/test/extra/deployers/test_rsync.rb +0 -2
- data/test/extra/test_auto_compiler.rb +5 -7
- data/test/extra/test_file_proxy.rb +0 -2
- data/test/extra/test_vcs.rb +0 -2
- data/test/extra/validators/test_links.rb +0 -2
- data/test/extra/validators/test_w3c.rb +0 -2
- data/test/filters/test_asciidoc.rb +0 -2
- data/test/filters/test_bluecloth.rb +0 -2
- data/test/filters/test_coderay.rb +0 -2
- data/test/filters/test_colorize_syntax.rb +49 -2
- data/test/filters/test_erb.rb +0 -2
- data/test/filters/test_erubis.rb +0 -2
- data/test/filters/test_haml.rb +0 -2
- data/test/filters/test_kramdown.rb +0 -2
- data/test/filters/test_less.rb +59 -5
- data/test/filters/test_markaby.rb +0 -2
- data/test/filters/test_maruku.rb +0 -2
- data/test/filters/test_mustache.rb +0 -2
- data/test/filters/test_rainpress.rb +0 -2
- data/test/filters/test_rdiscount.rb +0 -2
- data/test/filters/test_rdoc.rb +0 -2
- data/test/filters/test_redcarpet.rb +0 -2
- data/test/filters/test_redcloth.rb +0 -2
- data/test/filters/test_relativize_paths.rb +77 -24
- data/test/filters/test_rubypants.rb +0 -2
- data/test/filters/test_sass.rb +136 -10
- data/test/filters/test_slim.rb +0 -2
- data/test/filters/test_typogruby.rb +0 -2
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +3 -0
- data/test/helpers/test_blogging.rb +0 -2
- data/test/helpers/test_breadcrumbs.rb +0 -2
- data/test/helpers/test_capturing.rb +0 -2
- data/test/helpers/test_filtering.rb +0 -2
- data/test/helpers/test_html_escape.rb +0 -2
- data/test/helpers/test_link_to.rb +0 -2
- data/test/helpers/test_rendering.rb +0 -2
- data/test/helpers/test_tagging.rb +0 -2
- data/test/helpers/test_text.rb +0 -2
- data/test/helpers/test_xml_sitemap.rb +0 -2
- data/test/tasks/test_clean.rb +0 -2
- metadata +11 -9
- data/lib/nanoc3/cli/commands.rb +0 -16
- data/lib/nanoc3/cli/commands/help.rb +0 -71
- data/tasks/clean.rake +0 -11
data/lib/nanoc3/filters.rb
CHANGED
@@ -24,6 +24,7 @@ module Nanoc3::Filters
|
|
24
24
|
autoload 'Sass', 'nanoc3/filters/sass'
|
25
25
|
autoload 'Slim', 'nanoc3/filters/slim'
|
26
26
|
autoload 'Typogruby', 'nanoc3/filters/typogruby'
|
27
|
+
autoload 'UglifyJS', 'nanoc3/filters/uglify_js'
|
27
28
|
|
28
29
|
Nanoc3::Filter.register '::Nanoc3::Filters::AsciiDoc', :asciidoc
|
29
30
|
Nanoc3::Filter.register '::Nanoc3::Filters::BlueCloth', :bluecloth
|
@@ -47,5 +48,6 @@ module Nanoc3::Filters
|
|
47
48
|
Nanoc3::Filter.register '::Nanoc3::Filters::Sass', :sass
|
48
49
|
Nanoc3::Filter.register '::Nanoc3::Filters::Slim', :slim
|
49
50
|
Nanoc3::Filter.register '::Nanoc3::Filters::Typogruby', :typogruby
|
51
|
+
Nanoc3::Filter.register '::Nanoc3::Filters::UglifyJS', :uglify_js
|
50
52
|
|
51
53
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'systemu'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
|
5
7
|
# @since 3.2.0
|
@@ -12,45 +14,23 @@ module Nanoc3::Filters
|
|
12
14
|
#
|
13
15
|
# @return [String] The filtered content
|
14
16
|
def run(content, params={})
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
cmd_out = Tempfile.open('nanoc-asciidoc-out')
|
24
|
-
cmd_err = Tempfile.open('nanoc-asciidoc-err')
|
25
|
-
cmd_out.close
|
26
|
-
cmd_err.close
|
27
|
-
|
28
|
-
# Write input
|
29
|
-
cmd_in.write(content)
|
30
|
-
cmd_in.close
|
31
|
-
|
32
|
-
# Run
|
33
|
-
# TODO allow customizable options
|
34
|
-
fns = {
|
35
|
-
:in => Escape.shell_single_word(cmd_in.path),
|
36
|
-
:out => Escape.shell_single_word(cmd_out.path),
|
37
|
-
:err => Escape.shell_single_word(cmd_err.path),
|
38
|
-
}
|
39
|
-
command = "asciidoc -o #{fns[:out]} #{fns[:in]} 2>#{fns[:err]}"
|
40
|
-
system(command)
|
41
|
-
success = $?.success?
|
42
|
-
|
43
|
-
# Done
|
44
|
-
output = File.read(cmd_out.path)
|
45
|
-
errors = File.read(cmd_err.path)
|
46
|
-
end
|
17
|
+
# Run command
|
18
|
+
stdout = ''
|
19
|
+
stderr = ''
|
20
|
+
status = systemu(
|
21
|
+
[ 'asciidoc', '-o', '-', '-' ],
|
22
|
+
'stdin' => content,
|
23
|
+
'stdout' => stdout,
|
24
|
+
'stderr' => stderr)
|
47
25
|
|
48
26
|
# Show errors
|
49
|
-
|
50
|
-
|
27
|
+
unless status.success?
|
28
|
+
$stderr.puts stderr
|
29
|
+
raise RuntimeError, "AsciiDoc filter failed with status #{status}"
|
30
|
+
end
|
51
31
|
|
52
|
-
#
|
53
|
-
|
32
|
+
# Get result
|
33
|
+
stdout
|
54
34
|
end
|
55
35
|
|
56
36
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'bluecloth'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class BlueCloth < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'bluecloth'
|
14
|
-
|
15
15
|
::BlueCloth.new(content).to_html
|
16
16
|
end
|
17
17
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'coderay'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class CodeRay < Nanoc3::Filter
|
5
7
|
|
6
8
|
# @deprecated Use the `:colorize_syntax` filter instead.
|
7
9
|
def run(content, params={})
|
8
|
-
require 'coderay'
|
9
|
-
|
10
10
|
# Warn
|
11
11
|
warn 'The :coderay filter is deprecated; consider using the :colorize_syntax filter instead.'
|
12
12
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'stringio'
|
5
|
+
require 'open3'
|
6
|
+
|
3
7
|
module Nanoc3::Filters
|
4
8
|
class ColorizeSyntax < Nanoc3::Filter
|
5
9
|
|
@@ -55,18 +59,19 @@ module Nanoc3::Filters
|
|
55
59
|
#
|
56
60
|
# @param [String] content The content to filter
|
57
61
|
#
|
58
|
-
# @option params [
|
62
|
+
# @option params [Symbol] :default_colorizer (DEFAULT_COLORIZER) The
|
59
63
|
# default colorizer, i.e. the colorizer that will be used when the
|
60
64
|
# colorizer is not overriden for a specific language.
|
61
65
|
#
|
66
|
+
# @option params [Symbol] :syntax (:html) The syntax to use, which can be
|
67
|
+
# `:html`, `:xml` or `:xhtml`, the latter two being the same.
|
68
|
+
#
|
62
69
|
# @option params [Hash] :colorizers ({}) A hash containing
|
63
70
|
# a mapping of programming languages (symbols, not strings) onto
|
64
71
|
# colorizers (symbols).
|
65
72
|
#
|
66
73
|
# @return [String] The filtered content
|
67
74
|
def run(content, params={})
|
68
|
-
require 'nokogiri'
|
69
|
-
|
70
75
|
# Take colorizers from parameters
|
71
76
|
@colorizers = Hash.new(params[:default_colorizer] || DEFAULT_COLORIZER)
|
72
77
|
(params[:colorizers] || {}).each_pair do |language, colorizer|
|
@@ -177,8 +182,8 @@ module Nanoc3::Filters
|
|
177
182
|
#
|
178
183
|
# @return [String] The colorized output
|
179
184
|
def pygmentize(code, language, params={})
|
180
|
-
require 'stringio'
|
181
185
|
require 'systemu'
|
186
|
+
check_availability('pygmentize --V')
|
182
187
|
|
183
188
|
# Build command
|
184
189
|
cmd = [ 'pygmentize', '-l', language, '-f', 'html' ]
|
@@ -215,9 +220,10 @@ module Nanoc3::Filters
|
|
215
220
|
#
|
216
221
|
# @since 3.2.0
|
217
222
|
def simon_highlight(code, language, params={})
|
218
|
-
require 'stringio'
|
219
223
|
require 'systemu'
|
220
224
|
|
225
|
+
check_availability('highlight --version')
|
226
|
+
|
221
227
|
# Build command
|
222
228
|
cmd = [ 'highlight', '--syntax', language, '--fragment' ]
|
223
229
|
params.each do |key, value|
|
@@ -240,5 +246,12 @@ module Nanoc3::Filters
|
|
240
246
|
stdout.rewind
|
241
247
|
stdout.read
|
242
248
|
end
|
249
|
+
|
250
|
+
def check_availability(cmd)
|
251
|
+
Open3.popen3(*cmd) do |stdin, stdout, stderr, thread|
|
252
|
+
raise "Could not spawn #{cmd.join(' ')}" if thread.nil?
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
243
256
|
end
|
244
257
|
end
|
data/lib/nanoc3/filters/erb.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'erb'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class ERB < Nanoc3::Filter
|
5
7
|
|
@@ -14,8 +16,6 @@ module Nanoc3::Filters
|
|
14
16
|
#
|
15
17
|
# @return [String] The filtered content
|
16
18
|
def run(content, params={})
|
17
|
-
require 'erb'
|
18
|
-
|
19
19
|
# Create context
|
20
20
|
context = ::Nanoc3::Context.new(assigns)
|
21
21
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'erubis'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Erubis < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'erubis'
|
14
|
-
|
15
15
|
# Create context
|
16
16
|
context = ::Nanoc3::Context.new(assigns)
|
17
17
|
|
data/lib/nanoc3/filters/haml.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'haml'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Haml < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'haml'
|
14
|
-
|
15
15
|
# Get options
|
16
16
|
options = params.merge(:filename => filename)
|
17
17
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'kramdown'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Kramdown < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'kramdown'
|
14
|
-
|
15
15
|
# Get result
|
16
16
|
::Kramdown::Document.new(content, params).to_html
|
17
17
|
end
|
data/lib/nanoc3/filters/less.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'less'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Less < Nanoc3::Filter
|
5
7
|
|
@@ -10,7 +12,36 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
|
15
|
+
# Find imports (hacky)
|
16
|
+
imports = []
|
17
|
+
imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
|
18
|
+
imports.concat(content.scan(/^@import\s+url\((["']?)([^)]+?)\1\);/))
|
19
|
+
imported_filenames = imports.map do |i|
|
20
|
+
i[1].match(/\.(less|css)$/) ? i[1] : i[1] + '.less'
|
21
|
+
end
|
22
|
+
|
23
|
+
# Convert to items
|
24
|
+
imported_items = imported_filenames.map do |filename|
|
25
|
+
# Find directory for this item
|
26
|
+
current_dir_pathname = Pathname.new(@item[:content_filename]).dirname.realpath
|
27
|
+
|
28
|
+
# Find absolute pathname for imported item
|
29
|
+
imported_pathname = Pathname.new(filename)
|
30
|
+
if imported_pathname.relative?
|
31
|
+
imported_pathname = current_dir_pathname + imported_pathname
|
32
|
+
end
|
33
|
+
next if !imported_pathname.exist?
|
34
|
+
imported_filename = imported_pathname.realpath
|
35
|
+
|
36
|
+
# Find matching item
|
37
|
+
@items.find do |i|
|
38
|
+
next if i[:content_filename].nil?
|
39
|
+
Pathname.new(i[:content_filename]).realpath == imported_filename
|
40
|
+
end
|
41
|
+
end.compact
|
42
|
+
|
43
|
+
# Create dependencies
|
44
|
+
depend_on(imported_items)
|
14
45
|
|
15
46
|
# Add filename to load path
|
16
47
|
paths = [ File.dirname(@item[:content_filename]) ]
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'markaby'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Markaby < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'markaby'
|
14
|
-
|
15
15
|
# Get result
|
16
16
|
::Markaby::Builder.new(assigns).instance_eval(content).to_s
|
17
17
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'maruku'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Maruku < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'maruku'
|
14
|
-
|
15
15
|
# Get result
|
16
16
|
::Maruku.new(content, params).to_html
|
17
17
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'mustache'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
|
5
7
|
# @since 3.2.0
|
@@ -13,8 +15,6 @@ module Nanoc3::Filters
|
|
13
15
|
#
|
14
16
|
# @return [String] The filtered content
|
15
17
|
def run(content, params={})
|
16
|
-
require 'mustache'
|
17
|
-
|
18
18
|
# Get result
|
19
19
|
::Mustache.render(content, item.attributes)
|
20
20
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'rainpress'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class Rainpress < Nanoc3::Filter
|
5
7
|
|
@@ -10,8 +12,6 @@ module Nanoc3::Filters
|
|
10
12
|
#
|
11
13
|
# @return [String] The filtered content
|
12
14
|
def run(content, params={})
|
13
|
-
require 'rainpress'
|
14
|
-
|
15
15
|
::Rainpress.compress(content, params)
|
16
16
|
end
|
17
17
|
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'rdiscount'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
class RDiscount < Nanoc3::Filter
|
5
7
|
|
6
8
|
# Runs the content through [RDiscount](http://github.com/rtomayko/rdiscount).
|
7
|
-
#
|
9
|
+
#
|
10
|
+
# @option params [Array] symbol ([]) A list of RDiscount extensions
|
8
11
|
#
|
9
12
|
# @param [String] content The content to filter
|
10
13
|
#
|
11
14
|
# @return [String] The filtered content
|
12
15
|
def run(content, params={})
|
13
|
-
require 'rdiscount'
|
14
|
-
|
15
16
|
extensions = params[:extensions] || []
|
16
17
|
|
17
18
|
::RDiscount.new(content, *extensions).to_html
|
data/lib/nanoc3/filters/rdoc.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
begin
|
4
|
+
# new RDoc
|
5
|
+
require 'rdoc/markup'
|
6
|
+
require 'rdoc/markup/to_html'
|
7
|
+
rescue LoadError
|
8
|
+
# old RDoc
|
9
|
+
require 'rdoc/markup/simple_markup'
|
10
|
+
require 'rdoc/markup/simple_markup/to_html'
|
11
|
+
end
|
12
|
+
|
3
13
|
module Nanoc3::Filters
|
4
14
|
class RDoc < Nanoc3::Filter
|
5
15
|
|
@@ -12,15 +22,9 @@ module Nanoc3::Filters
|
|
12
22
|
def run(content, params={})
|
13
23
|
begin
|
14
24
|
# new RDoc
|
15
|
-
require 'rdoc/markup'
|
16
|
-
require 'rdoc/markup/to_html'
|
17
|
-
|
18
25
|
::RDoc::Markup.new.convert(content, ::RDoc::Markup::ToHtml.new)
|
19
26
|
rescue LoadError
|
20
27
|
# old RDoc
|
21
|
-
require 'rdoc/markup/simple_markup'
|
22
|
-
require 'rdoc/markup/simple_markup/to_html'
|
23
|
-
|
24
28
|
::SM::SimpleMarkup.new.convert(content, ::SM::ToHtml.new)
|
25
29
|
end
|
26
30
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require 'redcarpet'
|
4
|
+
|
3
5
|
module Nanoc3::Filters
|
4
6
|
|
5
7
|
# @since 3.2.0
|
@@ -15,8 +17,6 @@ module Nanoc3::Filters
|
|
15
17
|
#
|
16
18
|
# @return [String] The filtered content
|
17
19
|
def run(content, params={})
|
18
|
-
require 'redcarpet'
|
19
|
-
|
20
20
|
options = params[:options] || []
|
21
21
|
|
22
22
|
::Redcarpet.new(content, *options).to_html
|