mdoc 0.0.8 → 0.0.9
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 +8 -8
- data/.rubocop.yml +2 -0
- data/README.md +3 -1
- data/bin/mdoc +2 -2
- data/lib/mdoc/meta.rb +1 -1
- data/lib/mdoc/pipeline.rb +5 -0
- data/lib/mdoc/version.rb +1 -1
- data/lib/mdoc/writer/pandoc_writer.rb +25 -0
- data/lib/mdoc/writer.rb +9 -0
- data/lib/mdoc.rb +20 -23
- data/spec/fixtures/multikeys.html +1 -1
- data/spec/pipeline_spec.rb +11 -7
- data/spec/tpl_out_spec.rb +2 -2
- data/templates/pandoc.md.erb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDhlMjI1YzQ4Yjc4ODQ2Nzg2NjRjMWUwMzY0ZDY2NjgxMzk3MTdkNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmY3M2I3ODZhNjE3ZTk2OTQxNTlhNDdlY2VjZTlkN2NiMjkxYmNjOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmM5NDhhYmYzYWNjZjI2OWI1MjFjM2E4ZjlkZTk3ZmJlZTEwNzI4OTc1MTU4
|
10
|
+
ODAxYTQ2NzY4ODAyM2M1ZmVmMjU5YzlkOGVhZWIyMjUxMWMxZDExYmU4Mjlh
|
11
|
+
NWEyZGM0YWY5ZTQ0NzA3NWY5YTE0MmM5ZDI3NDQ0YzJkZjViNmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2NkYTdkZmVkYmE0ZGVhNWRmMGU5Y2E4NDRlZjA3MDRmYTVmNTQ4MDlmYmUy
|
14
|
+
ZjIyNjU4MWIxNmUxMmE2ZmJhZGVhZGU2ZjkzNjZjYTZhM2FhYzk4NWZmODdi
|
15
|
+
Nzg5Mzk1Yjg0NjIzZGU1NjI2MWFjNGZlMzQ0MTlhY2Y3MjhjNmY=
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
data/bin/mdoc
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
# vi: ft=ruby
|
4
4
|
|
5
|
-
|
5
|
+
$LOAD_PATH.unshift 'lib' # debug only
|
6
6
|
require 'mdoc'
|
7
7
|
|
8
|
-
Mdoc.load_conf_files %w[/etc/mdoc.conf ~/.mdoc.conf]
|
8
|
+
# Mdoc.load_conf_files %w[/etc/mdoc.conf ~/.mdoc.conf]
|
9
9
|
Mdoc.load_cli_options ARGV
|
10
10
|
|
11
11
|
Mdoc.execute!
|
data/lib/mdoc/meta.rb
CHANGED
data/lib/mdoc/pipeline.rb
CHANGED
data/lib/mdoc/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Mdoc
|
2
|
+
# delegate output to pandoc (assume pandoc in path)
|
3
|
+
class PandocWriter < Writer
|
4
|
+
def out(doc)
|
5
|
+
@tmp_file = doc.out_file ? doc.out_file + '.temp__' : ''
|
6
|
+
Mdoc.opts.no_output ? $stdout : File.new(@tmp_file, 'wb')
|
7
|
+
end
|
8
|
+
|
9
|
+
def process!(doc)
|
10
|
+
@tilt = Tilt::ERBTemplate.new(Mdoc.find_tpl_file('pandoc.md'))
|
11
|
+
oh = out(doc)
|
12
|
+
oh.write @tilt.render(doc)
|
13
|
+
unless oh == $stdout
|
14
|
+
oh.close
|
15
|
+
`pandoc -o #{doc.out_file} #{@tmp_file}`
|
16
|
+
File.delete @tmp_file
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_processors
|
21
|
+
%w[smart_code_block
|
22
|
+
expand_link]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/mdoc/writer.rb
CHANGED
data/lib/mdoc.rb
CHANGED
@@ -10,6 +10,7 @@ require 'mdoc/processor/add_toc'
|
|
10
10
|
require 'mdoc/processor/expand_link'
|
11
11
|
require 'mdoc/pipeline'
|
12
12
|
require 'mdoc/writer'
|
13
|
+
require 'mdoc/writer/pandoc_writer'
|
13
14
|
|
14
15
|
# individual processors
|
15
16
|
|
@@ -30,11 +31,12 @@ module Mdoc
|
|
30
31
|
def convert!(fname, doc_type = nil)
|
31
32
|
doc = prepare_doc(fname, doc_type)
|
32
33
|
|
33
|
-
# apply pipeline of processors
|
34
|
-
|
34
|
+
# apply pipeline of processors # TODO: separate writer
|
35
|
+
writer = find_writer(doc)
|
36
|
+
pli = default_pipeline(doc, writer)
|
35
37
|
yield pli if block_given? # receive user supplied processors
|
38
|
+
pli.writer = writer unless pli.writer
|
36
39
|
|
37
|
-
pli.writer = find_writer(doc) unless pli.writer
|
38
40
|
pli.apply!(doc)
|
39
41
|
doc # return doc
|
40
42
|
end
|
@@ -49,7 +51,7 @@ module Mdoc
|
|
49
51
|
doc_type = find_doc_type(fname) unless doc_type
|
50
52
|
doc = doc_type.new(fname)
|
51
53
|
# template
|
52
|
-
doc.tpl_file = find_tpl_file
|
54
|
+
doc.tpl_file = find_tpl_file(opts.template)
|
53
55
|
|
54
56
|
# output file
|
55
57
|
doc.out_file = find_out_file(fname) unless opts.no_output
|
@@ -58,16 +60,16 @@ module Mdoc
|
|
58
60
|
|
59
61
|
# from several directory
|
60
62
|
# rubocop:disable MethodLength
|
61
|
-
def find_tpl_file
|
63
|
+
def find_tpl_file(fname)
|
62
64
|
# add default search directory
|
63
65
|
ipath = File.expand_path(File.dirname(__FILE__) + '/../templates')
|
64
66
|
opts.tpl_directories << ipath unless opts.tpl_directories.include?(ipath)
|
65
67
|
rpath = File.expand_path('./templates')
|
66
68
|
opts.tpl_directories << rpath unless opts.tpl_directories.include?(rpath)
|
67
69
|
|
68
|
-
|
70
|
+
fname = 'default.' + fname unless fname =~ /\./
|
69
71
|
cand, buf = [], nil
|
70
|
-
|
72
|
+
fname.split('.').reverse.each do |b|
|
71
73
|
buf = buf ? b + '.' + buf : b
|
72
74
|
cand.unshift buf
|
73
75
|
end
|
@@ -79,7 +81,7 @@ module Mdoc
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
|
-
raise 'no template file found for ' + opts.template
|
84
|
+
# raise 'no template file found for ' + opts.template
|
83
85
|
nil
|
84
86
|
end
|
85
87
|
# rubocop:enable MethodLength
|
@@ -92,11 +94,9 @@ module Mdoc
|
|
92
94
|
|
93
95
|
# get class from keyword and module under Mdoc name space
|
94
96
|
def get_class(cname, mdl = Processor)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
return nil
|
99
|
-
end
|
97
|
+
mdl.const_get(cname.split(/[\,\_]/).map { |p| p.capitalize }.join)
|
98
|
+
rescue NameError
|
99
|
+
return nil
|
100
100
|
end
|
101
101
|
|
102
102
|
def get_processor(pn)
|
@@ -118,26 +118,23 @@ module Mdoc
|
|
118
118
|
end
|
119
119
|
|
120
120
|
# get a list of processors into a pipline
|
121
|
-
def default_pipeline(doc)
|
122
|
-
pli = Pipeline.new default_processors
|
121
|
+
def default_pipeline(doc, writer)
|
122
|
+
pli = Pipeline.new default_processors(writer)
|
123
123
|
opts.processors.each { |p| pli.append p }
|
124
124
|
opts.no_processors.each { |p| pli.remove p }
|
125
125
|
pli
|
126
126
|
end
|
127
127
|
|
128
|
-
def default_processors
|
129
|
-
|
130
|
-
add_toc
|
131
|
-
add_title
|
132
|
-
smart_code_block
|
133
|
-
expand_link
|
134
|
-
]
|
128
|
+
def default_processors(writer)
|
129
|
+
writer.new.default_processors
|
135
130
|
end
|
136
131
|
|
137
132
|
def find_writer(doc)
|
138
133
|
case opts.template
|
139
134
|
when /pandoc\.\w+$/
|
140
|
-
|
135
|
+
PandocWriter
|
136
|
+
when /(epub|docx)/ # no native support
|
137
|
+
PandocWriter
|
141
138
|
else Writer
|
142
139
|
end
|
143
140
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>The title for our document</title>
|
6
6
|
<!--this style include the test_md/css screen.css(first) and base.css -->
|
7
7
|
<style type="text/css">
|
8
|
-
pre code{display:block;background:#fff;color:#4d4d4c;font-family:Menlo, Monaco, Consolas, monospace;font-size:12px;line-height:1.5;border:1px solid #ccc;padding:10px}html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,code,del,dfn,em,img,q,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}table{border-collapse:separate;border-spacing:0}caption,th,td{text-align:left;font-weight:normal}table,td,th{vertical-align:middle}blockquote:before,blockquote:after,q:before,q:after{content:""}blockquote,q{quotes:"" ""}a img{border:none}body{margin:10px}html{height:100%}body{padding:0;margin:0;font:14px/22px "adelle", Georgia, sans-serif;font-size-adjust:none;font-style:normal;font-variant:normal;font-weight:normal;background:#f4f6ec}a{color:#369}#markdown-toc{float:left;width:230px;margin-right:30px;margin-top:40px}#markdown-toc a{display:block;font-weight:bold;text-decoration:none}#markdown-toc #sections{list-style-type:none;border-bottom:3px solid rgba(0,0,0,0.1);padding-bottom:10px;margin-bottom:10px}#markdown-toc #sections>li>a{padding:5px 0;color:#444;font-size:16px}#markdown-toc #sections ul{margin-bottom:15px}#markdown-toc #sections ul li{list-style-type:none}#markdown-toc #sections ul li a{padding:1px 15px;font-size:13px;font-weight:normal}#markdown-toc .extra{padding:5px 0;min-height:1.4em}#markdown-toc .extra a{color:#555;font-size:14px}#markdown-toc #travis img{margin-top:10px;display:block}#markdown-toc>*:last-child{margin-bottom:20px}#content{padding:30px 30px 20px 30px;min-height:100px;width:600px;background:#fff;float:left;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;margin-top:15px}#content #loader{color:#888;width:300px;height:24px;line-height:24px;position:absolute;top:30px;left:30px;background:url("data:image/gif;base64,R0lGODlhGAAYAPYAAP///5mZmfn5+dvb27i4uKmpqaCgoNra2v39/c/Pz6CgoJmZmfT09K+vr66urvb29qWlpaSkpPPz8/v7+87Ozvj4+NXV1dTU1Li4uKysrJubm52dnaqqqu7u7uPj46Ojo8LCwvb29ra2tqenp7q6utzc3JycnNfX1/Ly8uzs7J6ensbGxs3NzeDg4MvLy9LS0r+/v/r6+qysrOrq6t7e3tnZ2cTExLS0tLOzs6ioqLGxsefn57W1tcvLy7y8vMHBwd7e3qKiovHx8cfHx+Hh4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAFAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAGAAYAAAHmoAAgoOEhYaHgxUWBA4aCxwkJwKIhBMJBguZmpkqLBOUDw2bo5kKEogMEKSkLYgIoqubK5QJsZsNCIgCCraZBiiUA72ZJZQABMMgxgAFvRyfxpixGx3LANKxHtbNth8hy8i9IssHwwsXxgLYsSYpxrXDz5QIDubKlAwR5q2UErC2poxNoLBukwoX0IxVuIAhQ6YRBC5MskaxUCAAIfkEAAUAAQAsAAAAABgAGAAAB6GAAIKDhIWGh4MVFgQOGhsOGAcxiIQTCQYLmZqZGwkIlA8Nm6OaMgyHDBCkqwsjEoUIoqykNxWFCbOkNoYCCrmaJjWHA7+ZHzOIBMUND5QFvzATlACYsy/TgtWsIpPTz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Ah+QQABQAGACwAAAAAGAAYAAAHooAAgoOEhYaHgxUWBA4aCzkkJwKIhBMJBguZmpkqLAiUDw2bo5oyEocMEKSrCxCnhAiirKs3hQmzsy+DAgq4pBogKIMDvpvAwoQExQvHhwW+zYiYrNGU06wNHpSCz746O5TKyzwzhwfLmgQphQLX6D4dhLfomgmwDvQLOoYMEegRyApJkIWLQ0BDEyi426Six4RtgipcwJAhUwQCFypA3IgoEAAh+QQABQAHACwAAAAAGAAYAAAHoYAAgoOEhYaHgxUWBA4aGw4YBzGIhBMJBguZmpkbCQiUDw2bo5oyDIcMEKSrCyMShQiirKQ3FYUJs6Q2hgIKuZomNYcDv5kfM4gExQ0PlAW/MBOUAJizL9OC1awik9PPuTKvlMq/x5QHxQsbNIgC2r8JiLjpCzCfsA70Czi2hQwR9FwdkiAL3ClEEyi829Tp3rQKFzBkWKDBgYgDArBpRBQIADsAAAAAAAAAAAA=") no-repeat center left;padding-left:32px;font-size:18px}#content>p{zoom:1}#content>p:before,#content>p:after{content:"";display:table}#content>p:after{clear:both}#content p{padding:0 0 0.8125em 0;color:#444}#content p img{float:left;margin:0.5em 0.8125em 0.8125em 0;padding:0}#content img{max-width:100%}#content h1,#content h2,#content h3,#content h4,#content h5,#content h6{font-weight:bold;line-height:1.2em}#content h1{font-size:2.125em;margin-bottom:0.4em}#content h2{font-size:1.7em;margin:0.855em 0 0.4em;color:#cc333f}#content h3{font-size:1.3em;margin:0.956em 0 0.4em}#content h4{font-size:1.1em;margin:1.161em 0 0.4em}#content h5,#content h6{font-size:1em;font-weight:bold;margin:1.238em 0 0.4em}#content>h1,#content>h2{margin-top:0}#content ul{list-style-position:outside}#content li ul,#content li ol{margin:0 1.625em}#content ul,#content ol{margin:0 0 1.625em 1.25em}#content dl{margin:0 0 1.625em 0}#content dl dt{font-weight:bold}#content dl dd{margin-left:1.625em}#content a{text-decoration:none}#content a:hover{text-decoration:underline}#content table{margin-bottom:1.625em;border-collapse:collapse}#content th{font-weight:bold}#content tr,#content th,#content td{margin:0;padding:0 1.625em 0 1em;height:26px}#content tfoot{font-style:italic}#content caption{text-align:center;font-family:Georgia, serif}#content abbr,#content acronym{border-bottom:1px dotted #000}#content address{margin-top:1.625em;font-style:italic}#content del{color:#000}#content blockquote{padding:1em 1em 1.625em 1em;font-family:georgia, serif;font-style:italic}#content blockquote:before{content:"\201C";font-size:3em;margin-left:-0.625em;font-family:georgia, serif;color:#aaa;line-height:0}#content blockquote>p{padding:0;margin:0}#content strong{font-weight:bold}#content em,#content dfn{font-style:italic}#content dfn{font-weight:bold}#content pre,#content code{margin:0 0 1.625em;white-space:pre}#content pre,#content code,#content tt{font-size:1em;font-family:Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;line-height:1.5}#content code{background:#f7f8f1;padding:1px 2px;border:1px solid #ccc}#content pre code{padding:10px 12px;word-wrap:normal;overflow-y:auto}#content tt{display:block;margin:1.625em 0}#content hr{margin-bottom:1.625em}#content table{font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;width:100%}#content th,#content td{padding:5px 10px;border:1px solid #ccc}#content th{background:#eee;padding:7px 10px}#content td{font-size:0.9em;border-color:#ddd}#content tbody tr:nth-child(2n){background:#f5f5f5}@media only screen and (max-width: 480px){#container{width:100%}#markdown-toc{width:100%;margin-top:10px;float:none}#markdown-toc #sections,#markdown-toc #header,#markdown-toc .extra{padding-left:30px;padding-right:30px}#content{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;border-width:1px;float:none;margin:0;width:100%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}}@media only screen and (min-device-pixel-ratio: 1.5), only screen and (min-resolution: 1.5dppx){#github-ribbon img{width:100px}}*{margin:0;padding:0}body{margin-left:40px}#markdown-toc{float:right !important;position:fixed;left:745px;height:90%;overflow:auto}#content{float:left !important;filter:progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4);-moz-box-shadow:2px 2px 10px #909090;-webkit-box-shadow:2px 2px 10px #909090;box-shadow:2px 2px 10px #909090}#markdown-toc{width:auto;max-width:300px !important;top:40px}#markdown-toc>li>ul>li>a{color:#cc333f;margin-top:10px}#markdown-toc>li>ul>li>ul>li>a,h3{color:#009999}#markdown-toc>li>ul>li>ul>li>ul>li>a,h4{color:#669999}#markdown-toc>li>a{margin-bottom:20px;padding-bottom:20px;border-bottom:3px solid rgba(0,0,0,0.1);font-size:20px;color:#000000}#content code{border-radius:3px}
|
8
|
+
pre code{display:block;background:#fff;color:#4d4d4c;font-family:Menlo, Monaco, Consolas, monospace;font-size:12px;line-height:1.5;border:1px solid #ccc;padding:10px}html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,code,del,dfn,em,img,q,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}table{border-collapse:separate;border-spacing:0}caption,th,td{text-align:left;font-weight:normal}table,td,th{vertical-align:middle}blockquote:before,blockquote:after,q:before,q:after{content:""}blockquote,q{quotes:"" ""}a img{border:none}body{margin:10px}html{height:100%}body{padding:0;margin:0;font:14px/22px "adelle", Georgia, sans-serif;font-size-adjust:none;font-style:normal;font-variant:normal;font-weight:normal;background:#f4f6ec}a{color:#369}#markdown-toc{float:left;width:230px;margin-right:30px;margin-top:40px}#markdown-toc a{display:block;font-weight:bold;text-decoration:none}#markdown-toc #sections{list-style-type:none;border-bottom:3px solid rgba(0,0,0,0.1);padding-bottom:10px;margin-bottom:10px}#markdown-toc #sections>li>a{padding:5px 0;color:#444;font-size:16px}#markdown-toc #sections ul{margin-bottom:15px}#markdown-toc #sections ul li{list-style-type:none}#markdown-toc #sections ul li a{padding:1px 15px;font-size:13px;font-weight:normal}#markdown-toc .extra{padding:5px 0;min-height:1.4em}#markdown-toc .extra a{color:#555;font-size:14px}#markdown-toc #travis img{margin-top:10px;display:block}#markdown-toc>*:last-child{margin-bottom:20px}#content{padding:30px 30px 20px 30px;min-height:100px;width:600px;background:#fff;float:left;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;margin-top:15px}#content #loader{color:#888;width:300px;height:24px;line-height:24px;position:absolute;top:30px;left:30px;background:url("data:image/gif;base64,R0lGODlhGAAYAPYAAP///5mZmfn5+dvb27i4uKmpqaCgoNra2v39/c/Pz6CgoJmZmfT09K+vr66urvb29qWlpaSkpPPz8/v7+87Ozvj4+NXV1dTU1Li4uKysrJubm52dnaqqqu7u7uPj46Ojo8LCwvb29ra2tqenp7q6utzc3JycnNfX1/Ly8uzs7J6ensbGxs3NzeDg4MvLy9LS0r+/v/r6+qysrOrq6t7e3tnZ2cTExLS0tLOzs6ioqLGxsefn57W1tcvLy7y8vMHBwd7e3qKiovHx8cfHx+Hh4QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAFAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAGAAYAAAHmoAAgoOEhYaHgxUWBA4aCxwkJwKIhBMJBguZmpkqLBOUDw2bo5kKEogMEKSkLYgIoqubK5QJsZsNCIgCCraZBiiUA72ZJZQABMMgxgAFvRyfxpixGx3LANKxHtbNth8hy8i9I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hIWGh4MVFgQOGgscJCcxiIQTCQYLmZqZBiwIlA8Nm6OaGRKHDBCkqwsQp4QIoqyrGZ+DCbOzCYMCCrmsKhWCA7+zJ4IExaM5Qy2TAAXKQT41DIaYrCYiCSmUANisHz9Az4fRxRo8CUKGycqaECtEtgfvpBeCAuD2wbf2mj1gOfgnY0IhBhHeRUBxSIKsXBxeHZpAYd8mFS5seatwAUOGTAVIWBDgraS3QAAh+QQABQAGACwAAAAAGAAYAAAHooAAgoOEhYaHgxUWBA4aCzkkJwKIhBMJBguZmpkqLAiUDw2bo5oyEocMEKSrCxCnhAiirKs3hQmzsy+DAgq4pBogKIMDvpvAwoQExQvHhwW+zYiYrNGU06wNHpSCz746O5TKyzwzhwfLmgQphQLX6D4dhLfomgmwDvQLOoYMEegRyApJkIWLQ0BDEyi426Six4RtgipcwJAhUwQCFypA3IgoEAAh+QQABQAHACwAAAAAGAAYAAAHoYAAgoOEhYaHgxUWBA4aGw4YBzGIhBMJBguZmpkbCQiUDw2bo5oyDIcMEKSrCyMShQiirKQ3FYUJs6Q2hgIKuZomNYcDv5kfM4gExQ0PlAW/MBOUAJizL9OC1awik9PPuTKvlMq/x5QHxQsbNIgC2r8JiLjpCzCfsA70Czi2hQwR9FwdkiAL3ClEEyi829Tp3rQKFzBkWKDBgYgDArBpRBQIADsAAAAAAAAAAAA=") no-repeat center left;padding-left:32px;font-size:18px}#content>p{zoom:1}#content>p:before,#content>p:after{content:"";display:table}#content>p:after{clear:both}#content p{padding:0 0 0.8125em 0;color:#444}#content p img{float:left;margin:0.5em 0.8125em 0.8125em 0;padding:0}#content img{max-width:100%}#content h1,#content h2,#content h3,#content h4,#content h5,#content h6{font-weight:bold;line-height:1.2em}#content h1{font-size:2.125em;margin-bottom:0.4em}#content h2{font-size:1.7em;margin:0.855em 0 0.4em;color:#cc333f}#content h3{font-size:1.3em;margin:0.956em 0 0.4em}#content h4{font-size:1.1em;margin:1.161em 0 0.4em}#content h5,#content h6{font-size:1em;font-weight:bold;margin:1.238em 0 0.4em}#content>h1,#content>h2{margin-top:0}#content ul{list-style-position:outside}#content li ul,#content li ol{margin:0 1.625em}#content ul,#content ol{margin:0 0 1.625em 1.25em}#content dl{margin:0 0 1.625em 0}#content dl dt{font-weight:bold}#content dl dd{margin-left:1.625em}#content a{text-decoration:none}#content a:hover{text-decoration:underline}#content table{margin-bottom:1.625em;border-collapse:collapse}#content th{font-weight:bold}#content tr,#content th,#content td{margin:0;padding:0 1.625em 0 1em;height:26px}#content tfoot{font-style:italic}#content caption{text-align:center;font-family:Georgia, serif}#content abbr,#content acronym{border-bottom:1px dotted #000}#content address{margin-top:1.625em;font-style:italic}#content del{color:#000}#content blockquote{padding:1em 1em 1.625em 1em;font-family:georgia, serif;font-style:italic}#content blockquote:before{content:"\201C";font-size:3em;margin-left:-0.625em;font-family:georgia, serif;color:#aaa;line-height:0}#content blockquote>p{padding:0;margin:0}#content strong{font-weight:bold}#content em,#content dfn{font-style:italic}#content dfn{font-weight:bold}#content pre,#content code{margin:0 0 1.625em;white-space:pre}#content pre,#content code,#content tt{font-size:1em;font-family:Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace;line-height:1.5}#content code{background:#f7f8f1;padding:1px 2px;border:1px solid #ccc}#content pre code{padding:10px 12px;word-wrap:normal;overflow-y:auto}#content tt{display:block;margin:1.625em 0}#content hr{margin-bottom:1.625em}#content table{font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;width:100%}#content th,#content td{padding:5px 10px;border:1px solid #ccc}#content th{background:#eee;padding:7px 10px}#content td{font-size:0.9em;border-color:#ddd}#content tbody tr:nth-child(2n){background:#f5f5f5}@media only screen and (max-width: 480px){#container{width:100%}#markdown-toc{width:100%;margin-top:10px;float:none}#markdown-toc #sections,#markdown-toc #header,#markdown-toc .extra{padding-left:30px;padding-right:30px}#content{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;border-width:1px;float:none;margin:0;width:100%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}}@media only screen and (min-device-pixel-ratio: 1.5), only screen and (min-resolution: 1.5dppx){#github-ribbon img{width:100px}}*{margin:0;padding:0}body{margin-left:40px}#markdown-toc{float:right !important;position:fixed;left:745px;height:90%;overflow:auto}#content{float:left !important;filter:progid:DXImageTransform.Microsoft.Shadow(color=#909090,direction=120,strength=4);-moz-box-shadow:2px 2px 10px #909090;-webkit-box-shadow:2px 2px 10px #909090;box-shadow:2px 2px 10px #909090}#markdown-toc{width:auto;max-width:300px !important;top:40px}#markdown-toc>li>ul>li>a{color:#cc333f;margin-top:10px}#markdown-toc>li>ul>li>ul>li>a,h3{color:#009999}#markdown-toc>li>ul>li>ul>li>ul>li>a,h4{color:#669999}#markdown-toc>li>a{margin-bottom:20px;padding-bottom:20px;border-bottom:3px solid rgba(0,0,0,0.1);font-size:20px;color:#000000}#content code{border-radius:3px}#content>h1{font-size:2.0em}.title{font-size: 2.4em;color: #ff5456 !important}#markdown-toc>li{margin-bottom: 30px}#markdown-toc>li>a{padding-bottom:10px;}#markdown-toc>li>a{font-size: 18px;}#markdown-toc{white-space: nowrap}h1,h2,h3,h4,h5,h6{margin-bottom:1em !important;}#markdown-toc>li>ul>li>ul>li>ul>li>ul>li>a,h5{color:#7bb8b8 !important}#markdown-toc>li>ul>li>ul>li>ul>li>a,h4{color:#6c9e00 !important}#markdown-toc>li>ul>li>ul>li>a, h3{color:#3C6E6E !important}#markdown-toc>li>ul>li>a, h2{color:#4E6EA0 !important}#markdown-toc>li>a, h1{color:#134da5 !important}body{background:#ffffff}.code pre{border:1px solid rgb(204, 204, 204);overflow:auto;border-radius:3px}.code pre{background: none repeat scroll 0% 0% rgb(247, 248, 241)}#content sup{background: #c8deff}#content sup a{color: #273650}#content .footnotes{background: rgba(0,0,0,0.1);padding: 10px 0 0px 10px;border-radius: 5px}.reversefootnote{color: #000000;}
|
9
9
|
</style>
|
10
10
|
</head>
|
11
11
|
|
data/spec/pipeline_spec.rb
CHANGED
@@ -30,9 +30,11 @@ module Mdoc
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
class Writer
|
34
|
-
|
35
|
-
|
33
|
+
class NilWriter < Writer
|
34
|
+
def process!(doc); end
|
35
|
+
|
36
|
+
def default_processors
|
37
|
+
[]
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -42,12 +44,13 @@ describe Mdoc::Pipeline do
|
|
42
44
|
subject(:doc) do
|
43
45
|
Mdoc.convert!('spec/fixtures/multikeys.md') do |pl|
|
44
46
|
pl.insert('proc_wrap')
|
45
|
-
pl.writer = Mdoc::
|
47
|
+
pl.writer = Mdoc::NilWriter
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
51
|
it 'perform 3 processors' do
|
50
|
-
|
52
|
+
ps = Mdoc.default_processors(Mdoc::Writer).size
|
53
|
+
doc.performed.size.should eq(3 + ps)
|
51
54
|
doc.performed[Mdoc::Processor::ProcB].should eq(1)
|
52
55
|
end
|
53
56
|
end
|
@@ -63,7 +66,8 @@ describe Mdoc::Pipeline do
|
|
63
66
|
|
64
67
|
it 'perform 5 processors' do
|
65
68
|
doc.is_a?(Mdoc::Document::Kramdown).should be_true
|
66
|
-
|
69
|
+
ps = Mdoc.default_processors(Mdoc::Writer).size
|
70
|
+
doc.performed.size.should eq(5 + ps)
|
67
71
|
doc.performed[Mdoc::Processor::ProcD].should eq(1)
|
68
72
|
doc.performed[Mdoc::Processor::ProcC].should eq(1)
|
69
73
|
doc.body.should eq('c') # d insert before c
|
@@ -80,7 +84,7 @@ describe Mdoc::Pipeline do
|
|
80
84
|
pl.append('proc_b')
|
81
85
|
pl.insert('proc_d', { after: 'proc_b' })
|
82
86
|
pl.remove(['proc_b'])
|
83
|
-
pl.writer = Mdoc::
|
87
|
+
pl.writer = Mdoc::NilWriter
|
84
88
|
end
|
85
89
|
end
|
86
90
|
|
data/spec/tpl_out_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Mdoc do
|
|
4
4
|
it 'find pandoc.html' do
|
5
5
|
Mdoc.load_defaults
|
6
6
|
Mdoc.load_cli_options %w[-t pandoc.html -d spec/fixtures/templates]
|
7
|
-
tpl = Mdoc.find_tpl_file
|
7
|
+
tpl = Mdoc.find_tpl_file('pandoc.html')
|
8
8
|
tpl.should match(%r|spec/fixtures/templates/pandoc\.html\.erb$|)
|
9
9
|
Mdoc.find_out_file('ff.md').should eq('ff.html')
|
10
10
|
end
|
@@ -12,7 +12,7 @@ describe Mdoc do
|
|
12
12
|
it 'find default.html' do
|
13
13
|
Mdoc.load_defaults
|
14
14
|
Mdoc.load_cli_options %w[-t html -d spec/fixtures/templates]
|
15
|
-
tpl = Mdoc.find_tpl_file
|
15
|
+
tpl = Mdoc.find_tpl_file('html')
|
16
16
|
tpl.should match(%r|spec/fixtures/templates/default\.html\.erb$|)
|
17
17
|
Mdoc.find_out_file('ff.md').should eq('ff.html')
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huang Wei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/mdoc/processor/smart_code_block.rb
|
92
92
|
- lib/mdoc/version.rb
|
93
93
|
- lib/mdoc/writer.rb
|
94
|
+
- lib/mdoc/writer/pandoc_writer.rb
|
94
95
|
- mdoc.gemspec
|
95
96
|
- spec/add_title_spec.rb
|
96
97
|
- spec/add_toc_spec.rb
|
@@ -120,6 +121,7 @@ files:
|
|
120
121
|
- spec/spec_helper.rb
|
121
122
|
- spec/tpl_out_spec.rb
|
122
123
|
- templates/default.html.erb
|
124
|
+
- templates/pandoc.md.erb
|
123
125
|
homepage: https://github.com/7lime/mdoc-gem
|
124
126
|
licenses:
|
125
127
|
- MIT
|