schizm 0.0.9 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f17f1d1ae4d7892076dfb8cd163a999483ed2d61
4
- data.tar.gz: 2138eb60e28bb56149402f8aa681c4d9f957fe57
3
+ metadata.gz: 1e6ade6f1678f5e9aae1e0c4addf45cb740087d4
4
+ data.tar.gz: f7f1a6b0271041205ba6b3d6cac552b9efbd3b85
5
5
  SHA512:
6
- metadata.gz: 69974b4442b5f4ddf2f9b24d62147f96eab69f078341680bf94914a8ca09176650bcf63b963b4f3908c8ed889e709023ce1df9940aade7ce26c9332a8d3657bb
7
- data.tar.gz: 76464c5dcd06ed17f21385fcb718196c65422eb1a2b8a33fb4de92fa7be214641ce45f84b97487c52d5e5e4a4e77a5631efe97db2a331b0a54089d94bab77010
6
+ metadata.gz: 00e2ca134b48f72d8aabb95e1a870084dd23ecdf40ec7b4857923f210458947bccd1b5a4682579d1da7f10aebaa37c56945b51ae0ba8244e7fc1f38890df1c49
7
+ data.tar.gz: 809d884192100de33b8242285738e29f4560d3b793a762a0f3ba5a297385e3edb98a75ffe6c62592f9eb9632d1dbc16463eef812dcf96027e77710ca0f877210
data/bin/schizm CHANGED
@@ -14,11 +14,16 @@ when "init"
14
14
  when "build"
15
15
  Schizm::Env::Opts.build.order!
16
16
  Schizm::Env.build
17
- when "install-path"
18
- puts Schizm::Env.home
17
+ when "vim-install"
18
+ Schizm::Env::Opts.vim_install.order!
19
+ Schizm::Env.vim_install
20
+ exit 0
21
+ when "vim-uninstall"
22
+ Schizm::Env::Opts.vim_uninstall.order!
23
+ Schizm::Env.vim_uninstall
19
24
  exit 0
20
- when "info"
21
- # TODO
25
+ when "home?"
26
+ puts Schizm::Env.home
22
27
  exit 0
23
28
  else
24
29
  puts <<HELP
@@ -27,10 +32,12 @@ Usage: schizm MODE [OPTIONS]
27
32
  \tNew project in working directory.
28
33
  `schizm build [OPTIONS]`
29
34
  \tBuild project in working directory.
30
- `schizm install-path`
35
+ `schizm vim-install [OPTIONS]`
36
+ \tInstall Vim syntax files.
37
+ `schizm vim-uninstall [OPTIONS]`
38
+ \tUninstall Vim syntax files.
39
+ `schizm home?`
31
40
  \tDisplay schizm's install directory.
32
- `schizm info`
33
- \tDisplay additional information.
34
41
  HELP
35
42
  exit 0
36
43
  end
data/lib/schizm/env.rb CHANGED
@@ -51,29 +51,6 @@ module Env
51
51
  return false
52
52
  end
53
53
 
54
- # Prompt the user with a yes/no question.
55
- def self.yes? string, backup
56
- backup = backup.downcase[0]
57
- print "#{string} [Y/n] " if backup == "y"
58
- print "#{string} [y/N] " if backup == "n"
59
- answer = gets.strip.downcase[0]
60
- return answer == "y" if answer != ""
61
- return backup == "y"
62
- end
63
-
64
- # Write +string+ to +target+. If +target+ is an existing file and
65
- # +var[:rewrite]+ is not set, prompts the user for permission to rewrite.
66
- def self.write target, string
67
- if (not File.file? target or
68
- var? :rewrite or
69
- yes? "Rewrite '#{target}'?", "n")
70
- puts "Writing '#{target}'" if var? :verbose
71
- file = File.open target, "wb"
72
- file.write string.to_s
73
- file.close
74
- end
75
- end
76
-
77
54
  # Current user's name.
78
55
  def self.thisuser
79
56
  return Etc.getpwnam(Etc.getlogin).gecos.split(/,/).first
@@ -121,6 +98,162 @@ module Env
121
98
  return File.read File.join(home, "res", *args)
122
99
  end
123
100
 
