mark_maker 0.0.2 → 0.0.3
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/README.md +71 -6
- data/bin/generate_readme.rb +45 -8
- data/lib/mark_maker/generator.rb +24 -0
- data/lib/mark_maker/version.rb +1 -1
- data/lib/mark_maker.rb +1 -0
- data/test/test_mark_maker.rb +31 -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: 1ec41b346051f4ed6f008e0a86402a5174edcb1c
|
4
|
+
data.tar.gz: 0831f0feeebeaea95093c34096f573f300dbfd0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76a8c2ded0d68a56c51b0ffd4aa766b4bad4c617fcbe52f2e01ff13baab17eed6edc78566ef1e2ceecbef71bf0aaa530dce7f2cff1ae73ab5e422a109e34a7a5
|
7
|
+
data.tar.gz: 727d53292772a0a0ad187480b744965d44117b6e1072136df0b4006f97e76f74c28c9a219ac29844143c429f13ef047a8317170ad6a8e17ea1289c5a12bd24dc
|
data/README.md
CHANGED
@@ -42,17 +42,82 @@ Produces
|
|
42
42
|
|
43
43
|
Produces
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
- gold
|
46
|
+
- silver
|
47
|
+
- bronze
|
48
48
|
|
49
49
|
Or a numbered list with...
|
50
50
|
|
51
51
|
gen.numbers(*list_content)
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
Produces
|
54
|
+
|
55
|
+
1. gold
|
56
|
+
2. silver
|
57
|
+
3. bronze
|
58
|
+
|
59
|
+
### Code Examples
|
60
|
+
|
61
|
+
Standard markdown code blocks and embedding are supported, as well as github
|
62
|
+
flavored markdown fenced code blocks.
|
63
|
+
|
64
|
+
some_code = [ "# add it up",
|
65
|
+
"total = [1, 2, 3, 4].inject do |sum, i|",
|
66
|
+
" sum += i",
|
67
|
+
"end",
|
68
|
+
"",
|
69
|
+
"puts total" ]
|
70
|
+
gen.code_block(*some_code)
|
71
|
+
|
72
|
+
Produces
|
73
|
+
|
74
|
+
# add it up
|
75
|
+
total = [1, 2, 3, 4].inject do |sum, i|
|
76
|
+
sum += i
|
77
|
+
end
|
78
|
+
|
79
|
+
puts total
|
80
|
+
|
81
|
+
You can also generate a github flavored markdown fenced code version.
|
82
|
+
|
83
|
+
gen.fenced_code_block(*some_code)
|
84
|
+
|
85
|
+
Produces
|
86
|
+
|
87
|
+
```
|
88
|
+
# add it up
|
89
|
+
total = [1, 2, 3, 4].inject do |sum, i|
|
90
|
+
sum += i
|
91
|
+
end
|
92
|
+
|
93
|
+
puts total
|
94
|
+
```
|
95
|
+
|
96
|
+
You can also include a language in a fenced code block.
|
97
|
+
|
98
|
+
gen.fenced_code_language('ruby', *some_code)
|
99
|
+
|
100
|
+
Produces
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
# add it up
|
104
|
+
total = [1, 2, 3, 4].inject do |sum, i|
|
105
|
+
sum += i
|
106
|
+
end
|
107
|
+
|
108
|
+
puts total
|
109
|
+
```
|
110
|
+
|
111
|
+
Rendering beautifully highlighted code like so, if you are viewing this on github.
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
# add it up
|
115
|
+
total = [1, 2, 3, 4].inject do |sum, i|
|
116
|
+
sum += i
|
117
|
+
end
|
118
|
+
|
119
|
+
puts total
|
120
|
+
```
|
56
121
|
|
57
122
|
Contributing
|
58
123
|
------------
|
data/bin/generate_readme.rb
CHANGED
@@ -24,13 +24,7 @@ doc << gen.header2("Installation")
|
|
24
24
|
doc << ""
|
25
25
|
doc << "Add this line to your application's Gemfile:"
|
26
26
|
doc << ""
|
27
|
-
|
28
|
-
# ```ruby
|
29
|
-
|
30
27
|
doc << gen.code("gem 'mark_maker'")
|
31
|
-
|
32
|
-
# ```
|
33
|
-
|
34
28
|
doc << ""
|
35
29
|
doc << "And then execute:"
|
36
30
|
doc << ""
|
@@ -60,14 +54,57 @@ doc << ""
|
|
60
54
|
doc << gen.code("list_content = ['gold', 'silver', 'bronze']")
|
61
55
|
doc << gen.code("gen.bullets(*list_content)")
|
62
56
|
doc << "\nProduces\n\n"
|
63
|
-
doc << gen.bullets(*list_content)
|
57
|
+
doc << gen.code_block(*gen.bullets(*list_content))
|
64
58
|
doc << ""
|
65
59
|
doc << "Or a numbered list with..."
|
66
60
|
doc << ""
|
67
61
|
numbered_code = "gen.numbers(*list_content)"
|
68
62
|
doc << gen.code(numbered_code)
|
69
63
|
doc << ""
|
70
|
-
doc <<
|
64
|
+
doc << "Produces"
|
65
|
+
doc << ""
|
66
|
+
doc << gen.code_block(*eval(numbered_code))
|
67
|
+
doc << ""
|
68
|
+
doc << gen.header3("Code Examples")
|
69
|
+
doc << ""
|
70
|
+
doc << "Standard markdown code blocks and embedding are supported, as well as github"
|
71
|
+
doc << "flavored markdown fenced code blocks."
|
72
|
+
doc << ""
|
73
|
+
sample_block = <<-EOT.split("\n")
|
74
|
+
some_code = [ "# add it up",
|
75
|
+
"total = [1, 2, 3, 4].inject do |sum, i|",
|
76
|
+
" sum += i",
|
77
|
+
"end",
|
78
|
+
"",
|
79
|
+
"puts total" ]
|
80
|
+
EOT
|
81
|
+
execution_block = "gen.code_block(*some_code)"
|
82
|
+
doc << gen.code_block(*sample_block, execution_block)
|
83
|
+
doc << ""
|
84
|
+
doc << "Produces\n\n"
|
85
|
+
doc << gen.code_block(*gen.code_block(*eval(sample_block.join)))
|
86
|
+
doc << ""
|
87
|
+
doc << "You can also generate a github flavored markdown fenced code version."
|
88
|
+
fenced_code = "gen.fenced_code_block(*some_code)"
|
89
|
+
doc << ""
|
90
|
+
doc << gen.code(fenced_code)
|
91
|
+
doc << ""
|
92
|
+
doc << "Produces"
|
93
|
+
doc << ""
|
94
|
+
doc << gen.code_block(*eval("#{sample_block.join}\n#{fenced_code}\n"))
|
95
|
+
doc << ""
|
96
|
+
doc << "You can also include a language in a fenced code block."
|
97
|
+
doc << ""
|
98
|
+
fenced_code_language = "gen.fenced_code_language('ruby', *some_code)"
|
99
|
+
doc << gen.code(fenced_code_language)
|
100
|
+
doc << ""
|
101
|
+
doc << "Produces"
|
102
|
+
doc << ""
|
103
|
+
doc << gen.code_block(*eval("#{sample_block.join}\n#{fenced_code_language}"))
|
104
|
+
doc << ""
|
105
|
+
doc << "Rendering beautifully highlighted code like so, if you are viewing this on github."
|
106
|
+
doc << ""
|
107
|
+
doc << eval("#{sample_block.join}\n#{fenced_code_language}")
|
71
108
|
doc << ""
|
72
109
|
doc << gen.header2("Contributing")
|
73
110
|
doc << ""
|
data/lib/mark_maker/generator.rb
CHANGED
@@ -46,5 +46,29 @@ module MarkMaker
|
|
46
46
|
def code(content)
|
47
47
|
" #{content}"
|
48
48
|
end
|
49
|
+
|
50
|
+
def code_block(*content)
|
51
|
+
block = []
|
52
|
+
content.each { |c| block << code(c) }
|
53
|
+
block
|
54
|
+
end
|
55
|
+
|
56
|
+
# creates a github flavored markdown fenced code block
|
57
|
+
def fenced_code_block(*content)
|
58
|
+
block = []
|
59
|
+
block << MarkMaker::FENCE
|
60
|
+
content.each { |c| block << c }
|
61
|
+
block << MarkMaker::FENCE
|
62
|
+
block
|
63
|
+
end
|
64
|
+
|
65
|
+
# creates a github flavored markdown fenced code block that
|
66
|
+
# specifies the language for syntax highlighting purposes
|
67
|
+
def fenced_code_language(lang, *content)
|
68
|
+
block = []
|
69
|
+
block << MarkMaker::FENCE + lang
|
70
|
+
content.each { |c| block << c }
|
71
|
+
block << MarkMaker::FENCE
|
72
|
+
end
|
49
73
|
end
|
50
74
|
end
|
data/lib/mark_maker/version.rb
CHANGED
data/lib/mark_maker.rb
CHANGED
data/test/test_mark_maker.rb
CHANGED
@@ -77,4 +77,35 @@ class TestMarkMaker < Minitest::Test
|
|
77
77
|
markup = gen.code(content)
|
78
78
|
assert_match(/\s{4}var = code\(\)$/, markup)
|
79
79
|
end
|
80
|
+
|
81
|
+
def test_code_block_generation
|
82
|
+
content = ["a = 1", "b = 2", "c = 3"]
|
83
|
+
gen = MarkMaker::Generator.new
|
84
|
+
markup = gen.code_block(*content)
|
85
|
+
assert(markup.length == content.length, "The number of lines of content and markup is not equal.")
|
86
|
+
content.zip(markup).each do |c, m|
|
87
|
+
assert_match(/^\s{4}#{c}$/, m)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_fenced_code_block_generation
|
92
|
+
content = ["a = 1", "b = 2", "c = 3"]
|
93
|
+
gen = MarkMaker::Generator.new
|
94
|
+
markup = gen.fenced_code_block(*content)
|
95
|
+
assert(markup.length == content.length + 2, "Length of markup should equal the content plus the two fences.")
|
96
|
+
assert(markup.slice(1, content.length) == content, "The code body of the markup should match the original content exactly.")
|
97
|
+
assert(markup.first == MarkMaker::FENCE, "Markup should start with the code fence.")
|
98
|
+
assert(markup.last == MarkMaker::FENCE, "Markup should end with the code fence.")
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_fenced_code_language_generation
|
102
|
+
content = ["a = 1", "b = 2", "c = 3"]
|
103
|
+
lang = "ruby"
|
104
|
+
gen = MarkMaker::Generator.new
|
105
|
+
markup = gen.fenced_code_language(lang, *content)
|
106
|
+
assert(markup.length == content.length + 2, "Length of markup should equal the content plus the two fences.")
|
107
|
+
assert(markup.slice(1, content.length) == content, "The code body of the markup should match the original content exactly.")
|
108
|
+
assert(markup.first == MarkMaker::FENCE + lang, "Markup should start with the code fence and the language.")
|
109
|
+
assert(markup.last == MarkMaker::FENCE, "Markup should end with the code fence.")
|
110
|
+
end
|
80
111
|
end
|
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.0.
|
4
|
+
version: 0.0.3
|
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-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|