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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.document +11 -0
  3. data/.gitignore +17 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +3 -0
  6. data/.yardopts +3 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE +20 -0
  9. data/README.md +345 -0
  10. data/Rakefile +21 -0
  11. data/bin/bowler +44 -0
  12. data/config/bowlers/cmd.yaml +3 -0
  13. data/config/bowlers/html.yaml +128 -0
  14. data/config/bowlers/html_supplemental.yaml +3 -0
  15. data/config/bowlers/markdown2html.yaml +23 -0
  16. data/extras/demo/main.rb +34 -0
  17. data/extras/demo/public/apple-touch-icon-114x114-precomposed.png +0 -0
  18. data/extras/demo/public/apple-touch-icon-144x144-precomposed.png +0 -0
  19. data/extras/demo/public/apple-touch-icon-57x57-precomposed.png +0 -0
  20. data/extras/demo/public/apple-touch-icon-72x72-precomposed.png +0 -0
  21. data/extras/demo/public/apple-touch-icon-precomposed.png +0 -0
  22. data/extras/demo/public/apple-touch-icon.png +0 -0
  23. data/extras/demo/public/css/bootstrap-theme.css +384 -0
  24. data/extras/demo/public/css/bootstrap-theme.min.css +1 -0
  25. data/extras/demo/public/css/bootstrap.css +6805 -0
  26. data/extras/demo/public/css/bootstrap.min.css +9 -0
  27. data/extras/demo/public/css/main.css +22 -0
  28. data/extras/demo/public/favicon.ico +0 -0
  29. data/extras/demo/public/fonts/glyphicons-halflings-regular.eot +0 -0
  30. data/extras/demo/public/fonts/glyphicons-halflings-regular.svg +228 -0
  31. data/extras/demo/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  32. data/extras/demo/public/fonts/glyphicons-halflings-regular.woff +0 -0
  33. data/extras/demo/public/html.html +262 -0
  34. data/extras/demo/public/index.html +110 -0
  35. data/extras/demo/public/js/main.js +1 -0
  36. data/extras/demo/public/js/vendor/bootstrap.js +1999 -0
  37. data/extras/demo/public/js/vendor/bootstrap.min.js +6 -0
  38. data/extras/demo/public/js/vendor/jquery-1.10.1.min.js +6 -0
  39. data/extras/demo/public/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +11 -0
  40. data/extras/drafts/parsing.md +137 -0
  41. data/extras/support/typo +66 -0
  42. data/features/bowler.feature +8 -0
  43. data/features/html.feature +229 -0
  44. data/features/step_definitions/bowler_steps.rb +39 -0
  45. data/features/step_definitions/html_steps.rb +11 -0
  46. data/features/support/env.rb +7 -0
  47. data/images/owl-old.png +0 -0
  48. data/images/owl-old.xcf +0 -0
  49. data/images/owl.png +0 -0
  50. data/images/owl.xcf +0 -0
  51. data/lib/qipowl/bowlers/cmd.rb +26 -0
  52. data/lib/qipowl/bowlers/html.rb +409 -0
  53. data/lib/qipowl/bowlers/htmldoc.rb +268 -0
  54. data/lib/qipowl/bowlers/yaml.rb +63 -0
  55. data/lib/qipowl/core/bowler.rb +251 -0
  56. data/lib/qipowl/core/mapper.rb +92 -0
  57. data/lib/qipowl/core/monkeypatches.rb +168 -0
  58. data/lib/qipowl/core/ruler.rb +106 -0
  59. data/lib/qipowl/utils/hash_recursive_merge.rb +72 -0
  60. data/lib/qipowl/utils/logging.rb +14 -0
  61. data/lib/qipowl/version.rb +3 -0
  62. data/lib/qipowl.rb +50 -0
  63. data/qipowl.gemspec +42 -0
  64. data/qipowl.komodoproject +4 -0
  65. data/spec/bowler_spec.rb +11 -0
  66. data/spec/spec_helper.rb +15 -0
  67. data/spec/string_spec.rb +32 -0
  68. data/spec/yaml_test.yaml +10 -0
  69. metadata +254 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 11832e5a92068dd4a814b706480c20aae99c3a30