101
+ # Prompt the user with a yes/no question.
102
+ def self.yes? string, backup
103
+ backup = backup.downcase[0]
104
+ print "#{string} [Y/n] " if backup == "y"
105
+ print "#{string} [y/N] " if backup == "n"
106
+ answer = gets.strip.downcase[0]
107
+ return answer == "y" if answer != ""
108
+ return backup == "y"
109
+ end
110
+
111
+ # Write +string+ to +target+. If +target+ is an existing file and
112
+ # +var[:rewrite]+ is not set, prompts the user for permission to rewrite.
113
+ def self.write target, string
114
+ unless File.file? target and
115
+ not var? :rewrite and
116
+ not yes? "Rewrite '#{target}'?", "n"
117
+ puts "Writing '#{target}'" if var? :verbose
118
+ file = File.open target, "wb"
119
+ file.write string.to_s
120
+ file.close
121
+ end
122
+ end
123
+
124
+ # Delete +path+ if it exists. If +path+ is a directory, recursively
125
+ # delete all subdirectories.
126
+ def self.delete path
127
+ if File.exist? path
128
+ puts "Deleting #{path}" if var? :verbose
129
+ if File.file? path
130
+ File.delete path
131
+ elsif File.directory? path
132
+ Dir.foreach path do |subpath|
133
+ next if subpath == '.'
134
+ next if subpath == '..'
135
+ self.delete File.join(path, subpath)
136
+ end
137
+ end
138
+ end
139
+ end
140
+
141
+ # Create missing directories in +path+.
142
+ def self.blaze path
143
+ dir = ''
144
+ path = File.dirname path
145
+ path = File.absolute_path path
146
+ dirs = path.split File::SEPARATOR
147
+ dirs.each do |sub|
148
+ dir = File.join dir, sub
149
+ unless Dir.exist? dir
150
+ puts "Making '#{dir}'" if var? :verbose
151
+ Dir.mkdir dir
152
+ end
153
+ end
154
+ end
155
+
156
+ # Return path +dest+ relative to +from+.
157
+ def self.path_from from, dest
158
+ return Pathname.new(dest).relative_path_from(Pathname.new(from)).to_s
159
+ end
160
+
161
+ def self.docs_path path
162
+ return "/docs/#{path_from var[:output_doc], path}"
163
+ end
164
+
165
+ module Opts
166
+
167
+ def self.init
168
+ return OptionParser.new do |optparse|
169
+ optparse.banner = "Usage: schizm init [OPTIONS]"
170
+ optparse.on "-v", "--verbose", "Verbose messages?" do
171
+ Env.var[:verbose] = true
172
+ end
173
+ optparse.on "-r", "--rewrite", "Rewrite files without asking?" do
174
+ Env.var[:rewrite] = true
175
+ end
176
+ optparse.on "-t", "--title STR", "Set project title." do |str|
177
+ Env.var[:title] = str
178
+ end
179
+ optparse.on "-b", "--brief STR", "Set project brief." do |str|
180
+ Env.var[:brief] = str
181
+ end
182
+ optparse.on "-a", "--author STR", "Specify project author(s)." do |str|
183
+ Env.var[:author] = str
184
+ end
185
+ optparse.on "-y", "--year STR", "Specify project year(s)." do |str|
186
+ Env.var[:year] = str
187
+ end
188
+ license_enum = [
189
+ "BSD-2-Clause",
190
+ "BSD-3-Clause",
191
+ "GPL-2.0",
192
+ "GPL-3.0",
193
+ "LGPL-2.1",
194
+ "LGPL-3.0",
195
+ "MIT",
196
+ "MPL-2.0"
197
+ ]
198
+ license_help = <<LIC
199
+ Select license, none by default.
200
+
201
+ \tENUM License
202
+ \t"BSD-2-Clause" .... the 2-clause BSD License
203
+ \t"BSD-3-Clause" .... the 3-clause BSD License
204
+ \t"GPL-2.0" ......... the GNU General Public License v2.0
205
+ \t"GPL-3.0" ......... the GNU General Public License v3.0
206
+ \t"LGPL-2.1" ........ the GNU Lesser General Public License v2.1
207
+ \t"LGPL-3.0" ........ the GNU Lesser General Public License v3.0
208
+ \t"MIT" ............. the MIT License
209
+ \t"MPL-2.0" ......... the Mozilla Public License v2.0
210
+
211
+ LIC
212
+ optparse.on "-l", "--license ENUM",
213
+ license_enum,
214
+ license_help do |str|
215
+ Env.var[:license] = str
216
+ end
217
+ color_help = <<COL
218
+
219
+ \tENUM Basic color
220
+ \t"red" ............. F4 43 36
221
+ \t"pink" ............ E9 1E 63
222
+ \t"purple" .......... 9C 27 B0 *** Default primary
223
+ \t"deep-purple" ..... 67 3A B7
224
+ \t"indigo" .......... 3F 51 B5
225
+ \t"blue" ............ 21 96 F3
226
+ \t"light-blue" ...... 03 A9 F4
227
+ \t"cyan" ............ 00 BC D4
228
+ \t"teal" ............ 00 96 88 *** Default secondary
229
+ \t"green" ........... 4C AF 50
230
+ \t"light-green" ..... 8B C3 4A
231
+ \t"lime" ............ CD DC 39
232
+ \t"yellow" .......... FF EB 3B
233
+ \t"amber" ........... FF C1 07
234
+ \t"orange" .......... FF 98 00
235
+ \t"deep-orange" ..... FF 57 22
236
+
237
+ \tRefer to https://material.io/guidelines/style/color.html
238
+
239
+ COL
240
+ optparse.on "-p", "--primary-color ENUM", Env::COLORS.keys,
241
+ "Specify primary color." do |str|
242
+ Env.var[:primary_color] = str
243
+ end
244
+ optparse.on "-s", "--secondary-color ENUM", Env::COLORS.keys,
245
+ "Specify secondary color.", color_help do |str|
246
+ Env.var[:secondary_color] = str
247
+ end
248
+ optparse.on_tail "-h", "--help", "Display this help." do
249
+ puts optparse
250
+ exit 0
251
+ end
252
+ end
253
+ end
254
+
255
+ end # module Opts
256
+
124
257
  def self.init
