mark_maker 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +55 -1
- data/bin/generate_readme.rb +52 -1
- data/lib/mark_maker/generator.rb +8 -0
- data/lib/mark_maker/version.rb +1 -1
- data/lib/mark_maker.rb +3 -1
- data/test/test_mark_maker.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6da9b6765231882d2ded111aae9340b1b776a649
|
4
|
+
data.tar.gz: 3af219a0ebd74752af6694b61dc0467b081cbaef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e291fa3de2f051516db8e72157c95236bc2b5892fcffaab4f29c503a103323896aa60bf155596b47c2052d239c12e39131b638d2734fc8b087425c6f16a3748
|
7
|
+
data.tar.gz: 6a3dfc905d93c90da048c84e19edaf9e1d4614f075c78410558588584bc80412ae607bd423bc38a0b7a5362b8d7cbc564db58428bd1703b710bb8887970376a3
|
data/README.md
CHANGED
@@ -3,6 +3,35 @@ MarkMaker
|
|
3
3
|
|
4
4
|
Programatically generate markdown documents.
|
5
5
|
|
6
|
+
Intended Use
|
7
|
+
------------
|
8
|
+
|
9
|
+
The mark_maker gem provides a set of methods that take text content and
|
10
|
+
convert it to various markdown elements. The primary use case is simple
|
11
|
+
conversion of something like a JSON document into a markdown document.
|
12
|
+
|
13
|
+
The initial development goal is to provide
|
14
|
+
support for all of the markdown supported operations, at least in their basic form. What
|
15
|
+
I mean by basic is that you provide a 'chunk' of content and the mark_maker `Generator`
|
16
|
+
will return that content in the corresponding markdown format. For grouped content, variable
|
17
|
+
parameters will be provided on the method call to allow for things like correctly numbered
|
18
|
+
bullet lists. Each call to the generator is treated as a separate
|
19
|
+
markdown operation. So things like link definitions aren't going to be supported,
|
20
|
+
at least not in 1.0
|
21
|
+
|
22
|
+
Speaking of versioning, I'll use semantic versioning to indicate when new markdown
|
23
|
+
capabilities are added. I'll release 1.0 when I feel like it supports set
|
24
|
+
of markdown capabilites that fulfill the intended use. This will also include some
|
25
|
+
extended capabilities from expanded syntaxes like GitHub flavored markdown. Methods
|
26
|
+
generating non-core markdown will be noted in the documentation for that method.
|
27
|
+
|
28
|
+
If all goes well, and it appears anyone is using this gem, then a 2.0 release is
|
29
|
+
envisioned that will add a `Document` class that will provide a
|
30
|
+
more holistic layer of capabilities. For example, the aformentioned reference style
|
31
|
+
links would be nice. As would the ability to have an arbitrarily long string broken
|
32
|
+
down into nicely formatted hard break paragraphs. Same goes for nicely indented multi-line
|
33
|
+
bullets, etc.
|
34
|
+
|
6
35
|
Installation
|
7
36
|
------------
|
8
37
|
|
@@ -59,7 +88,7 @@ Produces
|
|
59
88
|
|
60
89
|
### Code Examples
|
61
90
|
|
62
|
-
Standard markdown code blocks and
|
91
|
+
Standard markdown code blocks and `code span` are supported, as well as github
|
63
92
|
flavored markdown fenced code blocks.
|
64
93
|
|
65
94
|
some_code = [ "# add it up",
|
@@ -148,6 +177,31 @@ Which gives you this stunning HTML table ...
|
|
148
177
|
|Third|C|$1,034.50|
|
149
178
|
|
150
179
|
|
180
|
+
### Block Quotes Example
|
181
|
+
|
182
|
+
```
|
183
|
+
content = <<-QUOTE
|
184
|
+
If you want to quote, you'll get a quote.
|
185
|
+
Warning, it will just quote line by line, not break it up nicely.
|
186
|
+
QUOTE
|
187
|
+
puts gen.block_quote(*content.split("
|
188
|
+
"))
|
189
|
+
```
|
190
|
+
|
191
|
+
Produces the markdown ...
|
192
|
+
|
193
|
+
```
|
194
|
+
> If you want to quote, you'll get a quote.
|
195
|
+
> Warning, it will just quote line by line, not break it up nicely.
|
196
|
+
```
|
197
|
+
|
198
|
+
|
199
|
+
Which looks like this when viewed as HTML...
|
200
|
+
|
201
|
+
> If you want to quote, you'll get a quote.
|
202
|
+
> Warning, it will just quote line by line, not break it up nicely.
|
203
|
+
|
204
|
+
|
151
205
|
Contributing
|
152
206
|
------------
|
153
207
|
|
data/bin/generate_readme.rb
CHANGED
@@ -29,6 +29,34 @@ puts gen.header1("MarkMaker")
|
|
29
29
|
puts ""
|
30
30
|
puts "Programatically generate markdown documents."
|
31
31
|
puts ""
|
32
|
+
puts gen.header2("Intended Use")
|
33
|
+
puts ""
|
34
|
+
puts "The mark_maker gem provides a set of methods that take text content and"
|
35
|
+
puts "convert it to various markdown elements. The primary use case is simple"
|
36
|
+
puts "conversion of something like a JSON document into a markdown document."
|
37
|
+
puts ""
|
38
|
+
puts "The initial development goal is to provide"
|
39
|
+
puts "support for all of the markdown supported operations, at least in their basic form. What"
|
40
|
+
puts "I mean by basic is that you provide a 'chunk' of content and the mark_maker #{ gen.code_span('Generator') }"
|
41
|
+
puts "will return that content in the corresponding markdown format. For grouped content, variable"
|
42
|
+
puts "parameters will be provided on the method call to allow for things like correctly numbered"
|
43
|
+
puts "bullet lists. Each call to the generator is treated as a separate"
|
44
|
+
puts "markdown operation. So things like link definitions aren't going to be supported,"
|
45
|
+
puts "at least not in 1.0"
|
46
|
+
puts ""
|
47
|
+
puts "Speaking of versioning, I'll use semantic versioning to indicate when new markdown"
|
48
|
+
puts "capabilities are added. I'll release 1.0 when I feel like it supports set"
|
49
|
+
puts "of markdown capabilites that fulfill the intended use. This will also include some"
|
50
|
+
puts "extended capabilities from expanded syntaxes like GitHub flavored markdown. Methods"
|
51
|
+
puts "generating non-core markdown will be noted in the documentation for that method."
|
52
|
+
puts ""
|
53
|
+
puts "If all goes well, and it appears anyone is using this gem, then a 2.0 release is"
|
54
|
+
puts "envisioned that will add a #{ gen.code_span('Document') } class that will provide a"
|
55
|
+
puts "more holistic layer of capabilities. For example, the aformentioned reference style"
|
56
|
+
puts "links would be nice. As would the ability to have an arbitrarily long string broken"
|
57
|
+
puts "down into nicely formatted hard break paragraphs. Same goes for nicely indented multi-line"
|
58
|
+
puts "bullets, etc."
|
59
|
+
puts ""
|
32
60
|
puts gen.header2("Installation")
|
33
61
|
puts ""
|
34
62
|
puts "Add this line to your application's Gemfile:"
|
@@ -77,7 +105,7 @@ puts gen.code_block(*eval(numbered_code))
|
|
77
105
|
puts ""
|
78
106
|
puts gen.header3("Code Examples")
|
79
107
|
puts ""
|
80
|
-
puts "Standard markdown code blocks and
|
108
|
+
puts "Standard markdown code blocks and #{gen.code_span('code span')} are supported, as well as github"
|
81
109
|
puts "flavored markdown fenced code blocks."
|
82
110
|
puts ""
|
83
111
|
sample_block = <<-EOT.split("\n")
|
@@ -139,6 +167,29 @@ puts "Which gives you this stunning HTML table ..."
|
|
139
167
|
puts ""
|
140
168
|
puts eval(table_code)
|
141
169
|
puts ""
|
170
|
+
puts gen.header3("Block Quotes Example")
|
171
|
+
puts ""
|
172
|
+
block_quote_code = <<-EOT
|
173
|
+
content = <<-QUOTE
|
174
|
+
If you want to quote, you'll get a quote.
|
175
|
+
Warning, it will just quote line by line, not break it up nicely.
|
176
|
+
QUOTE
|
177
|
+
puts gen.block_quote(*content.split("\n"))
|
178
|
+
EOT
|
179
|
+
puts gen.fenced_code_block(*block_quote_code.split("\n"))
|
180
|
+
puts ""
|
181
|
+
puts "Produces the markdown ..."
|
182
|
+
puts ""
|
183
|
+
block_quote_markdown = capture_stdout do
|
184
|
+
eval(block_quote_code)
|
185
|
+
end
|
186
|
+
puts gen.fenced_code_block(*block_quote_markdown.string.split("\n"))
|
187
|
+
puts ""
|
188
|
+
puts ""
|
189
|
+
puts "Which looks like this when viewed as HTML..."
|
190
|
+
puts ""
|
191
|
+
puts eval(block_quote_code)
|
192
|
+
puts ""
|
142
193
|
puts gen.header2("Contributing")
|
143
194
|
puts ""
|
144
195
|
puts gen.numbers(gen.link("Fork it", "https://github.com/sn1de/mark_maker/fork"),
|
data/lib/mark_maker/generator.rb
CHANGED
@@ -43,6 +43,10 @@ module MarkMaker
|
|
43
43
|
" #{content}"
|
44
44
|
end
|
45
45
|
|
46
|
+
def code_span(content)
|
47
|
+
"#{CODE_TIC}#{content}#{CODE_TIC}"
|
48
|
+
end
|
49
|
+
|
46
50
|
def code_block(*content)
|
47
51
|
content.map { |c| code(c) }
|
48
52
|
end
|
@@ -80,5 +84,9 @@ module MarkMaker
|
|
80
84
|
def table_row(*content)
|
81
85
|
content.inject("|") { |a, e| a << e << "|" }
|
82
86
|
end
|
87
|
+
|
88
|
+
def block_quote(*content)
|
89
|
+
content.map { |c| "#{BLOCK_QUOTE} #{c}"}
|
90
|
+
end
|
83
91
|
end
|
84
92
|
end
|
data/lib/mark_maker/version.rb
CHANGED
data/lib/mark_maker.rb
CHANGED
data/test/test_mark_maker.rb
CHANGED
@@ -78,6 +78,12 @@ class TestMarkMaker < Minitest::Test
|
|
78
78
|
assert_match(/\s{4}var = code\(\)$/, markup)
|
79
79
|
end
|
80
80
|
|
81
|
+
def test_code_span_generation
|
82
|
+
gen = MarkMaker::Generator.new
|
83
|
+
markup = "Some #{gen.code_span('a = b + c')} here."
|
84
|
+
assert_match(/^Some #{MarkMaker::CODE_TIC}a = b \+ c#{MarkMaker::CODE_TIC} here.$/, markup)
|
85
|
+
end
|
86
|
+
|
81
87
|
def test_code_block_generation
|
82
88
|
content = ["a = 1", "b = 2", "c = 3"]
|
83
89
|
gen = MarkMaker::Generator.new
|
@@ -137,5 +143,14 @@ class TestMarkMaker < Minitest::Test
|
|
137
143
|
row = gen.table_row(*content)
|
138
144
|
assert_match(/^\|#{Regexp.quote(content[0])}\|#{Regexp.quote(content[1])}\|#{Regexp.quote(content[2])}\|$/, row)
|
139
145
|
end
|
146
|
+
|
147
|
+
def test_block_quote_generation
|
148
|
+
content = ["Line 1", "Line 2", "Line 3"]
|
149
|
+
gen = MarkMaker::Generator.new
|
150
|
+
markup = gen.block_quote(*content)
|
151
|
+
content.zip(markup).each do |c, m|
|
152
|
+
assert_match(/^> #{Regexp.quote(c)}$/, m)
|
153
|
+
end
|
154
|
+
end
|
140
155
|
end
|
141
156
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mark_maker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Schneider
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|