4
+ data.tar.gz: 01dc0566c1f58d83664dff49c923dc68d5b58eeb
5
+ !binary "U0hBNTEy":
6
+ metadata.gz: f4ee26556053853856c043979387e2fedd29901d0b199902bbff5bbd9ce0b37bfe5f5c3e819d77643655c811d8b2df42c2318ae4f7b4f536aea7e8452c39cefd
7
+ data.tar.gz: eeac33cd357ad9c0c5ebf3785c4ecb4a98289ac5498c3291b1c19029ed3ab431d7a7befdd03741e1a32a12a3b594f291943c8cc76a75d61c97939e090864904a
data/.document ADDED
@@ -0,0 +1,11 @@
1
+ # .document is used by rdoc and yard to know how to generate documentation
2
+ # for example, it can be used to control how rdoc gets built when you do `gem install foo`
3
+
4
+ README.rdoc
5
+ lib/**/*.rb
6
+ bin/*
7
+
8
+ # Files below this - are treated as 'extra files', and aren't parsed for ruby code
9
+ -
10
+ features/**/*.feature
11
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ /nbproject/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=Fuubar
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ --private
2
+ --markup markdown
3
+ --hide-void-return
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in typogrowl.gemspec
4
+ gemspec
5
+
6
+ gem 'htmlbeautifier', :git => 'https://github.com/threedaymonk/htmlbeautifier'
7
+ gem 'aquarium', '~> 0.6', :git => 'git://github.com/deanwampler/Aquarium.git'
8
+ gem "crochets", :git => 'git://github.com/mudasobwa/crochets.git'
9
+
10
+ #gem "diff-lcs", :git => 'git://github.com/halostatue/diff-lcs.git'
11
+
12
+ #gem "rspec-core", :git => 'git://github.com/rspec/rspec-core.git'
13
+ #gem "rspec-expectations", :path => '../rspec-expectations'
14
+ #gem "rspec-mocks", :git => 'git://github.com/rspec/rspec-mocks.git'
15
+ # gem "rspec", :git => 'git://github.com/rspec/rspec.git'
16
+
17
+ gem 'rake', :group => :test
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Alexei Matyushkin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,345 @@
1
+ ![qipowl](/images/owl.png)
2
+
3
+ ## Name
4
+
5
+ _qipowl_ (pronounced as **keep all**)
6
+
7
+ [![Build Status](https://travis-ci.org/mudasobwa/qipowl.png)](https://travis-ci.org/mudasobwa/qipowl)
8
+ [![Gemnasium](https://gemnasium.com/mudasobwa/qipowl.png?travis)](https://gemnasium.com/mudasobwa/qipowl)
9
+ [![Stories in Ready](https://badge.waffle.io/mudasobwa/qipowl.png?label=ready)](http://waffle.io/mudasobwa/qipowl)
10
+
11
+ **Status:** Minimum viable product
12
+
13
+ ---
14
+
15
+ [Introduction into techniques](http://rocket-science.ru/qipowl/)
16
+
17
+ ## Intro
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
+ The main idea of _qipowl_ is to yield the power of
24
+ [DSL in Ruby](http://jroller.com/rolsen/entry/building_a_dsl_in_ruby).
25
+ The whole input text is treated neither more nor less than `DSL`.
26
+ That gives the user an ability to make virtually every term in input text
27
+ the _operating entity_.
28
+
29
+ ## Examples
30
+
31
+ This chapter should be the last one, but who wants to read technical details
32
+ without any clue of how they might be applied? So, here we go.
33
+
34
+ ### Shipping with: Markright
35
+
36
+ Right is looking right past up and down, right? _qipowl_ comes with built-in
37
+ markright parser, which is superset of markdown.
38
+
39
+ _qipowl_ markright utilizes UTF-8 heavily. The standard markup (here and further:
40
+ _qipowl markup_, or _qp_) lays on unicode characters instead of
41
+ legacy asterisks and underscores in markdown. It brings the better
42
+ readability to plain text before it’s processed with _qipowl_ and
43
+ allows more readable `DSL` for processing. For instance, the input:
44
+
45
+ §3 Emphasized text
46
+
47
+ There are four standard modifiers for emphasizing text:
48
+ ▶ “≡” — bold
49
+ ▶ “≈” — italic
50
+ ▶ “↓” — small
51
+ ▶ “λ” — code
52
+
53
+ The formers are to surround the target text piece.
54
+ This text contains:
55
+ • ≡bold≡,
56
+ • ≈italics≈,
57
+ • ↓small↓
58
+ • and even some λcodeλ.
59
+
60
+ will be processed as:
61
+
62
+ ```html
63
+ <h3>Emphasized text</h3>
64
+ <p class='dropcap'>There are four standard modifiers for emphasizing text:</p>
65
+ <dl><dt>“≡”</dt><dd>bold</dd>
66
+ <dt>“≈”</dt><dd>italic</dd>
67
+ <dt>“↓”</dt><dd>small</dd>
68
+ <dt>“λ”</dt><dd>code</dd></dl>
69
+ <p class='dropcap'>The formers are to surround the target text piece.
70
+ This text contains:</p>
71
+ <ul><li><strong>bold</strong>,</li>
72
+ <li><em>italics</em>,</li>
73
+ <li><small>small</small></li>
74
+ <li>and even some <code>code</code>.</li></ul>
75
+ ```
76
+
77
+ The valuable subset of HTML5 is implemented directly, plus the user may
78
+ eventually extend the list of understandable tags.
79
+
80
+ The markup-specific symbols, like “▶” and “•” in the previous example
81
+ may be mapped to keyboard (see `typo` file within `data` directory of the
82
+ project.
83
+
84
+ ## Internals
85
+
86
+ _qipowl_ markup implementation consists of two parts: markup definition
87
+ (kinda `yaml` file) and markup processor. The latter derives from base
88
+ processor implementation `Qipowl::Bowler`.
89
+
90
+ ### Markup definition
91
+
92
+ _qipowl_ understands six types of ‘operators’:
93
+
94
+ * flush
95
+ * block
96
+ * magnet
97
+ * inplace
98
+ * linewide
99
+ * handshake
100
+ * kiss
101
+ * custom
102
+
103
+ #### :flush
104
+
105
+ The operators in this group are executed immediately and do not break
106
+ the control flow. Technically, they are simply being substituted with
107
+ their representation.
108
+
109
+ :flush
110
+ :⏎ : :br
111
+
112
+ means that “⏎” anywhere in text will be substituted with “&lt;br&gt;”
113
+
114
+ #### :block
115
+
116
+ This group contains operators, which are driving the blocks. Such a block
117
+ should start with the operator and ends with it. Operator may receive an
118
+ additional parameter, located on the same string as the opening operator.
119
+
120
+ :block
121
+ :Λ : :pre
122
+
123
+ means that the following block:
124
+
125
+ Λ ruby
126
+ @mapping[:block].each { |tag, htmltag|
127
+ break if tag < :inplace
128
+ }
129
+ Λ
130
+
131
+ is to be left intouch (except of html is escaped inside)
132
+ and surrounded with `pre` tags:
133
+
134
+ <pre class='ruby'>
135
+ @mapping[:block].each { |tag, htmltag|
136
+ break if tag &lt; :inplace
137
+ }
138
+ </pre>
139
+
140
+ This operator is the only one which preserves the line breaks.
141
+
142
+ #### :magnet
143
+
144
+ Almost the same as `:inplace` but does not require closing match.
145
+ Operates on the following text piece until the space. E.g.
146
+
147
+ :magnet
148
+ :☎ : :span†phone
149
+
150
+ will produce
151
+
152
+ <span class='phone'>☎ +1(987)5554321</span>
153
+
154
+ for the markup:
155
+
156
+ ☎ +1(987)5554321
157
+
158
+ #### :inplace
159
+
160
+ Acts mostly like `:block` but inside one text block (text blocks are
161
+ likely paragraphs, delimited with double carriage returns.) Requires
162
+ closing element. Inplace operators are of highest priority and may
163
+ overlap.
164
+
165
+ :inplace
166
+ :≡ : :strong
167
+
168
+ will convert
169
+
170
+ That is ≡bold≡ text.
171
+
172
+ into
173
+
174
+ That is <strong>bold</strong> text.
175
+
176
+ #### :linewide
177
+
178
+ Those are not require closings, since they are operated on the _rest_ of
179
+ the text. Support nesting by prepending tags with _non-breakable space_:
180
+
181
+ :linewide
182
+ :• : li
183
+
184
+ The following syntax
185
+
186
+ • Line item 1
187
+  • Nested li 1
188
+  • Nested li 2
189
+ • Line item 2
190
+
191
+ will produce:
192
+
193
+ <ul><li>Line item 1</li>
194
+ <ul><li>Nested li 1</li>
195
+ <li>Nested li 2</li></ul>
196
+ <li>Line item 2</li></ul>
197
+
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
+ ### Extending
246
+
247
+ Extending _qipowl_ is as easy as writing a couple of strings in YAML format.
248
+ Let’s take a look at additional rules file for markdown support:
249
+
250
+ ```yaml
251
+ :synsugar :
252
+ # Code blocks, 4+ spaces indent
253
+ '(?x-mi:(\R)((?:(?:\R)+(?:\s{4,}|\t).*)+\R)(?=\R))' : "\\1\nΛ auto\\2Λ\n"
254
+ # Pictures
255
+ '!\[(.*?)\]\((.*?)\)' : '⚓\2 \1⚓'
256
+ # Links
257
+ '\[(.*?)\]\((.*?)\)' : '⚓\2 \1⚓'
258
+ # Blockquotes
259
+ '^\s*>' : '〉'
260
+ '^\s*>\s*>' : '〉 〉'
261
+ '^\s*\*\s*\*' : '〉 •'
262
+ '^\s+\*' : '• •'
263
+
264
+
265
+ :inplace :
266
+ :'__' : :strong
267
+ :'**' : :strong
268
+ :'_' : :em
269
+ :'*' : :em
270
+ :'`' : :code
271
+ ```
272
+
273
+ Bold, italic, code, images, links, blockquotes (including nesteds) are now
274
+ supported by _qipowl_. Let any one of you who is not delighted with,
275
+ be the first to throw a stone at me.
276
+
277
+ Need custom support for `github`-flavored markdown _strikethrough_? Oneliner
278
+ inside an `:inplace` section of custom rules came on scene:
279
+
280
+ ```yaml
281
+ :'~~' :strike
282
+ ```
283
+
284
+ #### Sophisticated extending
285
+
286
+ Whether one needs more sophisticated rules, she is to write her own
287
+ descendant of `Bowler` class, implementing DSL herself. E.g. `Html`
288
+ markup uses the following DSL for handling video links to YouTube:
289
+
290
+ ```ruby
291
+ # Handler for Youtube video
292
+ # @param [Array] args the words, gained since last call to {#harvest}
293
+ # @return [Nil] nil
294
+ def ✇ *args
295
+ id, *rest = args.flatten
296
+ harvest nil, orphan(rest.join(SEPARATOR)) unless rest.vacant?
297
+ harvest __callee__, "<iframe width='560' height='315'
298
+ src='http://www.youtube.com/embed/#{id}'
299
+ frameborder='0' allowfullscreen></iframe>"
300
+ end
301
+ ```
302
+
303
+ Here we harvest the previously gained words (`rest`) and transform copy-pasted
304
+ link to video into embedded frame with video content as by YouTube.
305
+
306
+ ## Installation
307
+
308
+ Add this line to your application's Gemfile:
309
+
310
+ gem 'typogrowl'
311
+
312
+ And then execute:
313
+
314
+ $ bundle
315
+
316
+ Or install it yourself as:
317
+
318
+ $ gem install typogrowl
319
+
320
+ ## Usage
321
+
322
+ ```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'
333
+
334
+ tg = Qipowl.tg_md__html # typogrowl markup _and_ markdown
335
+
336
+ puts tg.parse_and_roll(text)
337
+ ```
338
+
339
+ ## Contributing
340
+
341
+ 1. Fork it
342
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
343
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
344
+ 4. Push to the branch (`git push origin my-new-feature`)
345
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Tests'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.rspec_opts = '-Ispec'
8
+ # spec.rcov = true
9
+ end
10
+
11
+ require 'cucumber/rake/task'
12
+ desc 'Cucumber'
13
+ Cucumber::Rake::Task.new(:features)
14
+
15
+ task :default => [:features, :spec]
16
+
17
+ require 'yard'
18
+ desc 'YARD'
19
+ YARD::Rake::YardocTask.new(:yard) do |t|
20
+ t.files = ['**/*.rb', 'features/**/*.feature', 'features/**/*.rb']
21
+ end
data/bin/bowler ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'optparse'
7
+ require_relative '../lib/qipowl'
8
+
9
+ options = {}
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: #{$0} FILE|STRING"
12
+
13
+ # Bowl result?
14
+ opts.on("-a", "--action ACTION", [:bowl, :ruby, :cmd, :yaml, :html],
15
+ "Action to apply on input (bowl, ruby, cmd, yaml, html); default: html") do |action|
16
+ options[:action] = action || :bowl
17
+ end
18
+
19
+ # No argument, shows at tail. This will print an options summary.
20
+ opts.on_tail("-h", "--help", "Show this message") do
21
+ puts opts
22
+ exit
23
+ end
24
+ end.parse!
25
+
26
+ raise "Run `#{$0} --help` for execution examples. Exiting…" if ARGV.size.zero?
27
+
28
+ file_or_string = ARGV.first
29
+ file_or_string = File.read(file_or_string) if File.exist?(file_or_string)
30
+
31
+ case options[:action]
32
+ when :bowl
33
+ puts file_or_string.bowl
34
+ when :ruby
35
+ puts Qipowl::Mapping.new(nil, file_or_string).to_ruby
36
+ when :html
37
+ puts Qipowl::Html.parse file_or_string
38
+ when :cmd
39
+ puts Qipowl::Cmd.execute file_or_string
40
+ when :yaml
41
+ puts Qipowl::Yaml.parse file_or_string
42
+ else
43
+ puts Qipowl::Html.parse file_or_string
44
+ end
@@ -0,0 +1,3 @@
1
+ :entities :
2
+ :regular :
3
+ :список_файлов : :ls
@@ -0,0 +1,128 @@
1
+ # encoding: utf-8
2
+
3
+ # bowler’s entity values: - type, - synonyms, - parent
4
+ # possible types: - block, - alone, - grip, - magnet, - regular, - custom
5
+
6
+ # html specifics: - tag, - class
7
+
8
+ :includes :
9
+ - 'html_supplemental'
10
+ - 'markdown2html'
11
+
12
+ :entities :
13
+ :block :
14
+ :✍ :
15
+ :synonyms :
16
+ - :'---'
17
+ :Λ :
18
+ :tag : :pre
19
+ :class : :code
20
+ :alone :
21
+ :⏎ : :br
22
+ :—— : :hr
23
+ :magnet :
24
+ :☎ :
25
+ :tag : :span
26
+ :class : :phone
27
+ :✉ :
28
+ :tag : :span
29
+ :class : :email
30
+ :synonyms :
31
+ - :mail
32
+ :✎ : :lj
33
+ :☇ : :a
34
+ :grip :
35
+ :≡ : :strong
36
+ :≈ : :em
37
+ :↑ : :sup
38
+ :↓ : :small
39
+ :λ : :code
40
+ :⚓ : :a
41
+ :† : :abbr
42
+ :✁ : :del
43
+ :✿_span_nobr : :nobr
44
+ :regular :
45
+ :• :
46
+ :tag : :li
47
+ :parent :
48
+ :tag : :ul
49
+ :class : :fancy
50
+ :◦ :
51
+ :tag : :li
52
+ :parent : :ol
53
+ :class : :active
54
+ :▶ :
55
+ :tag : :dt
56
+ :parent : :dl
57
+ :▷ :
58
+ :tag : :dt
59
+ :parent :
60
+ :tag : :dl
61
+ :class : :dl_horizontal
62
+ :℁ : :address
63
+ :〉 :
64
+ :tag : :p
65
+ :parent : :blockquote
66
+ :class : :blockquote
67
+ :§1 : :h1
68
+ :§2 : :h2
69
+ :§3 : :h3
70
+ :§4 : :h4
71
+ :§5 : :h5
72
+ :§6 : :h6
73
+ :¶ :
74
+ :tag : :p
75
+ :class : :lead
76
+ :☆ :
77
+ :tag : :p
78
+ :class : :text_muted
79
+ :★ : :em
80
+ :☛ :
81
+ :tag : :p
82
+ :class : :text_success
83
+ :☞ :
84
+ :tag : :p
85
+ :class : :text_info
86
+ :☣ :
87
+ :tag : :p
88
+ :class : :text_warning
89
+ :☢ :
90
+ :tag : :p
91
+ :class : :text_danger
92
+ :✇ : :video
93
+ :⚘ : :figure
94
+ :✿_p_address :
95
+ :tag : :p
96
+ :class : :address
97
+ :✿_p_epigraph :
98
+ :tag : :p
99
+ :class : :epigraph
100
+ :✿_p_afterepigraph :
101
+ :tag : :p
102
+ :class : :afterepigraph
103
+ :✿_p_auto :
104
+ :tag : :p
105
+ :class : :dropcap
106
+
107
+ :custom :
108
+ '^\s*‒\p{Blank}+(.+),\s*(\S+)' : ' ⏎ ↓ ⚓\2 \1⚓'
109
+ '(\S+)¹(\S+?)(?=\s|\)|\.\s|\.\Z|\,\s|;\s|␍|\Z)' : '⚓\2 \1⚓'
110
+ '(\S+)†(.+?)†' : '†\1 \2†'
111
+ # http://youtu.be/SAJ_TzLqy1U?t=6s
112
+ 'http://youtu\.be/([A-Za-z0-9_]+)(?:\?t=(\d+)s)?' : '✇ \1'
113
+ # http://www.youtube.com/watch?v=SAJ_TzLqy1U
114
+ 'http://www\.youtube\.com/(?:watch\?v=|v/)([A-Za-z0-9_]+)' : '✇ \1'
115
+ # Standalone images and quotes
116
+ '^(https?://\S+)(\s*.*)$' : '⚘ \1 \2'
117
+
118
+ :enclosures :
119
+ :• :
120
+ :tag : :ul
121
+ :class : :fancy
122
+ :◦ : :ol
123
+ :▶ : :dl
124
+ :▷ :
125
+ :tag : :dl
126
+ :class : :dl_horizontal
127
+ :〉 : :blockquote
128
+
@@ -0,0 +1,3 @@
1
+ :entities :
2
+ :grip :
3
+ :÷ : :del
@@ -0,0 +1,23 @@
1
+ :custom :
2
+ '(?x-mi:(\R)((?:(?:\R)+(?:\s{4,}|\t).*)+\R)(?=\R))' : "\\1\nΛ auto\\2Λ\n"
3
+ '^!\[(.*?)\]\((.*?)\)$' : '⚘ \2 \1'
4
+ '!\[(.*?)\]\((.*?)\)' : '⚓\2 \1⚓'
5
+ '\[(.*?)\]\((.*?)\)' : '⚓\2 \1⚓'
6
+ '^\s*>' : '〉'
7
+ '^\s*>\s*>' : ' 〉'
8
+ '^\s+\*' : ' •'
9
+ ' {2,}(?=$)' : " ⏎"
10
+
11
+
12
+ :entities :
13
+ :grip :
14
+ :'**' :
15
+ :tag : :strong
16
+ :marker : :≡
17
+ :synonyms :
18
+ - :'__'
19
+ :'*' :
20
+ :tag : :em
21
+ :marker : :≈
22
+ :'`' : :code
23
+ :'~~' : :del
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ require 'cgi'
4
+ require 'json'
5
+ require 'sinatra'
6
+
7
+ require_relative '../qipowl'
8
+
9
+ use Rack::Session::Pool, :expire_after => 2592000
10
+
11
+ before do
12
+ session[:typo] ||= Qipowl.tg_md__html
13
+ end
14
+
15
+ get '/html/mapping' do
16
+ content_type :json
17
+ session[:typo].mapping.hash.to_json
18
+ end
19
+
20
+ delete '/html/mapping/:key' do |key|
21
+ content_type :json
22
+ session[:typo].mapping.remove_spice(key.to_sym).to_json
23
+ end
24
+
25
+ put '/html/mapping/:section/:key/:value/?:enclosure?' do |section, key, value, enclosure|
26
+ content_type :json
27
+ session[:typo].mapping.add_spice(section.to_sym, key.to_sym, value.to_sym, enclosure ? enclosure.to_sym : nil).to_json
28
+ end
29
+
30
+ get '/html/parse' do
31
+ str = CGI::parse(request.query_string)['text'].first
32
+ content_type :html
33
+ session[:typo].parse_and_roll str
34
+ end