qipowl 0.9.3 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: b1285e55189abe3129f00711fb21fbc905440796
4
- data.tar.gz: 2b46cc8dbd9b675f5293a8ebd3242aee06a2e06b
3
+ metadata.gz: 7f1c631668f2211baa4e0104c6d9c7d474679f8e
4
+ data.tar.gz: 4acc209241f865925f2ad27657943b910b611bb0
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 84bca4876f808702f0c4d8ae4a28ea46a9319fb7319c855c231d3b27ffadebaafecc85f8c94821d9373e6c8d087a526355900ba0d61a1668ad82e8cfd57ed605
7
- data.tar.gz: 045c623b7344d3c84e47beb8240742fb04cabb329007e7f9a14814fec415efe0289381eaa505d7150e144780caf8b518386356f73a38dff112f34d30407256f8
6
+ metadata.gz: 065e805c8794134debf98cb13f7362184902b05616eb2c6a17af4e7df2d77ec4fa153666a8191418fcf54e622549f819668d191a0be6489d2443f506224a317d
7
+ data.tar.gz: 9f821d61819a6c2b7d95004dc48d0a1240ec107be804f46a582aa0275ed386676bd0585ec34d249d8dad15e6b04482984470114f8a57204be4bbfb3ff8544e13
data/Gemfile CHANGED
@@ -4,5 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'aquarium', '~> 0.6', :git => 'git://github.com/deanwampler/Aquarium.git'
7
+ gem 'typogrowth', '~> 0.9', :git => 'git://github.com/mudasobwa/typogrowth.git', :branch => 'master'
7
8
 
8
9
  gem 'rake', :group => :test
data/README.md CHANGED
@@ -16,17 +16,158 @@ _qipowl_ (pronounced as **keep all**)
16
16
 
17
17
  ## Intro
18
18
 
19
- _qipowl_ is the next generation parser environment. It’s not the
20
- library for parsing, rather it is the framework to build extensive
21
- parsers for virtually every markup anyone may imagine.
22
-
23
19
  The main idea of _qipowl_ is to yield the power of