125
258
  dirnames = [
126
259
  "src",
@@ -190,7 +323,7 @@ MAKEFILE
190
323
  *.tmp
191
324
  docs/_site
192
325
  GITIGNORE
193
- write "docs/_config.yaml", <<YAMLCONFIG
326
+ write "docs/_config.yml", <<YMLCONFIG
194
327
  source: .
195
328
  destination: _site
196
329
  plugins_dir: _plugins
@@ -207,7 +340,7 @@ markdown_ext: "markdown,md"
207
340
  author: "#{author}"
208
341
  title: "#{title}"
209
342
  brief: "#{brief}"
210
- YAMLCONFIG
343
+ YMLCONFIG
211
344
  assets = {
212
345
  "schizm.liquid" => "docs/_layouts",
213
346
  "schizm.js" => "docs/assets/js",
@@ -251,38 +384,65 @@ SASS
251
384
  write "docs/assets/css/schizm.css", Sass::Engine.new(sass_source, sass_options).render
252
385
  end
253
386
 
254
- def self.delete dir
255
- if Dir.exist? dir
256
- Dir.foreach dir do |ent|
257
- next if ent == '.'
258
- next if ent == '..'
259
- path = File.join dir, ent
260
- File.delete path if File.file? path
261
- self.delete path if File.directory? path
262
- end
263
- end
264
- end
387
+ module Opts
265
388
 
266
- def self.blaze path
267
- dir = ''
268
- path = File.dirname path
269
- path = File.absolute_path path
270
- dirs = path.split File::SEPARATOR
271
- dirs.each do |sub|
272
- dir = File.join dir, sub
273
- Dir.mkdir dir unless Dir.exist? dir
389
+ def self.build
390
+ Env.var[:input] = "zrc"
391
+ Env.var[:output_doc] = "./docs/_docs"
392
+ Env.var[:output_src] = "./src"
393
+ Env.var[:guard] = true
394
+ return OptionParser.new do |optparse|
395
+ optparse.banner = "Usage: schizm build [OPTIONS]"
396
+ optparse.on "-v", "--verbose", "Verbose messages?" do
397
+ Env.var[:verbose] = true
398
+ end
399
+ optparse.on "-r", "--rewrite", "Rewrite files without asking?" do
400
+ Env.var[:rewrite] = true
401
+ end
402
+ optparse.on "-t", "--title STR", "Set project title." do |str|
403
+ Env.var[:title] = str
404
+ end
405
+ optparse.on "-b", "--brief STR", "Set project brief." do |str|
406
+ Env.var[:brief] = str
407
+ end
408
+ optparse.on "-a", "--author STR", "Specify project author(s)." do |str|
409
+ Env.var[:author] = str
410
+ end
411
+ optparse.on "-y", "--year STR", "Specify project year(s)." do |str|
412
+ Env.var[:year] = str
413
+ end
414
+ optparse.on "--input STR",
415
+ "Where to look for input files." do |str|
416
+ Env.var[:input] = str
417
+ end
418
+ optparse.on "--output-doc STR",
419
+ "Where to write documentation files." do |str|
420
+ Env.var[:output_doc] = str
421
+ end
422
+ optparse.on "--output-src STR",
423
+ "Where to write source files." do |str|
424
+ Env.var[:output_src] = str
425
+ end
426
+ optparse.on "--only-doc", "Build only documention files?" do
427
+ Env.var[:only_doc] = true
428
+ end
429
+ optparse.on "--only-src", "Build only source files?" do
430
+ Env.var[:only_src] = true
431
+ end
432
+ optparse.on "--[no-]guard", "Guard output headers?" do |ans|
433
+ Env.var[:guard] = ans
434
+ end
435
+ optparse.on "--[no-]share", "Share chunks by default?" do |ans|
436
+ Env.var[:share] = ans
437
+ end
438
+ optparse.on_tail "-h", "--help", "Display this help." do
439
+ puts optparse
440
+ exit 0
441
+ end
442
+ end
274
443
  end
275
- end
276
444
 
277
- def self.path_from from, dest
278
- from = Pathname.new from
279
- dest = Pathname.new dest
280
- dest.relative_path_from(from).to_s
281
- end
282
-
283
- def self.path_href path
284
- "/docs/#{path_from var[:output_doc], path}"
285
- end
445
+ end # module Opts
286
446
 
287
447
  def self.build
288
448
  zrc_root = var[:input]
@@ -331,86 +491,17 @@ PARSE
331
491
 
332
492
  module Opts
333
493
 
334
- def self.init
335
- OptionParser.new do |optparse|
336
- optparse.banner = "Usage: schizm init [OPTIONS]"
494
+ def self.vim which
495
+ return OptionParser.new do |optparse|
496
+ optparse.banner = "Usage: schizm vim-#{which} [OPTIONS]"
337
497
  optparse.on "-v", "--verbose", "Verbose messages?" do
338
498
  Env.var[:verbose] = true
339
499
  end
340
500
  optparse.on "-r", "--rewrite", "Rewrite files without asking?" do
341
501
  Env.var[:rewrite] = true
342
502
  end
343
- optparse.on "-t", "--title STR", "Set project title." do |str|
344
- Env.var[:title] = str
345
- end
346
- optparse.on "-b", "--brief STR", "Set project brief." do |str|
347
- Env.var[:brief] = str
348
- end
349
- optparse.on "-a", "--author STR", "Specify project author(s)." do |str|
350
- Env.var[:author] = str
351
- end
352
- optparse.on "-y", "--year STR", "Specify project year(s)." do |str|
353
- Env.var[:year] = str
354
- end
355
- license_enum = [
356
- "BSD-2-Clause",
357
- "BSD-3-Clause",
358
- "GPL-2.0",
359
- "GPL-3.0",
360
- "LGPL-2.1",
361
- "LGPL-3.0",
362
- "MIT",
363
- "MPL-2.0"
364
- ]
365
- license_help = <<LIC
366
- Select license, none by default.
367
-
368
- \tENUM License
369
- \t"BSD-2-Clause" .... the 2-clause BSD License
370
- \t"BSD-3-Clause" .... the 3-clause BSD License
371
- \t"GPL-2.0" ......... the GNU General Public License v2.0
372
- \t"GPL-3.0" ......... the GNU General Public License v3.0
373
- \t"LGPL-2.1" ........ the GNU Lesser General Public License v2.1
374
- \t"LGPL-3.0" ........ the GNU Lesser General Public License v3.0
375
- \t"MIT" ............. the MIT License
376
- \t"MPL-2.0" ......... the Mozilla Public License v2.0
377
-
378
- LIC
379
- optparse.on "-l", "--license ENUM",
380
- license_enum,
381
- license_help do |str|
382
- Env.var[:license] = str
383
- end
384
- color_help = <<COL
385
-
386
- \tENUM Basic color
387
- \t"red" ............. F4 43 36
388
- \t"pink" ............ E9 1E 63
389
- \t"purple" .......... 9C 27 B0 *** Default primary
390
- \t"deep-purple" ..... 67 3A B7
391
- \t"indigo" .......... 3F 51 B5
392
- \t"blue" ............ 21 96 F3
393
- \t"light-blue" ...... 03 A9 F4
394
- \t"cyan" ............ 00 BC D4
395
- \t"teal" ............ 00 96 88 *** Default secondary
396
- \t"green" ........... 4C AF 50
397
- \t"light-green" ..... 8B C3 4A
398
- \t"lime" ............ CD DC 39
399
- \t"yellow" .......... FF EB 3B
400
- \t"amber" ........... FF C1 07
401
- \t"orange" .......... FF 98 00
402
- \t"deep-orange" ..... FF 57 22
403
-
404
- \tRefer to https://material.io/guidelines/style/color.html
405
-
406
- COL
407
- optparse.on "-p", "--primary-color ENUM", Env::COLORS.keys,
408
- "Specify primary color." do |str|
409
- Env.var[:primary_color] = str
410
- end
411
- optparse.on "-s", "--secondary-color ENUM", Env::COLORS.keys,
412
- "Specify secondary color.", color_help do |str|
413
- Env.var[:secondary_color] = str
503
+ optparse.on "-p", "--path STR", "Specify Vim path." do |str|
504
+ Env.var[:vimhome] = str
414
505
  end
415
506
  optparse.on_tail "-h", "--help", "Display this help." do
416
507
  puts optparse
@@ -419,63 +510,46 @@ COL
419
510
  end
420
511
  end
421
512
 
422
- def self.build
423
- Env.var[:input] = "zrc"
424
- Env.var[:output_doc] = "./docs/_docs"
425
- Env.var[:output_src] = "./src"
426
- Env.var[:guard] = true
427
- OptionParser.new do |optparse|
428
- optparse.banner = "Usage: schizm build [OPTIONS]"
429
- optparse.on "-v", "--verbose", "Verbose messages?" do
430
- Env.var[:verbose] = true
431
- end
432
- optparse.on "-r", "--rewrite", "Rewrite files without asking?" do
433
- Env.var[:rewrite] = true
434
- end
435
- optparse.on "-t", "--title STR", "Set project title." do |str|
436
- Env.var[:title] = str
437
- end
438
- optparse.on "-b", "--brief STR", "Set project brief." do |str|
439
- Env.var[:brief] = str
440
- end
441
- optparse.on "-a", "--author STR", "Specify project author(s)." do |str|
442
- Env.var[:author] = str
443
- end
444
- optparse.on "-y", "--year STR", "Specify project year(s)." do |str|
445
- Env.var[:year] = str
446
- end
447
- optparse.on "--input STR",
448
- "Where to look for input files." do |str|
449
- Env.var[:input] = str
450
- end
451
- optparse.on "--output-doc STR",
452
- "Where to write documentation files." do |str|
453
- Env.var[:output_doc] = str
454
- end
455
- optparse.on "--output-src STR",
456
- "Where to write source files." do |str|
457
- Env.var[:output_src] = str
458
- end
459
- optparse.on "--only-doc", "Build only documention files?" do
460
- Env.var[:only_doc] = true
461
- end
462
- optparse.on "--only-src", "Build only source files?" do
463
- Env.var[:only_src] = true
464
- end
465
- optparse.on "--[no-]guard", "Guard output headers?" do |ans|
466
- Env.var[:guard] = ans
467
- end
468
- optparse.on "--[no-]share", "Share chunks by default?" do |ans|
469
- Env.var[:share] = ans
470
- end
471
- optparse.on_tail "-h", "--help", "Display this help." do
472
- puts optparse
473
- exit 0
474
- end
475
- end
513
+ def self.vim_install
514
+ return vim "install"
476
515
  end
477
516
 
478
- end # module Opts
517
+ def self.vim_uninstall
518
+ return vim "uninstall"
519
+ end
520
+
521
+ end
522
+
523
+ def self.vim_install
524
+ vimhome = "~/.vim"
525
+ vimhome = var[:vimhome] if var? :vimhome
526
+ vimhome = File.absolute_path File.expand_path(vimhome)
527
+ assets = {
528
+ "vim/ftdetect/schizm.vim" => File.join(vimhome, "ftdetect"),
529
+ "vim/ftplugin/schizm.vim" => File.join(vimhome, "ftplugin"),
530
+ "vim/indent/schizm.vim" => File.join(vimhome, "indent"),
531
+ "vim/syntax/schizm.vim" => File.join(vimhome, "syntax")
532
+ }
533
+ assets.each do |from, to|
534
+ blaze File.join(to, File.basename(from))
535
+ write File.join(to, File.basename(from)), resource(from)
536
+ end
537
+ end
538
+
539
+ def self.vim_uninstall
540
+ vimhome = "~/.vim"
541
+ vimhome = var[:vimhome] if var? :vimhome
542
+ vimhome = File.absolute_path File.expand_path(vimhome)
543
+ assets = [
544
+ File.join(vimhome, "ftdetect/schizm.vim"),
545
+ File.join(vimhome, "ftplugin/schizm.vim"),
546
+ File.join(vimhome, "indent/schizm.vim"),
547
+ File.join(vimhome, "syntax/schizm.vim")
548
+ ]
549
+ assets.each do |asset|
550
+ delete asset
551
+ end
552
+ end
479
553
 
480
554
  end # module Env
481
555
 
data/lib/schizm/match.rb CHANGED
@@ -100,16 +100,16 @@ module Schizm
100
100
  CHAR_ESCAPE = /\\(.)/u
101
101
 
102
102
  # Link definition, content put in match group 1, params put in match group 2.
103
- LINK_DEF = /^\[(#{DELIM_BRACKS})\]:[ ]*(.*)[ ]*\n/u
103
+ LINK_DEF = /^&:\[(#{DELIM_BRACKS})\][ ]*(.*)[ ]*\n/u
104
104
 
105
105
  # Link reference, content put in match group 1, params put in match group 2.
106
- LINK_REF_PARENS = /\[(#{DELIM_BRACKS})\]\((#{DELIM_PARENS})\)/um
106
+ LINK_REF_PARENS = /&\[(#{DELIM_BRACKS})\]\((#{DELIM_PARENS})\)/um
107
107
 
108
108
  # Link reference, content put in match group 1, params put in match group 2.
109
- LINK_REF_BRACKS = /\[(#{DELIM_BRACKS})\](?:\[(#{DELIM_BRACKS})\])?/um
109
+ LINK_REF_BRACKS = /&\[(#{DELIM_BRACKS})\](?:\[(#{DELIM_BRACKS})\])?/um
110
110
 
111
111
  # Image definition, entry put in match group 1, params put in match group 2.
112
- IMAGE_DEF = /^!\[(#{DELIM_BRACKS})\]:[ ]*(.*)[ ]*\n/u
112
+ IMAGE_DEF = /^!:\[(#{DELIM_BRACKS})\][ ]*(.*)[ ]*\n/u
113
113
 
114
114
  # Image reference, alt put in match group 1, params put in match group 2.
115
115
  IMAGE_REF_PARENS = /!\[(#{DELIM_BRACKS})\]\((#{DELIM_PARENS})\)/u
@@ -118,13 +118,13 @@ module Schizm
118
118
  IMAGE_REF_BRACKS = /!\[(#{DELIM_BRACKS})\](?:\[(#{DELIM_BRACKS})\])?/u
119
119
 
120
120
  # Center math, content put in match group 1.
121
- CENTER_MATH = /[$][$]((?:[^\\$]*(?:\\.)*)*)[$][$]/um
121
+ CENTER_MATH = /\$\$((?:[^\\$]*(?:\\.)*)*)\$+/um
122
122
 
123
123
  # Markup attributes for +CENTER_MATH+.
124
124
  CENTER_MATH_ATTRS = {'type' => 'math/tex; mode=display'}
125
125
 
126
126
  # Inline math, content put in match group 1.
127
- INLINE_MATH = /[$]((?:[^\\$]*(?:\\.)*)*)[$]/um
127
+ INLINE_MATH = /\$((?:[^\\$]*(?:\\.)*)*)\$/um
128
128
 
129
129
  # Markup attributes for +INLINE_MATH+.
130
130
  INLINE_MATH_ATTRS = {'type' => 'math/tex; mode=inline'}
@@ -145,40 +145,37 @@ module Schizm
145
145
  INLINE_INS = /\+{(#{DELIM_BRACES})}/um
146
146
 
147
147
  # Inline delete, content put in match group 1.
148
- INLINE_DEL = /~{(#{DELIM_BRACES})}/um
148
+ INLINE_DEL = /-{(#{DELIM_BRACES})}/um
149
149
 
150
150
  # Chunk label, content put in match group 1.
151
- CHUNK_LABEL = /[@]\[(#{DELIM_BRACKS})\]/um
152
-
153
- # Chunk param, content put in match group 1.
154
- CHUNK_PARAM = /[#]\[(#{DELIM_BRACKS})\]/um
151
+ CHUNK_LABEL = /@\[(#{DELIM_BRACKS})\]/um
155
152
 
156
153
  # Chunk block, content put in match group 1.
157
154
  CHUNK_BLOCK = /\((#{DELIM_PARENS})\)/um
158
155
 
159
156
  # Enter quote block.
160
- ENTER_QUOTE = /^["][ ]{3}/u #/^[ ]{0,3}[>][>][>]/u
157
+ ENTER_QUOTE = /^[>][ ]{3}/u
161
158
 
162
159
  # Enter aside block.
163
- ENTER_ASIDE = /^[>][ ]{3}/u #/^[ ]{0,3}[.]{3}/u
160
+ ENTER_ASIDE = /^[~][ ]{3}/u
164
161
 
165
162
  # Enter alert block.
166
- ENTER_ALERT = /^[!][ ]{3}/u # /^[ ]{0,3}[!]{1,3}/u
163
+ ENTER_ALERT = /^[!][ ]{3}/u
167
164
 
168
165
  # Enter bug block.
169
- ENTER_BUG = /^[?][ ]{3}/u #/^[ ]{0,3}[?]{1,3}/u
166
+ ENTER_BUG = /^[?][ ]{3}/u
170
167
 
171
168
  # Enter olist element.
172
- ENTER_OLIST = /^\d\.[ ]{2}|\d{2}\.[ ]/u #/^[ ]{0,3}--?[#]/u
169
+ ENTER_OLIST = /^\d\.[ ]{2}|\d{2}\.[ ]/u
173
170
 
174
171
  # Enter ulist element.
175
- ENTER_ULIST = /^[-][ ]{3}|[-]{2}[ ]{2}/u #/^[ ]{0,3}--?[%]/u
172
+ ENTER_ULIST = /^[-][ ]{3}|[-]{2}[ ]{2}/u
176
173
 
177
174
  # Enter tlist element, type put in match group 1.
178
- ENTER_TLIST = /^\[([x ])\][ ]/u #/^[ ]{0,3}\[([x ])\]/u
175
+ ENTER_TLIST = /^\[([x ])\][ ]/u
179
176
 
180
177
  # Enter dlist element, content put in match group 1.
181
- ENTER_DLIST = /^(\p{Graph}.*?)::/u #/^[ ]{0,3}(.*?)::/u
178
+ ENTER_DLIST = /^(\p{Graph}.*?)::/u
182
179
 
183
180
  # Enter code block.
184
181
  ENTER_CODE = /^[ ]{4,}(?=\p{Graph})/u
@@ -188,106 +185,68 @@ module Schizm
188
185
 
189
186
  # Special ASCII sequences.
190
187
  GLYPH = [
191
- [/\(tm\)/ui, 8482], # Trademark.
192
- [/\(c\)/ui, 9400], # Copyright.
193
- [/\(r\)/ui, 174], # Registered.
194
- [/\+-/u, 177], # Plus minus.
195
- [/==/u, 8801], # Identical.
196
- [/=~/u, 8773], # Congruent.
197
- [/!=/u, 8800], # Not equal.
198
- [/<=/u, 8804], # Less equal.
199
- [/>=/u, 8805], # Greater equal.
200
- [/~=/u, 8776], # Approximately.
201
- [/--/u, 8211], # En dash.
202
- [/---/u, 8212], # Em dash.
203
- [/\.{3}/u, 8230], # Ellipsis.
204
- [/<--/u, 8592], # Left single arrow.
205
- [/<==/u, 8656], # Left double arrow.
206
- [/-->/u, 8594], # Right single arrow.
207
- [/==>/u, 8658], # Right double arrow.
208
- [/<-->/u, 8596], # Horizontal single arrow.
209
- [/<==>/u, 8660], # Horizontal double arrow.
210
- [/<~~/u, 8668], # Left squiggle arrow.
211
- [/~~>/u, 8669], # Right squiggle arrow.
212
- [/<<--/u, 8606], # Left two headed arrow.
213
- [/-->>/u, 8608], # Right two headed arrow.
214
- [/<--</u, 8610], # Left arrow with tail.
215
- [/>-->/u, 8611], # Right arrow with tail.
216
- [/\|<--/u, 8676], # Left arrow to bar.
217
- [/-->\|/u, 8677], # Right arrow to bar.
218
- [/<---/u, 10229], # Left long single arrow.
219
- [/<===/u, 10232], # Left long double arrow.
220
- [/--->/u, 10230], # Right long single arrow.
221
- [/===>/u, 10233], # Right long double arrow.
222
- [/<--->/u, 10231], # Horizontal long single arrow.
223
- [/<===>/u, 10234], # Horizontal long double arrow.
224
- [/<---\|/u, 10235], # Left long single arrow from bar.
225
- [/<===\|/u, 10237], # Left long double arrow from bar.
226
- [/\|--->/u, 10236], # Right long single arrow from bar.
227
- [/\|===>/u, 10238], # Right long double arrow from bar.
228
- [/<-\/-/u, 8602], # Left single arrow with stroke.
229
- [/<=\/=/u, 8653], # Left double arrow with stroke.
230
- [/<-\|-/u, 8695], # Left single arrow with vertical bar.
231
- [/<=\|=/u, 10498], # Left double arrow with vertical bar.
232
- [/-\/->/u, 8603], # Right single arrow with stroke.
233
- [/=\/=>/u, 8655], # Right double arrow with stroke.
234
- [/-\|->/u, 8696], # Right single arrow with vertical bar.
235
- [/=\|=>/u, 10499], # Right double arrow with vertical bar.
236
- [/<-\/->/u, 8622], # Horizontal single arrow with stroke.
237
- [/<-\|->/u, 8697], # Horizontal single arrow with vertical bar.
238
- [/<=\|=>/u, 10500], # Horizontal double arrow with vertical bar.
239
- [/<--\|/u, 8612], # Left single arrow from bar.
240
- [/<==\|/u, 10502], # Left double arrow from bar.
241
- [/\|-->/u, 8614], # Right single arrow from bar.
242
- [/\|==>/u, 10503] # Right double arrow from bar.
243
- ]
244
-
245
- # Base-2 digit sequence for C++ int literal.
246
- CPP_INT_DIGITS_2 = /0[Bb][0-1]+/
247
-
248
- # Base-8 digit sequence for C++ int literal.
249
- CPP_INT_DIGITS_8 = /0[0-7]+/
250
-
251
- # Base-10 digit sequence for C++ int literal.
252
- CPP_INT_DIGITS_10 = /[1-9][0-9]*|0(?![0-9])/
253
-
254
- # Base-16 digit sequence for C++ int literal.
255
- CPP_INT_DIGITS_16 = /0[Xx][0-9A-Fa-f]+/
256
-
257
- # Digit sequence for C++ int literal.
258
- CPP_INT_DIGITS = Regexp.union [
259
- CPP_INT_DIGITS_2,
260
- CPP_INT_DIGITS_8,
261
- CPP_INT_DIGITS_10,
262
- CPP_INT_DIGITS_16
188
+ [/\(tm\)/ui, 8482], # Trademark.
189
+ [/\(c\)/ui, 9400], # Copyright.
190
+ [/\(r\)/ui, 174], # Registered.
191
+ [/\+-/u, 177], # Plus minus.
192
+ [/==/u, 8801], # Identical.
193
+ [/=~/u, 8773], # Congruent.
194
+ [/!=/u, 8800], # Not equal.
195
+ [/<=/u, 8804], # Less equal.
196
+ [/>=/u, 8805], # Greater equal.
197
+ [/~=/u, 8776], # Approximately.
198
+ [/--/u, 8211], # En dash.
199
+ [/---/u, 8212], # Em dash.
200
+ [/\.{3}/u, 8230], # Ellipsis.
201
+ [/<--/u, 8592], # Left single arrow.
202
+ [/<==/u, 8656], # Left double arrow.
203
+ [/-->/u, 8594], # Right single arrow.
204
+ [/==>/u, 8658], # Right double arrow.
205
+ [/<-->/u, 8596], # Horizontal single arrow.
206
+ [/<==>/u, 8660], # Horizontal double arrow.
207
+ [/<~~/u, 8668], # Left squiggle arrow.
208
+ [/~~>/u, 8669], # Right squiggle arrow.
209
+ [/<<--/u, 8606], # Left two headed arrow.
210
+ [/-->>/u, 8608], # Right two headed arrow.
211
+ [/<--</u, 8610], # Left arrow with tail.
212
+ [/>-->/u, 8611], # Right arrow with tail.
213
+ [/\|<--/u, 8676], # Left arrow to bar.
214
+ [/-->\|/u, 8677], # Right arrow to bar.
215
+ [/<---/u, 10229], # Left long single arrow.
216
+ [/<===/u, 10232], # Left long double arrow.
217
+ [/--->/u, 10230], # Right long single arrow.
218
+ [/===>/u, 10233], # Right long double arrow.
219
+ [/<--->/u, 10231], # Horizontal long single arrow.
220
+ [/<===>/u, 10234], # Horizontal long double arrow.
221
+ [/<---\|/u, 10235], # Left long single arrow from bar.
222
+ [/<===\|/u, 10237], # Left long double arrow from bar.
223
+ [/\|--->/u, 10236], # Right long single arrow from bar.
224
+ [/\|===>/u, 10238], # Right long double arrow from bar.
225
+ [/<-\/-/u, 8602], # Left single arrow with stroke.
226
+ [/<=\/=/u, 8653], # Left double arrow with stroke.
227
+ [/<-\|-/u, 8695], # Left single arrow with vertical bar.
228
+ [/<=\|=/u, 10498], # Left double arrow with vertical bar.
229
+ [/-\/->/u, 8603], # Right single arrow with stroke.
230
+ [/=\/=>/u, 8655], # Right double arrow with stroke.
231
+ [/-\|->/u, 8696], # Right single arrow with vertical bar.
232
+ [/=\|=>/u, 10499], # Right double arrow with vertical bar.
233
+ [/<-\/->/u, 8622], # Horizontal single arrow with stroke.
234
+ [/<-\|->/u, 8697], # Horizontal single arrow with vertical bar.
235
+ [/<=\|=>/u, 10500], # Horizontal double arrow with vertical bar.
236
+ [/<--\|/u, 8612], # Left single arrow from bar.
237
+ [/<==\|/u, 10502], # Left double arrow from bar.
238
+ [/\|-->/u, 8614], # Right single arrow from bar.
239
+ [/\|==>/u, 10503] # Right double arrow from bar.
263
240
  ]
264
241
 
265
- # C++ int literal.
266
- CPP_INT = /#{CPP_INT_DIGITS}(?:[Uu][Ll]{0,2}|[Ll]{1,2}|_[0-9A-Za-z_]+)?/
267
-
268
- # Base-10 digit sequence for C++ float literal.
269
- CPP_FLT_DIGITS_10 = /(?:\.[0-9]+|[0-9]+\.[0-9]*|[0-9]+(?=[Ee]))(?:[Ee][+-]?[0-9]+)?/
270
-
271
- # Base-16 digit sequence for C++ float literal.
272
- CPP_FLT_DIGITS_16 = /(?:0[Xx]1\.[0-9A-Fa-f]+[Pp][+-][0-9]+)/
273
-
274
- # Digit sequence for C++ float literal.
275
- CPP_FLT_DIGITS = Regexp.union [
276
- CPP_FLT_DIGITS_10,
277
- CPP_FLT_DIGITS_16
278
- ]
279
-
280
- # C++ float literal.
281
- CPP_FLT = /#{CPP_FLT_DIGITS}(?:[Ii]?[FfLl]|_[A-Za-z0-9_]+)?/
282
-
283
- # C++ int or float literal.
284
- CPP_NUMBER = /[+-]?(?:#{CPP_FLT}|#{CPP_INT})/
242
+ # C++ string.
243
+ HICPPSTR = /(?:u8?|[ULR])?(["'])((?:[^\\\1]*(?:\\.)*)*)\1/u
285
244
 
286
- # C++ char or string literal.
287
- CPP_STRING = /(?:u8?|[ULR])?(["'])((?:[^\\\1]*(?:\\.)*)*)\1/u
245
+ # C++ number.
246
+ HICPPNUM = /[+-]?(?:(?:(?:(?:\.\d+|\d+\.\d*|\d+(?=e))(?:e[+-]?\d+)?)|0x1\.\h+p[+-]\d+)(?:i?[fl]|_\w+)?|(?:0b[01]+|0[0-7]+|[1-9]\d*|0(?!\d)|0x\h+)(?:ul?l?|ll?|_\w+)?)/i
288
247
 
289
- # C++ highlighting table.
290
- HIGHLIGHT_CPP = [
248
+ # C++ syntax highlighting.
249
+ HICPP = [
291
250
  ["hi-comment", /\/\/.*$/u],
292
251
  ["hi-comment", /\/\*.*?\*\//um],
293
252
  ["hi-preproc", /\#(?:ifn?def|endif|if|else|elif|define|pragma|include)\b.*?(?<=[^\\])(?:\n|\z)/um],
@@ -296,7 +255,7 @@ module Schizm
296
255
  ["hi-type-spec", /(?:constexpr|const|volatile|static|mutable|thread_local|register|extern|inline|noexcept)\b/u],
297
256
  ["hi-flow", /(?:new|delete|do|while|for|if|else|try|throw|catch|switch|case|default|break|continue|goto|return)\b/u],
298
257
  ["hi-op", /(?:(?:and|or|xor|not)(?:_eq)?|bitand|bitor|compl|(?:(?:const|dynamic|static|reinterpret)_cast))\b/u],
299
- ["hi-value", /(?:true|false|this|nullptr|NULL|#{CPP_NUMBER}|#{CPP_STRING})\b/u],
258
+ ["hi-value", /(?:true|false|this|nullptr|NULL|#{HICPPSTR}|#{HICPPNUM})\b/u],
300
259
  ["hi-other", /(?:alignas|alignof|sizeof|decltype|template|typename|typedef|using|concept|requires|operator)\b/u],
301
260
  ["hi-other", /(?:namespace|class|struct|enum|public|protected|private|friend|final|virtual|override)\b/u],
302
261
  ["hi-ident", /[a-zA-Z]\w*/u],
data/lib/schizm/parse.rb CHANGED
@@ -93,7 +93,7 @@ module Parse
93
93
  Chunk.each do |chunk|
94
94
  if chunk.label == @label and
95
95
  (chunk.where == @where or chunk.share?)
96
- return "#{Env.path_href(@where)}\##{chunk.id(1)}"
96
+ return "#{Env.docs_path(@where)}\##{chunk.id(1)}"
97
97
  end
98
98
  end
99
99
  return ""
@@ -108,7 +108,7 @@ module Parse
108
108
  def to_s
109
109
  return "" if @index < 1
110
110
  return "" if @index > @chunk.blocks.size
111
- return "#{Env.path_href(@chunk.where)}\##{@chunk.id(@index)}"
111
+ return "#{Env.docs_path(@chunk.where)}\##{@chunk.id(@index)}"
112
112
  end
113
113
  end
114
114
 
@@ -304,12 +304,6 @@ module Parse
304
304
  when "Local" then chunk.share = false
305
305
  else raise "Unknown attribute."
306
306
  end
307
- =begin
308
- when sscan.skip(/[ ]*\#=[ ]*(.*?)\n/u)
309
- sscan[1].split(' ').each_with_index do |param, index|
310
- chunk.params[param][:index] = index
311
- end
312
- =end
313
307
  when sscan.skip(/[ ]*\+=[ ]*(?:#{CHUNK_BLOCK})?\n/u)
314
308
  label = sscan[1]
315
309
  block = sscan.scan_until(END_INDENT)
@@ -348,7 +342,7 @@ module Parse
348
342
  ]),
349
343
  Markup.new("div")
350
344
  .add_attrs("class" => "panel-body")
351
- .add_elems(Markup.new("pre").add_elems(highlight(where, block, HIGHLIGHT_CPP)))
345
+ .add_elems(Markup.new("pre").add_elems(highlight(where, block, HICPP)))
352
346
  ])
353
347
  end
354
348
  div
@@ -0,0 +1,2 @@
1
+ autocmd BufNewFile,BufRead *.zrc setfiletype schizm
2
+ autocmd BufNewFile,BufRead *.schizm setfiletype schizm
@@ -0,0 +1,2 @@
1
+ setlocal tabstop=4 shiftwidth=4
2
+ setlocal expandtab
File without changes
@@ -0,0 +1,48 @@
1
+ syn match zrcBlkSec /\v^[ ]*[!?~>][ ]{3}/
2
+ syn match zrcBlkSec /\v^[ ]*\-{3,}[ ]*$/
3
+ syn match zrcBlkSec /\v^[ ]*\={3,}[ ]*$/
4
+ syn match zrcBlkSec /\v^%([ ]{4})*[#]{1,6}/
5
+ syn match zrcBlkFmt /\v^%([ ]{4})*[-][ ]{3}/
6
+ syn match zrcBlkFmt /\v^%([ ]{4})*%(\d\.[ ]{2}|\d{2}\.[ ])/
7
+ syn match zrcBlkFmt /\v^%([ ]{4})*\[[ x]\][ ]/
8
+ syn match zrcBlkFmt /\v^[ ]*%(\*[ ]?){3,}[ ]*$/
9
+ syn match zrcBlkFmt /\v^[ ]*\^[ ]*$/
10
+ hi link zrcBlkSec PreProc
11
+ hi link zrcBlkFmt Delimiter
12
+ syn cluster zrcInl contains=zrcInlScr,zrcInlIns,zrcInlDel,zrcInlMath,zrcInlCode,zrcInlEmph,zrcInlBold,zrcInlBoldEmph,zrcInlSym,zrcInlEsc
13
+ syn region zrcInlIns matchgroup=Delimiter start=/\v[+]\{/ end=/\v\}/ contains=@zrcInl
14
+ syn region zrcInlDel matchgroup=Delimiter start=/\v[-]\{/ end=/\v\}/ contains=@zrcInl
15
+ syn region zrcInlScr matchgroup=Delimiter start=/\v[_^]\{/ end=/\v\}/ contains=@zrcInl
16
+ syn region zrcInlMath matchgroup=Delimiter start=/\v\$\$?/ end=/\v\$+/ contains=zrcInlEsc
17
+ syn region zrcInlCode matchgroup=Delimiter start=/\v\`/ end=/\v\`/ contains=zrcInlEsc
18
+ syn region zrcInlEmph matchgroup=Delimiter start=/\v\*/ end=/\v\*+/ contains=zrcInlEsc
19
+ syn region zrcInlBold matchgroup=Delimiter start=/\v\*{2}/ end=/\v\*+/ contains=zrcInlEsc
20
+ syn region zrcInlBoldEmph matchgroup=Delimiter start=/\v\*{3,}/ end=/\v\*+/ contains=zrcInlEsc
21
+ syn match zrcInlSym /\v\&%(\w+|\#\d+|\#[xX][0-9a-fA-F]+);/
22
+ syn match zrcInlEsc /\v\\./
23
+ hi zrcInlIns gui=underline
24
+ hi link zrcInlDel Ignore
25
+ hi link zrcInlMath Statement
26
+ hi link zrcInlCode Structure
27
+ hi zrcInlEmph gui=italic
28
+ hi zrcInlBold gui=bold
29
+ hi zrcInlBoldEmph gui=bold,italic
30
+ hi link zrcInlSym Constant
31
+ hi link zrcInlEsc SpecialChar
32
+ syn match zrcDef /\v^\&:\[[^\]]+\].*$/
33
+ syn match zrcDef /\v^\!:\[[^\]]+\].*$/
34
+ syn region zrcRef matchgroup=Macro start=/\v\&\[/ end=/\v\]/ contains=@zrcInl nextgroup=zrcRefArg
35
+ syn region zrcRef matchgroup=Macro start=/\v\!\[/ end=/\v\]/ contains=@zrcInl nextgroup=zrcRefArg
36
+ syn region zrcRefArg matchgroup=Macro start=/\v\[/ end=/\v\]/ contains=zrcInlEsc contained
37
+ syn region zrcRefArg matchgroup=Macro start=/\v\(/ end=/\v\)/ contains=zrcInlEsc contained
38
+ hi link zrcDef Comment
39
+ hi link zrcRefArg Macro
40
+ syn region zrcChkRef matchgroup=Operator start=/\v\@\[/ end=/\v\]/ contains=@zrcInl
41
+ syn region zrcChkRefCmd matchgroup=Operator start=/\v^%([ ]{4})*\@\[/ end=/\v\]/ contains=@zrcInl nextgroup=zrcChkCmd skipwhite
42
+ syn region zrcChkCmd matchgroup=Operator start=/\v\:\:/ end=/\v$/ oneline contained contains=zrcChkAtt
43
+ syn region zrcChkCmd matchgroup=Operator start=/\v\-\>/ end=/\v$/ oneline contained
44
+ syn region zrcChkCmd matchgroup=Operator start=/\v\+\=/ end=/\v^[ ]*\^[ ]*$/ contained contains=zrcChkRef
45
+ syn keyword zrcChkAtt Local contained
46
+ syn keyword zrcChkAtt Share contained
47
+ hi link zrcChkCmd String
48
+ hi link zrcChkAtt Identifier
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schizm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Grady Saunders
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2018-02-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: mgradysaunders@gmail.com
@@ -54,6 +54,10 @@ files:
54
54
  - res/scss/fonts.scss
55
55
  - res/scss/mixin.scss
56
56
  - res/scss/style.scss
57
+ - res/vim/ftdetect/schizm.vim
58
+ - res/vim/ftplugin/schizm.vim
59
+ - res/vim/indent/schizm.vim
60
+ - res/vim/syntax/schizm.vim
57
61
  homepage: https://github.com/mgradysaunders/schizm
58
62
  licenses:
59
63
  - BSD-2-Clause
@@ -74,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
78
  version: '0'
75
79
  requirements: []
76
80
  rubyforge_project:
77
- rubygems_version: 2.5.1
81
+ rubygems_version: 2.5.2.1
78
82
  signing_key:
79
83
  specification_version: 4
80
84
  summary: A literate programming tool for C/C++