greenmat 3.2.0.1 → 3.2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +15 -0
- data/greenmat.gemspec +3 -47
- data/lib/greenmat/cli.rb +86 -0
- data/lib/greenmat/version.rb +3 -0
- data/spec/greenmat/markdown_spec.rb +65 -0
- data/spec/spec_helper.rb +90 -0
- data/tasks/generate_xcode_project.rake +5 -0
- data/tasks/greenmat.rake +65 -0
- data/tasks/spec.rake +5 -0
- data/test/MarkdownTest_1.0.3/MarkdownTest.pl +181 -0
- data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html +17 -0
- data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Tests/Auto links.html +18 -0
- data/test/MarkdownTest_1.0.3/Tests/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.html +118 -0
- data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html +15 -0
- data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Tests/Code Blocks.html +18 -0
- data/test/MarkdownTest_1.0.3/Tests/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Tests/Code Spans.html +6 -0
- data/test/MarkdownTest_1.0.3/Tests/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.html +71 -0
- data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html +15 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html +72 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.html +13 -0
- data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, inline style.html +11 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, reference style.html +52 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.html +9 -0
- data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html +3 -0
- data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html +314 -0
- data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html +942 -0
- data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.html +9 -0
- data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html +148 -0
- data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Tests/Strong and em together.html +7 -0
- data/test/MarkdownTest_1.0.3/Tests/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tests/Tabs.html +25 -0
- data/test/MarkdownTest_1.0.3/Tests/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tests/Tidyness.html +8 -0
- data/test/MarkdownTest_1.0.3/Tests/Tidyness.text +5 -0
- data/test/MarkdownTest_1.0/MarkdownTest.pl +162 -0
- data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.html +17 -0
- data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0/Tests/Auto links.html +18 -0
- data/test/MarkdownTest_1.0/Tests/Auto links.text +13 -0
- data/test/MarkdownTest_1.0/Tests/Backslash escapes.html +102 -0
- data/test/MarkdownTest_1.0/Tests/Backslash escapes.text +104 -0
- data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.html +15 -0
- data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0/Tests/Horizontal rules.html +71 -0
- data/test/MarkdownTest_1.0/Tests/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).html +14 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).text +14 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).html +72 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML comments.html +13 -0
- data/test/MarkdownTest_1.0/Tests/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0/Tests/Links, inline style.html +9 -0
- data/test/MarkdownTest_1.0/Tests/Links, inline style.text +9 -0
- data/test/MarkdownTest_1.0/Tests/Links, reference style.html +18 -0
- data/test/MarkdownTest_1.0/Tests/Links, reference style.text +31 -0
- data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.html +3 -0
- data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.html +314 -0
- data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.html +942 -0
- data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0/Tests/Nested blockquotes.html +9 -0
- data/test/MarkdownTest_1.0/Tests/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.html +137 -0
- data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.text +122 -0
- data/test/MarkdownTest_1.0/Tests/Strong and em together.html +7 -0
- data/test/MarkdownTest_1.0/Tests/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0/Tests/Tabs.html +25 -0
- data/test/MarkdownTest_1.0/Tests/Tabs.text +21 -0
- data/test/MarkdownTest_1.0/Tests/Tidyness.html +8 -0
- data/test/MarkdownTest_1.0/Tests/Tidyness.text +5 -0
- data/test/fixtures/benchmark.md +232 -0
- data/test/greenmat_bin_test.rb +80 -0
- metadata +186 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 640a48e0309d3ad49841f279024df4b6bfad325f
|
|
4
|
+
data.tar.gz: 6d5c03df89ba11808bb57ca7c156336e4f300a92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c6ed914f324b245051525b3a8ff1189ac7a7144ad370254245448e0d857bcae235b1c202e9e66597a51df931f59c042ff2f345580c5765ba2160b81aa8a45fe
|
|
7
|
+
data.tar.gz: e7479bf0e3e018566ea1640e09981d7eddb36d8eebe3e4b64946130abf0951220f08e923b1032769ad20d941a836cc0be129fe0b70ef729f460a2215987f4581
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/greenmat.gemspec
CHANGED
|
@@ -13,53 +13,9 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.authors = ["Natacha Porté", "Vicent Martí"]
|
|
14
14
|
s.license = 'MIT'
|
|
15
15
|
s.required_ruby_version = '>= 2.0.0'
|
|
16
|
-
|
|
17
|
-
s.files =
|
|
18
|
-
|
|
19
|
-
Gemfile
|
|
20
|
-
README.md
|
|
21
|
-
Rakefile
|
|
22
|
-
bin/greenmat
|
|
23
|
-
ext/greenmat/autolink.c
|
|
24
|
-
ext/greenmat/autolink.h
|
|
25
|
-
ext/greenmat/buffer.c
|
|
26
|
-
ext/greenmat/buffer.h
|
|
27
|
-
ext/greenmat/extconf.rb
|
|
28
|
-
ext/greenmat/houdini.h
|
|
29
|
-
ext/greenmat/houdini_href_e.c
|
|
30
|
-
ext/greenmat/houdini_html_e.c
|
|
31
|
-
ext/greenmat/html.c
|
|
32
|
-
ext/greenmat/html.h
|
|
33
|
-
ext/greenmat/html_blocks.h
|
|
34
|
-
ext/greenmat/html_smartypants.c
|
|
35
|
-
ext/greenmat/markdown.c
|
|
36
|
-
ext/greenmat/markdown.h
|
|
37
|
-
ext/greenmat/gm_markdown.c
|
|
38
|
-
ext/greenmat/gm_render.c
|
|
39
|
-
ext/greenmat/greenmat.h
|
|
40
|
-
ext/greenmat/stack.c
|
|
41
|
-
ext/greenmat/stack.h
|
|
42
|
-
lib/greenmat.rb
|
|
43
|
-
lib/greenmat/compat.rb
|
|
44
|
-
lib/greenmat/render_man.rb
|
|
45
|
-
lib/greenmat/render_strip.rb
|
|
46
|
-
greenmat.gemspec
|
|
47
|
-
test/benchmark.rb
|
|
48
|
-
test/custom_render_test.rb
|
|
49
|
-
test/html5_test.rb
|
|
50
|
-
test/html_render_test.rb
|
|
51
|
-
test/html_toc_render_test.rb
|
|
52
|
-
test/markdown_test.rb
|
|
53
|
-
test/pathological_inputs_test.rb
|
|
54
|
-
test/greenmat_compat_test.rb
|
|
55
|
-
test/safe_render_test.rb
|
|
56
|
-
test/smarty_html_test.rb
|
|
57
|
-
test/smarty_pants_test.rb
|
|
58
|
-
test/stripdown_render_test.rb
|
|
59
|
-
test/test_helper.rb
|
|
60
|
-
]
|
|
61
|
-
# = MANIFEST =
|
|
62
|
-
s.test_files = s.files.grep(%r{^test/})
|
|
16
|
+
|
|
17
|
+
s.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
63
19
|
s.extra_rdoc_files = ["COPYING"]
|
|
64
20
|
s.extensions = ["ext/greenmat/extconf.rb"]
|
|
65
21
|
s.executables = ["greenmat"]
|
data/lib/greenmat/cli.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'greenmat'
|
|
2
|
+
require 'optparse'
|
|
3
|
+
|
|
4
|
+
module Greenmat
|
|
5
|
+
# This class aims at easing the creation of custom
|
|
6
|
+
# binary for your needs. For example, you can add new
|
|
7
|
+
# options or change the existing ones. The parsing
|
|
8
|
+
# is handled by Ruby's OptionParser. For instance:
|
|
9
|
+
#
|
|
10
|
+
# class Custom::CLI < Greenmat::CLI
|
|
11
|
+
# def self.options_parser
|
|
12
|
+
# super.tap do |opts|
|
|
13
|
+
# opts.on("--rainbow") do
|
|
14
|
+
# @@options[:rainbow] = true
|
|
15
|
+
# end
|
|
16
|
+
# end
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# def self.render_object
|
|
20
|
+
# @@options[:rainbow] ? RainbowRender : super
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
class CLI
|
|
24
|
+
def self.options_parser
|
|
25
|
+
@@options = {
|
|
26
|
+
render_extensions: {},
|
|
27
|
+
parse_extensions: {},
|
|
28
|
+
smarty_pants: false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
OptionParser.new do |opts|
|
|
32
|
+
opts.banner = "Usage: greenmat [--parse <extension>...] " \
|
|
33
|
+
"[--render <extension>...] [--smarty] <file>..."
|
|
34
|
+
|
|
35
|
+
opts.on("--parse EXTENSION", "Enable a parsing extension") do |ext|
|
|
36
|
+
ext = ext.gsub('-', '_').to_sym
|
|
37
|
+
@@options[:parse_extensions][ext] = true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
opts.on("--render EXTENSION", "Enable a rendering extension") do |ext|
|
|
41
|
+
ext = ext.gsub('-', '_').to_sym
|
|
42
|
+
@@options[:render_extensions][ext] = true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
opts.on("--smarty", "Enable Smarty Pants") do
|
|
46
|
+
@@options[:smarty_pants] = true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
opts.on_tail("-v", "--version", "Display the current version") do
|
|
50
|
+
STDOUT.write "Greenmat #{Greenmat::VERSION}"
|
|
51
|
+
exit
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
opts.on_tail("-h", "--help", "Display this help message") do
|
|
55
|
+
puts opts
|
|
56
|
+
exit
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.process(args)
|
|
62
|
+
self.legacy_parse!(args)
|
|
63
|
+
self.options_parser.parse!(args)
|
|
64
|
+
STDOUT.write parser_object.render(ARGF.read)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.render_object
|
|
68
|
+
@@options[:smarty_pants] ? Render::SmartyHTML : Render::HTML
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.parser_object
|
|
72
|
+
renderer = render_object.new(@@options[:render_extensions])
|
|
73
|
+
Greenmat::Markdown.new(renderer, @@options[:parse_extensions])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.legacy_parse!(args) # :nodoc:
|
|
77
|
+
# Workaround for backward compatibility as OptionParser
|
|
78
|
+
# doesn't support the --flag-OPTION syntax.
|
|
79
|
+
args.select {|a| a =~ /--(parse|render)-/ }.each do |arg|
|
|
80
|
+
args.delete(arg)
|
|
81
|
+
arg = arg.partition(/\b-/)
|
|
82
|
+
args.push(arg.first, arg.last)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'greenmat'
|
|
2
|
+
|
|
3
|
+
module Greenmat
|
|
4
|
+
RSpec.describe Markdown do
|
|
5
|
+
subject(:markdown) { Markdown.new(renderer, options) }
|
|
6
|
+
let(:renderer) { Render::HTML.new }
|
|
7
|
+
let(:options) { {} }
|
|
8
|
+
let(:rendered_html) { markdown.render(text) }
|
|
9
|
+
|
|
10
|
+
context 'with no_mention_emphasis option' do
|
|
11
|
+
let(:options) { { no_mention_emphasis: true } }
|
|
12
|
+
|
|
13
|
+
[
|
|
14
|
+
['@_username_', false],
|
|
15
|
+
['@__username__', false],
|
|
16
|
+
['@___username___', false],
|
|
17
|
+
['@user__name__', false],
|
|
18
|
+
['@some__user__name__', false],
|
|
19
|
+
[' @_username_', false],
|
|
20
|
+
['あ@_username_', false],
|
|
21
|
+
['A@_username_', true],
|
|
22
|
+
['@*username*', true],
|
|
23
|
+
['_foo_', true],
|
|
24
|
+
['_', false],
|
|
25
|
+
['_foo @username_', false],
|
|
26
|
+
['__foo @username__', false],
|
|
27
|
+
['___foo @username___', false]
|
|
28
|
+
].each do |text, emphasize|
|
|
29
|
+
context "with text #{text.inspect}" do
|
|
30
|
+
let(:text) { text }
|
|
31
|
+
|
|
32
|
+
if emphasize
|
|
33
|
+
it 'emphasizes the text' do
|
|
34
|
+
expect(rendered_html).to include('<em>').or include('<strong>')
|
|
35
|
+
end
|
|
36
|
+
else
|
|
37
|
+
it 'does not emphasize the text' do
|
|
38
|
+
expect(rendered_html.chomp).to eq("<p>#{text.strip}</p>")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context 'without no_mention_emphasis option' do
|
|
46
|
+
let(:options) { {} }
|
|
47
|
+
|
|
48
|
+
context 'with text "@_username_"' do
|
|
49
|
+
let(:text) { '@_username_' }
|
|
50
|
+
|
|
51
|
+
it 'emphasizes the text' do
|
|
52
|
+
expect(rendered_html).to include('<em>')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'with text "_foo @username_"' do
|
|
57
|
+
let(:text) { '_foo @username_' }
|
|
58
|
+
|
|
59
|
+
it 'emphasizes the text' do
|
|
60
|
+
expect(rendered_html).to include('<em>')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
5
|
+
# files.
|
|
6
|
+
#
|
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
|
13
|
+
# it.
|
|
14
|
+
#
|
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
16
|
+
# users commonly want.
|
|
17
|
+
#
|
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
22
|
+
# assertions if you prefer.
|
|
23
|
+
config.expect_with :rspec do |expectations|
|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
26
|
+
# defined using `chain`, e.g.:
|
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
29
|
+
# ...rather than:
|
|
30
|
+
# # => "be bigger than 2"
|
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
36
|
+
config.mock_with :rspec do |mocks|
|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
38
|
+
# a real object. This is generally recommended, and will default to
|
|
39
|
+
# `true` in RSpec 4.
|
|
40
|
+
mocks.verify_partial_doubles = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
45
|
+
|
|
46
|
+
# These two settings work together to allow you to limit a spec run
|
|
47
|
+
# to individual examples or groups you care about by tagging them with
|
|
48
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
49
|
+
# get run.
|
|
50
|
+
config.filter_run :focus
|
|
51
|
+
config.run_all_when_everything_filtered = true
|
|
52
|
+
|
|
53
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
54
|
+
# recommended. For more details, see:
|
|
55
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
56
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
57
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
58
|
+
config.disable_monkey_patching!
|
|
59
|
+
|
|
60
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
61
|
+
# be too noisy due to issues in dependencies.
|
|
62
|
+
# config.warnings = true
|
|
63
|
+
|
|
64
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
65
|
+
# file, and it's useful to allow more verbose output when running an
|
|
66
|
+
# individual spec file.
|
|
67
|
+
if config.files_to_run.one?
|
|
68
|
+
# Use the documentation formatter for detailed output,
|
|
69
|
+
# unless a formatter has already been configured
|
|
70
|
+
# (e.g. via a command-line flag).
|
|
71
|
+
config.default_formatter = 'doc'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Print the 10 slowest examples and example groups at the
|
|
75
|
+
# end of the spec run, to help surface which specs are running
|
|
76
|
+
# particularly slow.
|
|
77
|
+
# config.profile_examples = 10
|
|
78
|
+
|
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
81
|
+
# the seed, which is printed after each run.
|
|
82
|
+
# --seed 1234
|
|
83
|
+
config.order = :random
|
|
84
|
+
|
|
85
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
86
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
87
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
88
|
+
# as the one that triggered the failure.
|
|
89
|
+
Kernel.srand config.seed
|
|
90
|
+
end
|
data/tasks/greenmat.rake
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
namespace :greenmat do
|
|
2
|
+
desc 'Rename Redcarpet project to Greenmat'
|
|
3
|
+
task :rename_project do
|
|
4
|
+
ProjectRenamer.rename
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ProjectRenamer
|
|
9
|
+
PATH_MAP = {
|
|
10
|
+
'redcarpet' => 'greenmat',
|
|
11
|
+
'rc_' => 'gm_'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SYMBOL_MAP = {
|
|
15
|
+
'redcarpet' => 'greenmat',
|
|
16
|
+
'Redcarpet' => 'Greenmat',
|
|
17
|
+
'REDCARPET' => 'GREENMAT',
|
|
18
|
+
/\brc_/ => 'gm_'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
SYMBOL_RENAME_EXCLUSION_PATH_PATTERNS = [
|
|
22
|
+
/^tasks\//,
|
|
23
|
+
/^tmp\//,
|
|
24
|
+
/\.(?:bundle|so)$/,
|
|
25
|
+
/README/
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
module_function
|
|
29
|
+
|
|
30
|
+
def rename
|
|
31
|
+
rename_paths
|
|
32
|
+
rename_symbols
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def rename_paths
|
|
36
|
+
Dir['**/*'].each do |path|
|
|
37
|
+
PATH_MAP.each do |old, new|
|
|
38
|
+
next unless path.include?(old)
|
|
39
|
+
is_directory = File.directory?(path)
|
|
40
|
+
File.rename(path, path.gsub(old, new))
|
|
41
|
+
fail RenamedDirectory if is_directory
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
rescue RenamedDirectory
|
|
45
|
+
retry
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def rename_symbols
|
|
49
|
+
Dir['**/*'].each do |path|
|
|
50
|
+
next unless File.file?(path)
|
|
51
|
+
next if SYMBOL_RENAME_EXCLUSION_PATH_PATTERNS.any? { |pattern| path.match(pattern) }
|
|
52
|
+
|
|
53
|
+
source = File.read(path)
|
|
54
|
+
|
|
55
|
+
SYMBOL_MAP.each do |old, new|
|
|
56
|
+
source.gsub!(old, new)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
File.write(path, source)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class RenamedDirectory < StandardError
|
|
64
|
+
end
|
|
65
|
+
end
|
data/tasks/spec.rake
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/perl
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# MarkdownTester -- Run tests for Markdown implementations
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2004-2005 John Gruber
|
|
7
|
+
# <http://daringfireball.net/projects/markdown/>
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
use strict;
|
|
11
|
+
use warnings;
|
|
12
|
+
use Getopt::Long;
|
|
13
|
+
use Benchmark;
|
|
14
|
+
|
|
15
|
+
our $VERSION = '1.0.2';
|
|
16
|
+
# Sat 24 Dec 2005
|
|
17
|
+
|
|
18
|
+
my $time_start = new Benchmark;
|
|
19
|
+
my $test_dir = "Tests";
|
|
20
|
+
my $script = "./Markdown.pl";
|
|
21
|
+
my $use_tidy = 0;
|
|
22
|
+
my ($flag_version);
|
|
23
|
+
|
|
24
|
+
GetOptions (
|
|
25
|
+
"script=s" => \$script,
|
|
26
|
+
"testdir=s" => \$test_dir,
|
|
27
|
+
"tidy" => \$use_tidy,
|
|
28
|
+
"version" => \$flag_version,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if($flag_version) {
|
|
32
|
+
my $progname = $0;
|
|
33
|
+
$progname =~ s{.*/}{};
|
|
34
|
+
die "$progname version $VERSION\n";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
unless (-d $test_dir) { die "'$test_dir' is not a directory.\n"; }
|
|
38
|
+
unless (-f $script) { die "$script does not exist.\n"; }
|
|
39
|
+
unless (-x $script) { die "$script is not executable.\n"; }
|
|
40
|
+
|
|
41
|
+
my $tests_passed = 0;
|
|
42
|
+
my $tests_failed = 0;
|
|
43
|
+
|
|
44
|
+
TEST:
|
|
45
|
+
foreach my $testfile (glob "$test_dir/*.text") {
|
|
46
|
+
my $testname = $testfile;
|
|
47
|
+
$testname =~ s{.*/(.+)\.text$}{$1}i;
|
|
48
|
+
print "$testname ... ";
|
|
49
|
+
|
|
50
|
+
# Look for a corresponding .html file for each .text file:
|
|
51
|
+
my $resultfile = $testfile;
|
|
52
|
+
$resultfile =~ s{\.text$}{\.html}i;
|
|
53
|
+
unless (-f $resultfile) {
|
|
54
|
+
print "'$resultfile' does not exist.\n\n";
|
|
55
|
+
next TEST;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# open(TEST, $testfile) || die("Can't open testfile: $!");
|
|
59
|
+
open(RESULT, $resultfile) || die("Can't open resultfile: $!");
|
|
60
|
+
undef $/;
|
|
61
|
+
# my $t_input = <TEST>;
|
|
62
|
+
my $t_result = <RESULT>;
|
|
63
|
+
|
|
64
|
+
my $t_output = `'$script' '$testfile'`;
|
|
65
|
+
|
|
66
|
+
# Normalize the output and expected result strings:
|
|
67
|
+
$t_result =~ s/\s+\z//; # trim trailing whitespace
|
|
68
|
+
$t_output =~ s/\s+\z//; # trim trailing whitespace
|
|
69
|
+
if ($use_tidy) {
|
|
70
|
+
# Escape the strings, pass them through to CLI tidy tool for tag-level equivalency
|
|
71
|
+
$t_result =~ s{'}{'\\''}g; # escape ' chars for shell
|
|
72
|
+
$t_output =~ s{'}{'\\''}g;
|
|
73
|
+
$t_result = `echo '$t_result' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
|
|
74
|
+
$t_output = `echo '$t_output' | tidy --show-body-only 1 --quiet 1 --show-warnings 0`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if ($t_output eq $t_result) {
|
|
78
|
+
print "OK\n";
|
|
79
|
+
$tests_passed++;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
print "FAILED\n\n";
|
|
83
|
+
# This part added by JM to print diffs
|
|
84
|
+
open(OUT, '>tmp1') or die $!;
|
|
85
|
+
print OUT $t_output or die $!;
|
|
86
|
+
open(RES, '>tmp2') or die $!;
|
|
87
|
+
print RES $t_result or die $!;
|
|
88
|
+
print `diff tmp1 tmp2`;
|
|
89
|
+
close RES;
|
|
90
|
+
close OUT;
|
|
91
|
+
print "\n";
|
|
92
|
+
`rm tmp?`;
|
|
93
|
+
# End of added part
|
|
94
|
+
$tests_failed++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
print "\n\n";
|
|
99
|
+
print "$tests_passed passed; $tests_failed failed.\n";
|
|
100
|
+
|
|
101
|
+
my $time_end = new Benchmark;
|
|
102
|
+
my $time_diff = timediff($time_end, $time_start);
|
|
103
|
+
print "Benchmark: ", timestr($time_diff), "\n";
|
|
104
|
+
|
|
105
|
+
if ($tests_failed ne 0) {
|
|
106
|
+
exit 1;
|
|
107
|
+
} else {
|
|
108
|
+
exit 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
__END__
|
|
112
|
+
|
|
113
|
+
=pod
|
|
114
|
+
|
|
115
|
+
=head1 NAME
|
|
116
|
+
|
|
117
|
+
B<MarkdownTest>
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
=head1 SYNOPSIS
|
|
121
|
+
|
|
122
|
+
B<MarkdownTest.pl> [ B<--options> ] [ I<file> ... ]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
=head1 DESCRIPTION
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
=head1 OPTIONS
|
|
129
|
+
|
|
130
|
+
Use "--" to end switch parsing. For example, to open a file named "-z", use:
|
|
131
|
+
|
|
132
|
+
MarkdownTest.pl -- -z
|
|
133
|
+
|
|
134
|
+
=over 4
|
|
135
|
+
|
|
136
|
+
=item B<--script>
|
|
137
|
+
|
|
138
|
+
Specify the path to the Markdown script to test. Defaults to
|
|
139
|
+
"./Markdown.pl". Example:
|
|
140
|
+
|
|
141
|
+
./MarkdownTest.pl --script ./PHP-Markdown/php-markdown
|
|
142
|
+
|
|
143
|
+
=item B<--testdir>
|
|
144
|
+
|
|
145
|
+
Specify the path to a directory containing test data. Defaults to "Tests".
|
|
146
|
+
|
|
147
|
+
=item B<--tidy>
|
|
148
|
+
|
|
149
|
+
Flag to turn on using the command line 'tidy' tool to normalize HTML
|
|
150
|
+
output before comparing script output to the expected test result.
|
|
151
|
+
Assumes that the 'tidy' command is available in your PATH. Defaults to
|
|
152
|
+
off.
|
|
153
|
+
|
|
154
|
+
=back
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
=head1 BUGS
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
=head1 VERSION HISTORY
|
|
163
|
+
|
|
164
|
+
1.0 Mon 13 Dec 2004-2005
|
|
165
|
+
|
|
166
|
+
1.0.1 Mon 19 Sep 2005
|
|
167
|
+
|
|
168
|
+
+ Better handling of case when foo.text exists, but foo.html doesn't.
|
|
169
|
+
It now prints a message and moves on, rather than dying.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
=head1 COPYRIGHT AND LICENSE
|
|
173
|
+
|
|
174
|
+
Copyright (c) 2004-2005 John Gruber
|
|
175
|
+
<http://daringfireball.net/>
|
|
176
|
+
All rights reserved.
|
|
177
|
+
|
|
178
|
+
This is free software; you may redistribute it and/or modify it under
|
|
179
|
+
the same terms as Perl itself.
|
|
180
|
+
|
|
181
|
+
=cut
|