24
20
  [DSL in Ruby](http://jroller.com/rolsen/entry/building_a_dsl_in_ruby).
25
21
  The whole input text is treated neither more nor less than `DSL`.
26
22
  That gives the user an ability to make virtually every term in input text
27
23
  the _operating entity_.
28
24
 
29
- ## Examples
25
+ ## Principles
26
+
27
+ **Qipowl** is a Ruby parsing library. The parsing is done via
28
+ DSL exactly as [Ouroboros](http://en.wikipedia.org/wiki/Ouroboros)
29
+ eats it’s own tail.
30
+
31
+ The whole input is treated as Ruby source code and executed respectively.
32
+ To prevent collisions of input with built-in ruby methods, the ASCII symbols
33
+ in the input are being translated into their
34
+ [fullwidth equivalents](http://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#Chart)
35
+ before execution (and back to ASCII after the parsing is done.)
36
+
37
+ Let’s say we have a string “Hello world” as input. It became ‘encoded’ into:
38
+ “Hello world”, executed as Ruby code (exactly as e. g. `puts rand`
39
+ would) and finally ‘decoded’ back to ASCII. Whether the parser knows anything
40
+ about ‘Hello’ or ‘world’ it would be executed. Say, we have
41
+
42
+ def world *args
43
+ "brave new #{__callee__}"
44
+ end
45
+
46
+ thus the output will be:
47
+
48
+ # ⇒ Hello brave new world
49
+
50
+ More about may be found at [project page](http://rocket-science.ru/qipowl/).
51
+
52
+ ## Applications
53
+
54
+ **Qipowl** has a wide list of applications. The “markright”, descendant
55
+ of “markup” and “markdown” is presented [here](http://qipowl.herokuapp.com).
56
+
57
+ **Qipowl HTML** uses extended unicode symbols
58
+ to specify more clean and readable source files and (boom!) ruby DSL to
59
+ interpret them. E.g. the data definitions look like:
60
+
61
+ ▶ Data term — definition goes here
62
+
63
+ Headings:
64
+
65
+ §1 This is a second-level heading
66
+
67
+ Bold and emphasis:
68
+
69
+ The following ≡text≡ goes strong and this one is ≈emphasized≈.
70
+
71
+ Comments are possible as well:
72
+
73
+ ✍ FIXME!
74
+ Not to forget add this to parsing!
75
+
76
+
77
+ etc.
78
+
79
+ ## Why?
80
+
81
+ Just because it’s 2013 all around. Unicode came already and those fancy
82
+ symbols are easily mapped to the keyboard layouts. The brackets, used
83
+ in old good Markdown are ugly, look at how they might be introduced:
84
+
85
+ I like Markdown¹http://daringfireball.net/projects/markdown/syntax
86
+
87
+ Markdown lacks a lot of modern features (properties of text).
88
+
89
+ Markdown does not provide a blanket set of marks, fully covering
90
+ claims to markup language.
91
+
92
+ ## Parsing
93
+
94
+ Parsing is the most sexy part of **Qipowl** bowels, since it’s done
95
+ almost without any external parsing; input files are the ruby scripts
96
+ themselves. WTF? Let me explain.
97
+
98
+ Let we have an input file of the following structure:
99
+
100
+ §1 Qipowl
101
+
102
+ ✍ FIXME
103
+ include language reference here
104
+
105
+
106
+ ≡Qipowl≡ is the most exciting ruby DSL application example. As it
107
+ is stated in markdown reference:
108
+
109
+ 〉 Readability, however, is emphasized above all else.
110
+ A Markdown-formatted document should be publishable as-is,
111
+ as plain text, without looking like it’s been marked up with
112
+ tags or formatting instructions.
113
+ — http://daringfireball.net/projects/markdown/syntax
114
+
115
+ Now we simply give the source to ruby interpreter, which knowns, that
116
+ `§1` is *in fact* ruby function, which transforms that to any other syntax
117
+ we want. To HTML, for instance.
118
+
119
+ ## Parsing problems
120
+
121
+ Not all the constructions may be passed to ruby script as is. There are
122
+ four exceptions:
123
+
124
+ - **blockquotes**, which are in fact kinda documents inside documents, because
125
+ they might be nested and they may include any other markup;
126
+ - **images**, **videos**, etc. which may be typed as the hyperlink only;
127
+ - **anchors, abbrs etc.**, the elements which are not “symbol-text” formed.
128
+ They rather are looking like “text-symbol-text” and unfortunately should
129
+ be preparsed to supply correct ruby DSL;
130
+ - **lists and data definitions**, are to be surrounded with `<ul>`/`<dd>` tags;
131
+ - **tables**… Bah, I didn’t think most about tables yet. They are ugly.
132
+
133
+ ### Links
134
+
135
+ Links might be:
136
+ - **anchors**
137
+ - Wiki says¹http://wikipedia.org
138
+ - Wiki clone¹/wiki
139
+ - — Wikipedia, http://wikipedia.org
140
+ the latter may be found in quotations only.
141
+ - **images**
142
+ - http://localhost/a.png
143
+ - Best views of Hornsjø¹http://localhost/a.png
144
+ - **videos**
145
+ - http://youtu.be/SAJ_TzLqy1U
146
+ - http://www.youtube.com/watch?v=SAJ_TzLqy1U
147
+
148
+ Abbrs are looking (and processing) mostly like links, but now we may
149
+ forget about them:
150
+ - **abbrs**
151
+ - Wiki†Best online knowledge base ever†
152
+
153
+
154
+ Links are being parsed in the following manner:
155
+
156
+ - find the link in the input, according to simple pattern `URI.regexp`
157
+ - determine whether it is an image, video or link to page by downloading
158
+ and analyzing the headers
159
+ - TODO copying the image to the host computer, providing the watermark
160
+ with copyright and any other significant information
161
+ - TODO instead of previous two actions we might simply analyze it by extension
162
+ e.g. if there is no internet connection available
163
+ - prepending the link with special character (understood by DSL)
164
+
165
+ After all is done, we yield smth like `⚐ http://localhost.a.png` in place of
166
+ `http://localhost.a.png` and `⚓ http://localhost/index.html` in place of
167
+ `http://localhost/index.html`
168
+
169
+
170
+ ### Examples
30
171
 
31
172
  This chapter should be the last one, but who wants to read technical details
32
173
  without any clue of how they might be applied? So, here we go.
@@ -94,11 +235,9 @@ _qipowl_ understands six types of ‘operators’:
94
235
  * flush
95
236
  * block
96
237
  * magnet
97
- * inplace
98
- * linewide
99
- * handshake
100
- * kiss
101
- * custom
238
+ * grip
239
+ * regular
240
+ * self
102
241
 
103
242
  #### :flush
104
243
 
@@ -155,14 +294,14 @@ for the markup:
155
294
 
156
295
  ☎ +1(987)5554321
157
296
 
158
- #### :inplace
297
+ #### :grip
159
298
 
160
299
  Acts mostly like `:block` but inside one text block (text blocks are
161
300
  likely paragraphs, delimited with double carriage returns.) Requires
162
301
  closing element. Inplace operators are of highest priority and may
163
302
  overlap.
164
303
 
165
- :inplace
304
+ :grip
166
305
  :≡ : :strong
167
306
 
168
307
  will convert
@@ -173,12 +312,12 @@ into
173
312
 
174
313
  That is <strong>bold</strong> text.
175
314
 
176
- #### :linewide
315
+ #### :regular
177
316
 
178
317
  Those are not require closings, since they are operated on the _rest_ of
179
318
  the text. Support nesting by prepending tags with _non-breakable space_:
180
319
 
181
- :linewide
320
+ :regular
182
321
  :• : li
183
322
 
184
323
  The following syntax
@@ -195,53 +334,6 @@ will produce:
195
334
  <li>Nested li 2</li></ul>
196
335
  <li>Line item 2</li></ul>
197
336
 
198
- #### :handshake
199
-
200
- **TODO** rewrite examples for latex
201
-
202
- The group contains operators, acting on left and right operands between
203
- the delimiters given. By default it takes the whole line from `^` till `$`.
204
-
205
- :handshake :
206
- :∈ : :mathml
207
- :⊂ :
208
- :tag : :mathml
209
- :from : '\s'
210
- :till : '.'
211
-
212
- The following syntax
213
-
214
- Let we have A ⊂ ∅. Then the following formula is OK:
215
- ∀ a ∈ ∅
216
- which is evident, though.
217
-
218
- will produce:
219
-
220
- Let we have <mathml>A ⊂ ∅</mathml>. Then the following formula is OK:
221
- <mathml>∀ a ∈ ∅</mathml>
222
- which is evident, though.
223
-
224
- #### :kiss
225
-
226
- Almost the same as `:handshake` but operates on the preceeding/following pair of
227
- text piece without spaces. E.g.
228
-
229
- :kiss
230
- :÷ : :mathml
231
-
232
- The following syntax
233
-
234
- The formula 12 ÷ 5 is simple.
235
-
236
- will produce:
237
-
238
- The formula <mathml>12 ÷ 5</mathml> is simple.
239
-
240
- #### :custom
241
-
242
- Custom is not yet fully powerful mechanism to make substitutions inplace
243
- for generic words. Please use on your own risk.
244
-
245
337
  ### Extending
246
338
 
247
339
  Extending _qipowl_ is as easy as writing a couple of strings in YAML format.
@@ -307,7 +399,7 @@ link to video into embedded frame with video content as by YouTube.
307
399
 
308
400
  Add this line to your application's Gemfile:
309
401
 
310
- gem 'typogrowl'
402
+ gem 'qipowl'
311
403
 
312
404
  And then execute:
313
405
 
@@ -315,25 +407,14 @@ And then execute:
315
407
 
316
408
  Or install it yourself as:
317
409
 
318
- $ gem install typogrowl
410
+ $ gem install qipowl
319
411
 
320
412
  ## Usage
321
413
 
322
414
  ```ruby
323
- require 'typogrowl'
324
-
325
- tg = Qipowl::Html.new
326
- puts tg.parse_and_roll(text)
327
- ```
328
-
329
- or even simplier
330
-
331
- ```ruby
332
- require 'typogrowl'
415
+ require 'qipowl'
333
416
 
334
- tg = Qipowl.tg_md__html # typogrowl markup _and_ markdown
335
-
336
- puts tg.parse_and_roll(text)
417
+ result = Qipowl.parse text # qipowl markup _and_ markdown
337
418
  ```
338
419
 
339
420
  ## Contributing
data/bin/bowler CHANGED
@@ -11,7 +11,7 @@ OptionParser.new do |opts|
11
11
  opts.banner = "Usage: #{$0} FILE|STRING"
12
12
 
13
13
  # Bowl result?
14
- opts.on("-a", "--action ACTION", [:bowl, :ruby, :cmd, :yaml, :html],
14
+ opts.on("-a", "--action ACTION", [:bowl, :unbowl, :ruby, :cmd, :yaml, :html],
15
15
  "Action to apply on input (bowl, html); default: html") do |action|
16
16
  options[:action] = action || :bowl
17
17
  end
@@ -31,6 +31,8 @@ file_or_string = File.read(file_or_string) if File.exist?(file_or_string)
31
31
  case options[:action]
32
32
  when :bowl
33
33
  puts file_or_string.bowl
34
+ when :unbowl
35
+ puts file_or_string.unbowl
34
36
  else
35
37
  puts Qipowl::Html.parse file_or_string
36
- end
38
+ end
@@ -11,7 +11,16 @@
11
11
 
12
12
  :entities :
13
13
  :self :
14
- :qipowl : :strong
14
+ :qipowl :
15
+ :tag : :strong
16
+ :format : "<a href='http://\\1.github.com'>\\1</a>"
17
+ :tag :
18
+ :format : :tagger_format
19
+ :tag2 :
20
+ :tag : :b
21
+ :format : :tagger_format
22
+ :synonyms :
23
+ - :tag3
15
24
  :block :
16
25
  :✍ :
17
26
  :synonyms :
@@ -29,8 +38,6 @@
29
38
  :✉ :
30
39
  :tag : :span
31
40
  :class : :email
32
- :synonyms :
33
- - :mail
34
41
  :✎ : :lj
35
42
  :☇ : :a
36
43
  :grip :
@@ -38,11 +45,17 @@
38
45
  :≈ : :em
39
46
  :↑ : :sup
40
47
  :↓ : :small
41
- :λ : :code
48
+ :λ :
49
+ :tag : :code
50
+ :synonyms :
51
+ - :✿_span_fixedfont
42
52
  :⚓ : :a
43
53
  :† : :abbr
44
54
  :✁ : :del
45
55
  :✿_span_nobr : :nobr
56
+ :✓ :
57
+ :tag : :span
58
+ :class : :notypo
46
59
  :regular :
47
60
  :• :
48
61
  :tag : :li
@@ -60,7 +73,7 @@
60
73
  :tag : :dt
61
74
  :parent :
62
75
  :tag : :dl
63
- :class : :dl_horizontal
76
+ :class : :'dl-horizontal'
64
77
  :℁ : :address
65
78
  :〉 :
66
79
  :tag : :p
@@ -84,6 +97,8 @@
84
97
  :☛ :
85
98
  :tag : :p
86
99
  :class : :'text-success'
100
+ :synonyms :
101
+ - :✿_div_center
87
102
  :☞ :
88
103
  :tag : :p
89
104
  :class : :'text-info'
@@ -92,7 +107,7 @@
92
107
  :class : :'text-warning'
93
108
  :☢ :
94
109
  :tag : :p
95
- :class : :text_danger
110
+ :class : :'text-danger'
96
111
  :✇ : :video
97
112
  :⚘ : :figure
98
113
  :✿_p_address :
@@ -117,8 +132,8 @@
117
132
  # http://www.youtube.com/watch?v=SAJ_TzLqy1U
118
133
  'http://www\.youtube\.com/(?:watch\?v=|v/)([A-Za-z0-9_]+)' : '✇ \1'
119
134
  # Standalone images and quotes
120
- '^(https?://\S+)(\s*.*)$' : '⚘ \1 \2'
121
-
135
+ '^(https?://\S+)(\s*.*?)$' : '⚘ \1 \2'
136
+
122
137
  :enclosures :
123
138
  :• :
124
139
  :tag : :ul
@@ -127,6 +142,6 @@
127
142
  :▶ : :dl
128
143
  :▷ :
129
144
  :tag : :dl
130
- :class : :dl_horizontal
145
+ :class : :'dl-horizontal'
131
146
  :〉 : :blockquote
132
147
 
@@ -1,9 +1,38 @@
1
1
  Principles
2
2
  ==========
3
3
 
4
- **Typegrowl** is kinda
5
- [Markdown](http://daringfireball.net/projects/markdown/syntax) successor,
6
- or, if you like, a Markdown². **Typegrowl** uses extended unicode symbols
4
+ **Qipowl** is a Ruby parsing library. The parsing is done via
5
+ DSL exactly as [Ouroboros](http://en.wikipedia.org/wiki/Ouroboros)
6
+ eats it’s own tail.
7
+
8
+ The whole input is treated as Ruby source code and executed respectively.
9
+ To prevent collisions of input with built-in ruby methods, the ASCII symbols
10
+ in the input are being translated into their
11
+ [fullwidth equivalents](http://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#Chart)
12
+ before execution (and back to ASCII after the parsing is done.)
13
+
14
+ Let’s say we have a string “Hello world” as input. It became ‘encoded’ into:
15
+ “Hello world”, executed as Ruby code (exactly as e. g. `puts rand`
16
+ would) and finally ‘decoded’ back to ASCII. Whether the parser knows anything
17
+ about ‘Hello’ or ‘world’ it would be executed. Say, we have
18
+
19
+ def world *args
20
+ "brave new #{__callee__}"
21
+ end
22
+
23
+ thus the output will be:
24
+
25
+ # ⇒ Hello brave new world
26
+
27
+ More about may be found at [project page](http://rocket-science.ru/qipowl/).
28
+
29
+ Applications
30
+ ============
31
+
32
+ **Qipowl** has a wide list of applications. The “markright”, descendant
33
+ of “markup” and “markdown” is presented [here](http://qipowl.herokuapp.com).
34
+
35
+ **Qipowl HTML** uses extended unicode symbols
7
36
  to specify more clean and readable source files and (boom!) ruby DSL to
8
37
  interpret them. E.g. the data definitions look like:
9
38
 
@@ -11,7 +40,7 @@ interpret them. E.g. the data definitions look like:
11
40
 
12
41
  Headings:
13
42
 
14
- §§ This is a second-level heading
43
+ §1 This is a second-level heading
15
44
 
16
45
  Bold and emphasis:
17
46
 
@@ -19,13 +48,12 @@ Bold and emphasis:
19
48
 
20
49
  Comments are possible as well:
21
50
 
22
- FIXME! Not to forget add this to parsing!
51
+ FIXME!
52
+ Not to forget add this to parsing!
53
+
23
54
 
24
55
  etc.
25
56
 
26
- The other goal is to generate more typographically correct output, with
27
- proper quotation marks (“” instead of "" etc.)
28
-
29
57
  Why?
30
58
  ====
31
59
 
@@ -35,37 +63,37 @@ in old good Markdown are ugly, look at how they might be introduced:
35
63
 
36
64
  I like Markdown¹http://daringfireball.net/projects/markdown/syntax
37
65
 
38
- Markdown lacks a lot of modern features (properties of text,) such as:
39
- - tags
40
- - ???
66
+ Markdown lacks a lot of modern features (properties of text).
41
67
 
42
68
  Markdown does not provide a blanket set of marks, fully covering
43
69
  claims to markup language.
44
70
 
45
-
46
71
  Parsing
47
72
  =======
48
73
 
49
- Parsing is the most sexy part of **Typegrowl** bowels, since it’s done
50
- almost without any external parsing; `.tg` files are the ruby scripts
74
+ Parsing is the most sexy part of **Qipowl** bowels, since it’s done
75
+ almost without any external parsing; input files are the ruby scripts
51
76
  themselves. WTF? Let me explain.
52
77
 
53
- Let we have a `.tg` file of the following structure:
78
+ Let we have an input file of the following structure:
54
79
 
55
- § Typegrowl
80
+ §1 Qipowl
56
81
 
57
- include language reference here
58
- ≡Typegrowl≡ is the most exciting ruby DSL application example. As it
82
+ FIXME
83
+ include language reference here
84
+
85
+
86
+ ≡Qipowl≡ is the most exciting ruby DSL application example. As it
59
87
  is stated in markdown reference:
60
88
 
61
- » Readability, however, is emphasized above all else.
62
- » A Markdown-formatted document should be publishable as-is,
63
- » as plain text, without looking like it’s been marked up with
64
- » tags or formatting instructions.
65
- » — http://daringfireball.net/projects/markdown/syntax
89
+  Readability, however, is emphasized above all else.
90
+ A Markdown-formatted document should be publishable as-is,
91
+ as plain text, without looking like it’s been marked up with
92
+ tags or formatting instructions.
93
+ — http://daringfireball.net/projects/markdown/syntax
66
94
 
67
95
  Now we simply give the source to ruby interpreter, which knowns, that
68
- `§` is *in fact* ruby function, which transforms that to any other syntax
96
+ `§1` is *in fact* ruby function, which transforms that to any other syntax
69
97
  we want. To HTML, for instance.
70
98
 
71
99
  ## Parsing problems
@@ -81,7 +109,6 @@ They rather are looking like “text-symbol-text” and unfortunately should
81
109
  be preparsed to supply correct ruby DSL;
82
110
  - **lists and data definitions**, are to be surrounded with `<ul>`/`<dd>` tags;
83
111
  - **tables**… Bah, I didn’t think most about tables yet. They are ugly.
84
-
85
112
 
86
113
  ### Links
87
114
 
@@ -106,8 +133,7 @@ forget about them:
106
133
 
107
134
  Links are being parsed in the following manner:
108
135
 
109
- - find the link in the input, according to simple pattern like
110
- `(?:^|\P{L})(?<proto>[hftps/:]*)(?<path>\S+?)(?:\s|$)`
136
+ - find the link in the input, according to simple pattern `URI.regexp`
111
137
  - determine whether it is an image, video or link to page by downloading
112
138
  and analyzing the headers
113
139
  - TODO copying the image to the host computer, providing the watermark
@@ -120,18 +146,3 @@ After all is done, we yield smth like `⚐ http://localhost.a.png` in place of
120
146
  `http://localhost.a.png` and `⚓ http://localhost/index.html` in place of
121
147
  `http://localhost/index.html`
122
148
 
123
- We will store all the links in some array and substitute them in input
124
- with array index as shown below:
125
-
126
- Wiki¹⚓0 says, that Saint-Petersburg is the most beatuful city in the world:
127
- SPb in the night¹⚐1
128
-
129
- ### Links and abbrs: final normalization
130
-
131
- Now there are no nasty “http://” links without prepending DSL. Nice.
132
- Let’s go further: we don’t like links and abbrs in format
133
-
134
- - `title¹href`
135
- - and `term†explanation`
136
-
137
-