redcarpet 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/redcarpet.rb +1 -1
- data/lib/redcarpet/cli.rb +86 -0
- data/redcarpet.gemspec +3 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 357df7331e4bc2256b21132e897105ce6241494b
|
4
|
+
data.tar.gz: 28ce2d2ad837940fff06c2a4ee3a6b501fc3d6fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2971c2bea2d9117e85e87ee9d889b6ef466fedff78c35286847bba884ca4591c7e672b12032f371bff8a02cb308a703689982b6056cc0ca90d6bb8eaf9f1f3af
|
7
|
+
data.tar.gz: 987022b77e2b3bdbf6b87191c9b90056da7c1eed3a30b29f510ab6bbbd0268d040d08399a67237cbde425656ea5704867c086b7d400c4458ae4a868da7c6ee5c
|
data/lib/redcarpet.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
module Redcarpet
|
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 < Redcarpet::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: redcarpet [--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 "Redcarpet #{Redcarpet::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
|
+
Redcarpet::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
|
data/redcarpet.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'redcarpet'
|
4
|
-
s.version = '3.3.
|
4
|
+
s.version = '3.3.1'
|
5
5
|
s.summary = "Markdown that smells nice"
|
6
6
|
s.description = 'A fast, safe and extensible Markdown to (X)HTML parser'
|
7
|
-
s.date = '2015-06-
|
7
|
+
s.date = '2015-06-07'
|
8
8
|
s.email = 'vicent@github.com'
|
9
9
|
s.homepage = 'http://github.com/vmg/redcarpet'
|
10
10
|
s.authors = ["Natacha Porté", "Vicent Martí"]
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
ext/redcarpet/stack.c
|
38
38
|
ext/redcarpet/stack.h
|
39
39
|
lib/redcarpet.rb
|
40
|
+
lib/redcarpet/cli.rb
|
40
41
|
lib/redcarpet/compat.rb
|
41
42
|
lib/redcarpet/render_man.rb
|
42
43
|
lib/redcarpet/render_strip.rb
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Natacha Porté
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-06-
|
12
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- ext/redcarpet/stack.c
|
74
74
|
- ext/redcarpet/stack.h
|
75
75
|
- lib/redcarpet.rb
|
76
|
+
- lib/redcarpet/cli.rb
|
76
77
|
- lib/redcarpet/compat.rb
|
77
78
|
- lib/redcarpet/render_man.rb
|
78
79
|
- lib/redcarpet/render_strip.rb
|