qipowl 0.9.0
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 +7 -0
- data/.document +11 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/.yardopts +3 -0
- data/Gemfile +17 -0
- data/LICENSE +20 -0
- data/README.md +345 -0
- data/Rakefile +21 -0
- data/bin/bowler +44 -0
- data/config/bowlers/cmd.yaml +3 -0
- data/config/bowlers/html.yaml +128 -0
- data/config/bowlers/html_supplemental.yaml +3 -0
- data/config/bowlers/markdown2html.yaml +23 -0
- data/extras/demo/main.rb +34 -0
- data/extras/demo/public/apple-touch-icon-114x114-precomposed.png +0 -0
- data/extras/demo/public/apple-touch-icon-144x144-precomposed.png +0 -0
- data/extras/demo/public/apple-touch-icon-57x57-precomposed.png +0 -0
- data/extras/demo/public/apple-touch-icon-72x72-precomposed.png +0 -0
- data/extras/demo/public/apple-touch-icon-precomposed.png +0 -0
- data/extras/demo/public/apple-touch-icon.png +0 -0
- data/extras/demo/public/css/bootstrap-theme.css +384 -0
- data/extras/demo/public/css/bootstrap-theme.min.css +1 -0
- data/extras/demo/public/css/bootstrap.css +6805 -0
- data/extras/demo/public/css/bootstrap.min.css +9 -0
- data/extras/demo/public/css/main.css +22 -0
- data/extras/demo/public/favicon.ico +0 -0
- data/extras/demo/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/extras/demo/public/fonts/glyphicons-halflings-regular.svg +228 -0
- data/extras/demo/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/extras/demo/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/extras/demo/public/html.html +262 -0
- data/extras/demo/public/index.html +110 -0
- data/extras/demo/public/js/main.js +1 -0
- data/extras/demo/public/js/vendor/bootstrap.js +1999 -0
- data/extras/demo/public/js/vendor/bootstrap.min.js +6 -0
- data/extras/demo/public/js/vendor/jquery-1.10.1.min.js +6 -0
- data/extras/demo/public/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +11 -0
- data/extras/drafts/parsing.md +137 -0
- data/extras/support/typo +66 -0
- data/features/bowler.feature +8 -0
- data/features/html.feature +229 -0
- data/features/step_definitions/bowler_steps.rb +39 -0
- data/features/step_definitions/html_steps.rb +11 -0
- data/features/support/env.rb +7 -0
- data/images/owl-old.png +0 -0
- data/images/owl-old.xcf +0 -0
- data/images/owl.png +0 -0
- data/images/owl.xcf +0 -0
- data/lib/qipowl/bowlers/cmd.rb +26 -0
- data/lib/qipowl/bowlers/html.rb +409 -0
- data/lib/qipowl/bowlers/htmldoc.rb +268 -0
- data/lib/qipowl/bowlers/yaml.rb +63 -0
- data/lib/qipowl/core/bowler.rb +251 -0
- data/lib/qipowl/core/mapper.rb +92 -0
- data/lib/qipowl/core/monkeypatches.rb +168 -0
- data/lib/qipowl/core/ruler.rb +106 -0
- data/lib/qipowl/utils/hash_recursive_merge.rb +72 -0
- data/lib/qipowl/utils/logging.rb +14 -0
- data/lib/qipowl/version.rb +3 -0
- data/lib/qipowl.rb +50 -0
- data/qipowl.gemspec +42 -0
- data/qipowl.komodoproject +4 -0
- data/spec/bowler_spec.rb +11 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/string_spec.rb +32 -0
- data/spec/yaml_test.yaml +10 -0
- metadata +254 -0
@@ -0,0 +1,229 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Feature: All the possibilities of HTML parser
|
4
|
+
|
5
|
+
Scenario Outline: Inplace tags
|
6
|
+
Given we use "html" bowler
|
7
|
+
When the input string is <input>
|
8
|
+
And the execute method is called on bowler
|
9
|
+
Then the result should equal to <output>
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
| input | output |
|
13
|
+
| "here ≈italic≈ goes" | "<p>here <em>italic</em> goes</p>" |
|
14
|
+
| "here ≡bold≡ goes" | "<p>here <strong>bold</strong> goes</p>" |
|
15
|
+
| "here ↓small↓ goes" | "<p>here <small>small</small> goes</p>" |
|
16
|
+
| "here ↑sup↑ goes" | "<p>here <sup>sup</sup> goes</p>" |
|
17
|
+
| "here abbr†desc ription† goes" | "<p>here <abbr title='desc ription'>abbr</abbr> goes</p>" |
|
18
|
+
| "here ✁del✁ goes" | "<p>here <del>del</del> goes</p>" |
|
19
|
+
| "here ✿_span_nobrnobr✿_span_nobr goes" | "<p>here <nobr>nobr</nobr> goes</p>" |
|
20
|
+
| "here ÷deleted÷ goes" | "<p>here <del>deleted</del> goes</p>" |
|
21
|
+
| "here λcodeλ goes" | "<p>here <code>code</code> goes</p>" |
|
22
|
+
| "here ≡λbold codeλ≡ goes" | "<p>here <strong><code>bold code</code></strong> goes</p>" |
|
23
|
+
| "here λ≡code bold≡λ goes" | "<p>here <code><strong>code bold</strong></code> goes</p>" |
|
24
|
+
| "Hello, ≈World≈!" | "<p>Hello, <em>World</em>!</p>" |
|
25
|
+
|
26
|
+
|
27
|
+
Scenario Outline: Alone tags
|
28
|
+
Given we use "html" bowler
|
29
|
+
When the input string is <input>
|
30
|
+
And the execute method is called on bowler
|
31
|
+
Then the result should equal to <output>
|
32
|
+
|
33
|
+
Examples:
|
34
|
+
| input | output |
|
35
|
+
| "A ⏎ B" | "<p>A <br/> B</p>" |
|
36
|
+
| "A —— B" | "<p>A</p> <hr/> <p>B</p>" |
|
37
|
+
|
38
|
+
Scenario: Block tag Λ
|
39
|
+
Given we use "html" bowler
|
40
|
+
When the input string is "Λ ruby @mapping[:block] = ≡bold≡ Λ"
|
41
|
+
And the execute method is called on bowler
|
42
|
+
Then the result should equal to
|
43
|
+
"""
|
44
|
+
|
45
|
+
<pre class='ruby'>@mapping[:block] = ≡bold≡ </pre>
|
46
|
+
"""
|
47
|
+
|
48
|
+
Scenario: Block tag ✍
|
49
|
+
Given we use "html" bowler
|
50
|
+
When the input string is
|
51
|
+
"""
|
52
|
+
✍
|
53
|
+
ruby @mapping[:block] = ≡bold≡
|
54
|
+
✍
|
55
|
+
"""
|
56
|
+
And the execute method is called on bowler
|
57
|
+
Then the result should equal to
|
58
|
+
"""
|
59
|
+
|
60
|
+
|
61
|
+
"""
|
62
|
+
|
63
|
+
Scenario Outline: Video tags
|
64
|
+
Given we use "html" bowler
|
65
|
+
When the input string is <input>
|
66
|
+
And the execute method is called on bowler
|
67
|
+
Then the result should match "<iframe class='youtube' width='560' height='315' src='http://www.youtube.com/embed/gokeLEC8dZc'"
|
68
|
+
|
69
|
+
Examples:
|
70
|
+
| input |
|
71
|
+
| "http://www.youtube.com/watch?v=gokeLEC8dZc" |
|
72
|
+
| "http://youtu.be/gokeLEC8dZc" |
|
73
|
+
| "YouTube http://youtu.be/gokeLEC8dZc inline test." |
|
74
|
+
|
75
|
+
Scenario Outline: Magnet tags
|
76
|
+
Given we use "html" bowler
|
77
|
+
When the input string is <input>
|
78
|
+
And the execute method is called on bowler
|
79
|
+
Then the result should equal to <output>
|
80
|
+
|
81
|
+
Examples:
|
82
|
+
| input | output |
|
83
|
+
| "☎ +1(987)5554321" | "<p><span class='phone'>☎ +1(987)5554321</span></p>" |
|
84
|
+
| "✉ info_twitter.com" | "<p><span class='email'>✉ info_twitter.com</span></p>" |
|
85
|
+
| "✎ mudasobwa" | "<p><span style='white-space: nowrap;'><a href='http://mudasobwa.livejournal.com/profile?mode=full'><img src='http://l-stat.livejournal.com/img/userinfo.gif' alt='[info]' style='border: 0pt none ; vertical-align: bottom; padding-right: 1px;' height='17' width='17'></a><a href='http://mudasobwa.livejournal.com/?style=mine'><b>mudasobwa</b></a></span></p>" |
|
86
|
+
| "☇ id001" | "<p><a name='id001'></a></p>" |
|
87
|
+
|
88
|
+
Scenario Outline: Custom tags
|
89
|
+
Given we use "html" bowler
|
90
|
+
When the input string is <input>
|
91
|
+
And the execute method is called on bowler
|
92
|
+
Then the result should equal to <output>
|
93
|
+
|
94
|
+
Examples:
|
95
|
+
| input | output |
|
96
|
+
| "‒ Wikipedia, http://wikipedia.org" | "<p><br/> <small><a href='http://wikipedia.org'>Wikipedia</a></small></p>" |
|
97
|
+
| "Wikipedia¹http://wikipedia.org" | "<p><a href='http://wikipedia.org'>Wikipedia</a></p>" |
|
98
|
+
| "Wikipedia†Best knowledge base†" | "<p><abbr title='Best knowledge base'>Wikipedia</abbr></p>" |
|
99
|
+
| "Inplace picture¹http://mudasobwa.ru/images/am.jpg goes here." | "<p><img class='inplace' alt='Inplace picture' src='http://mudasobwa.ru/images/am.jpg'/> goes here.</p>" |
|
100
|
+
| "http://mudasobwa.ru/images/am.jpg Standalone picture" | " ␍ <figure> ␍ <img src='http://mudasobwa.ru/images/am.jpg'/> ␍ <figcaption> ␍ <p> ␍ Standalone picture ␍ </p> ␍ </figcaption> ␍ </figure> ␍ " |
|
101
|
+
|
102
|
+
Scenario Outline: Markdown atavisms ⇒ links
|
103
|
+
Given we use "html" bowler
|
104
|
+
When the input string is <input>
|
105
|
+
And the execute method is called on bowler
|
106
|
+
Then the result should equal to <output>
|
107
|
+
|
108
|
+
Examples:
|
109
|
+
| input | output |
|
110
|
+
| "Here  goes" | "<p>Here <img class='inplace' alt='Image' src='http://mudasobwa.ru/images/am.jpg'/> goes</p>" |
|
111
|
+
| "" | " ␍ <figure> ␍ <img src='http://mudasobwa.ru/images/am.jpg'/> ␍ <figcaption> ␍ <p> ␍ Figure ␍ </p> ␍ </figcaption> ␍ </figure> ␍ " |
|
112
|
+
| "Here [Link](http://wikipedia.org/) goes" | "<p>Here <a href='http://wikipedia.org/'>Link</a> goes</p>" |
|
113
|
+
| "Here *italic* goes" | "<p>Here <em>italic</em> goes</p>" |
|
114
|
+
| "Here inplace*it*alic goes" | "<p>Here inplace<em>it</em>alic goes</p>" |
|
115
|
+
| "Here non-italic 5*3 math goes" | "<p>Here non-italic 5*3 math goes</p>" |
|
116
|
+
| "Here **bold** goes" | "<p>Here <strong>bold</strong> goes</p>" |
|
117
|
+
| "Here ~~del~~ goes" | "<p>Here <del>del</del> goes</p>" |
|
118
|
+
| "Here `code` goes" | "<p>Here <code>code</code> goes</p>" |
|
119
|
+
|
120
|
+
|
121
|
+
Scenario Outline: Regular tags
|
122
|
+
Given we use "html" bowler
|
123
|
+
When the input string is <input>
|
124
|
+
And the execute method is called on bowler
|
125
|
+
Then the result should equal to <output>
|
126
|
+
|
127
|
+
Examples:
|
128
|
+
| input | output |
|
129
|
+
| "List: • li1 • li2" | "<p>List:</p> <ul class='fancy'><li>li1 </li> <li>li2</li></ul>" |
|
130
|
+
| "List: • li1 • nested 1 • nested 2 • li2" | "<p>List:</p> <ul class='fancy'><li>li1 </li> <ul class='fancy'><li>nested 1 </li> <li>nested 2 </li></ul> <li>li2</li></ul>" |
|
131
|
+
| "Data: ▶ dt — dd ▶ dt — dd" | "<p>Data:</p> <dl> ␍ <dt>dt</dt> ␍ <dd>dd </dd> ␍ ␍ <dt>dt</dt> ␍ <dd>dd</dd> ␍ </dl>" |
|
132
|
+
| "§1 Header" | "<h1>Header</h1>" |
|
133
|
+
| "〉 Blockquote" | "<blockquote><p class='blockquote'>Blockquote</p></blockquote>" |
|
134
|
+
|
135
|
+
Scenario: Address tag
|
136
|
+
Given we use "html" bowler
|
137
|
+
When the input string is "℁ ≡Twitter≡ ⏎ ☎ +1(987)5554321 ⏎ ✉ info@twitter.com"
|
138
|
+
And the execute method is called on bowler
|
139
|
+
Then the result should equal to "<address><strong>Twitter</strong> <br/> <span class='phone'>☎ +1(987)5554321</span> <br/> <span class='email'>✉ info@twitter.com</span></address>"
|
140
|
+
|
141
|
+
Scenario: Entity addition
|
142
|
+
Given we use "html" bowler
|
143
|
+
When the input string is "List: × li1 line item × li2"
|
144
|
+
And rule "×" is added to mapping as "li" in "regular" section with "ol" enclosure
|
145
|
+
And the execute method is called on bowler
|
146
|
+
Then the result should equal to "<p>List:</p> <ol><li>li1 line item </li> <li>li2</li></ol>"
|
147
|
+
|
148
|
+
Scenario: Entity removal
|
149
|
+
Given we use "html" bowler
|
150
|
+
When the input string is "List: ◦ li1 ◦ li2"
|
151
|
+
And rule "◦" is removed from mapping
|
152
|
+
And the execute method is called on bowler
|
153
|
+
Then the result should equal to "<p>List: ◦ li1 ◦ li2</p>"
|
154
|
+
|
155
|
+
Scenario: Standalone images
|
156
|
+
Given we use "html" bowler
|
157
|
+
When the input string is
|
158
|
+
"""
|
159
|
+
✍
|
160
|
+
Preamble: given
|
161
|
+
✍
|
162
|
+
|
163
|
+
〉 http://mudasobwa.ru/i/self.jpg With caption
|
164
|
+
‒ Wiki, http://wikipedia.ru
|
165
|
+
|
166
|
+
Nice?
|
167
|
+
"""
|
168
|
+
And the execute method is called on bowler
|
169
|
+
Then the result should equal to
|
170
|
+
"""
|
171
|
+
|
172
|
+
|
173
|
+
<blockquote><p class='blockquote'>http://mudasobwa.ru/i/self.jpg With caption
|
174
|
+
<br/> <small><a href='http://wikipedia.ru'>Wiki</a></small> </p></blockquote>
|
175
|
+
<p>Nice?</p>
|
176
|
+
"""
|
177
|
+
|
178
|
+
Scenario: Comments
|
179
|
+
Given we use "html" bowler
|
180
|
+
When the input string is
|
181
|
+
"""
|
182
|
+
---
|
183
|
+
This is a comment text
|
184
|
+
---
|
185
|
+
|
186
|
+
Nice?
|
187
|
+
"""
|
188
|
+
And the execute method is called on bowler
|
189
|
+
Then the result should equal to
|
190
|
+
"""
|
191
|
+
|
192
|
+
|
193
|
+
<p>Nice?</p>
|
194
|
+
"""
|
195
|
+
|
196
|
+
Scenario: Blockquotes
|
197
|
+
Given we use "html" bowler
|
198
|
+
When the input string is
|
199
|
+
"""
|
200
|
+
§2 Blockquotes
|
201
|
+
|
202
|
+
〉 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere
|
203
|
+
erat a ante.
|
204
|
+
〉 Nested blockquote first line
|
205
|
+
〉 Nested blockquote second line
|
206
|
+
〉 Lorem ipsum para text 2.
|
207
|
+
|
208
|
+
Some para text.
|
209
|
+
|
210
|
+
〉 Intro 1.
|
211
|
+
• list item ≡with bold≡ 1
|
212
|
+
• list item ≈emphasized≈
|
213
|
+
• nested list item 1
|
214
|
+
• nested list item 2
|
215
|
+
|
216
|
+
〉 Blockquote standalone.
|
217
|
+
|
218
|
+
〉 Intro 2.
|
219
|
+
• list item 2.1
|
220
|
+
• list item 2.2
|
221
|
+
〉 Continuing intro 2.
|
222
|
+
|
223
|
+
Blockquote standalone.
|
224
|
+
"""
|
225
|
+
And the execute method is called on bowler
|
226
|
+
Then the result should match "<blockquote><blockquote><blockquote><p class='blockquote'>Nested blockquote first"
|
227
|
+
And the result should match "</li> <ul class='fancy'><li>nested list item 1"
|
228
|
+
And the result should match "<p>Blockquote standalone.</p>"
|
229
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Given(/^we use "(.*?)" bowler$/) do |f|
|
2
|
+
# @f = "config/bowlers/#{f}.yaml"
|
3
|
+
@bowler = Qipowl::Ruler.new_bowler f
|
4
|
+
end
|
5
|
+
|
6
|
+
When(/^the input string is "(.*?)"$/) do |input|
|
7
|
+
@input = input
|
8
|
+
end
|
9
|
+
|
10
|
+
When(/^the input string is$/) do |input|
|
11
|
+
@input = input
|
12
|
+
end
|
13
|
+
|
14
|
+
When(/^the execute method is called on bowler$/) do
|
15
|
+
@result = @bowler.execute @input
|
16
|
+
end
|
17
|
+
|
18
|
+
When(/^rule "(.*?)" is added to mapping as "(.*?)" in "(.*?)" section with "(.*?)" enclosure$/) do |key, val, section, encl|
|
19
|
+
@bowler.add_entity section, key, val, encl
|
20
|
+
end
|
21
|
+
|
22
|
+
When(/^rule "(.*?)" is removed from mapping$/) do |key|
|
23
|
+
@bowler.remove_entity key
|
24
|
+
end
|
25
|
+
|
26
|
+
Then(/^bowler has all the method aliases$/) do
|
27
|
+
puts @bowler.class.instance_methods(false)
|
28
|
+
puts '='*60
|
29
|
+
@bowler.class.constants(false).each { |c|
|
30
|
+
puts "Constant: #{c}"
|
31
|
+
puts @bowler.class.const_get(c)
|
32
|
+
puts '-'*60
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
Then(/^the output is "(.*?)"$/) do |result|
|
37
|
+
expect(@result).to eq(result)
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Then(/^the result should equal to "(.*?)"$/) do |result|
|
2
|
+
expect(@result.carriage).to eq(result)
|
3
|
+
end
|
4
|
+
|
5
|
+
Then(/^the result should equal to$/) do |result|
|
6
|
+
expect(@result).to eq(result)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/^the result should match "(.*?)"$/) do |result|
|
10
|
+
expect(@result).to match(result)
|
11
|
+
end
|
data/images/owl-old.png
ADDED
Binary file
|
data/images/owl-old.xcf
ADDED
Binary file
|
data/images/owl.png
ADDED
Binary file
|
data/images/owl.xcf
ADDED
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require_relative '../core/bowler'
|
4
|
+
|
5
|
+
module Qipowl::Bowlers
|
6
|
+
|
7
|
+
# Markup processor for Html output.
|
8
|
+
#
|
9
|
+
# This class produces HTML from markup as Markdown does.
|
10
|
+
class Cmd < Bowler
|
11
|
+
def initialize file = nil
|
12
|
+
super
|
13
|
+
merge_rules file if file
|
14
|
+
end
|
15
|
+
|
16
|
+
def список_файлов *args
|
17
|
+
puts `#{@mapping.linewide(__callee__)} #{args.join(SEPARATOR).unbowl}`
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.execute str
|
21
|
+
Cmd.new.parse_and_roll str
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|