rabbit 3.0.2 → 3.0.4

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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +31 -0
  3. data/Rakefile +51 -73
  4. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  5. data/doc/_config.yml +2 -2
  6. data/doc/en/how-to-make/markdown.md +28 -2
  7. data/doc/en/how-to-make/rd.rd +28 -2
  8. data/doc/en/install/homebrew.rd +0 -15
  9. data/doc/en/news.rd +83 -0
  10. data/doc/en/sample/hiki/rabbit.hiki +1 -1
  11. data/doc/en/sample/markdown/rabbit.md +1 -1
  12. data/doc/en/sample/rd/rabbit.rd +1 -1
  13. data/doc/en/usage/rabbit-slide.rd +1 -1
  14. data/doc/en/usage/rabbit.rd +1 -1
  15. data/doc/ja/how-to-make/markdown.md +25 -5
  16. data/doc/ja/how-to-make/rd.rd +25 -5
  17. data/doc/ja/install/homebrew.rd +0 -15
  18. data/doc/ja/news.rd +83 -0
  19. data/doc/ja/usage/rabbit.rd +1 -1
  20. data/lib/rabbit/action.rb +1 -23
  21. data/lib/rabbit/canvas.rb +2 -10
  22. data/lib/rabbit/command/rabbit-slide.rb +1 -1
  23. data/lib/rabbit/command/rabbit.rb +6 -4
  24. data/lib/rabbit/cursor-manager.rb +5 -5
  25. data/lib/rabbit/element/text.rb +66 -0
  26. data/lib/rabbit/error.rb +9 -1
  27. data/lib/rabbit/frame.rb +22 -2
  28. data/lib/rabbit/front.rb +1 -1
  29. data/lib/rabbit/gesture/handler.rb +5 -8
  30. data/lib/rabbit/gtk.rb +44 -2
  31. data/lib/rabbit/image/mermaid.rb +3 -2
  32. data/lib/rabbit/info-window.rb +16 -2
  33. data/lib/rabbit/menu.rb +1 -3
  34. data/lib/rabbit/parser/ext/charty.rb +9 -0
  35. data/lib/rabbit/parser/markdown/converter.rb +3 -3
  36. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +0 -12
  37. data/lib/rabbit/parser/rd/ext/inline-verbatim.rb +23 -0
  38. data/lib/rabbit/parser/wiki/output.rb +0 -6
  39. data/lib/rabbit/renderer/base.rb +1 -9
  40. data/lib/rabbit/renderer/display/base.rb +7 -5
  41. data/lib/rabbit/renderer/display/button-handler.rb +25 -10
  42. data/lib/rabbit/renderer/display/cursor.rb +18 -2
  43. data/lib/rabbit/renderer/display/drawing-area-base.rb +23 -7
  44. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +35 -20
  45. data/lib/rabbit/renderer/display/gesture.rb +17 -1
  46. data/lib/rabbit/renderer/engine/cairo.rb +27 -13
  47. data/lib/rabbit/renderer/gl.rb +0 -81
  48. data/lib/rabbit/renderer/kernel.rb +0 -50
  49. data/lib/rabbit/renderer/offscreen.rb +1 -6
  50. data/lib/rabbit/renderer/printer.rb +2 -8
  51. data/lib/rabbit/renderer/screen.rb +6 -7
  52. data/lib/rabbit/source/argf.rb +17 -1
  53. data/lib/rabbit/source/base.rb +35 -10
  54. data/lib/rabbit/source/file.rb +17 -1
  55. data/lib/rabbit/source/uri.rb +17 -1
  56. data/lib/rabbit/theme/dark-gradation/dark-gradation.rb +2 -2
  57. data/lib/rabbit/theme/default-comment/default-comment.rb +1 -5
  58. data/lib/rabbit/theme/image-slide-number/property.rb +1 -1
  59. data/lib/rabbit/theme/title-background-image/title-background-image.rb +2 -2
  60. data/lib/rabbit/trackball.rb +21 -21
  61. data/lib/rabbit/utils.rb +5 -45
  62. data/lib/rabbit/version.rb +2 -2
  63. data/lib/rabbit/video-window.rb +6 -2
  64. data/po/en/rabbit.edit.po +27 -45
  65. data/po/en/rabbit.po +9 -24
  66. data/po/fr/rabbit.edit.po +27 -45
  67. data/po/fr/rabbit.po +9 -24
  68. data/po/ja/rabbit.edit.po +59 -71
  69. data/po/ja/rabbit.po +12 -24
  70. data/rabbit.gemspec +11 -14
  71. data/sample/gl-sample.rd +2 -4
  72. data/sample/rabbit/theme/gl-sample/gl-sample.rb +1 -1
  73. data/sample/rabbit-en.hiki +1 -1
  74. data/sample/rabbit-en.md +1 -1
  75. data/sample/rabbit-en.rd +1 -13
  76. data/sample/rabbit.rd +1 -13
  77. data/test/helper.rb +1 -2
  78. data/test/parser/test-markdown.rb +4 -3
  79. data/test/parser/test-rd.rb +3 -3
  80. data/test/parser/test-wiki.rb +2 -2
  81. data/test/test-readme-parser.rb +15 -12
  82. data/test/test-source.rb +2 -2
  83. metadata +35 -122
  84. data/doc/images/screenshots/en/blue-circle-raw.png +0 -0
  85. data/doc/images/screenshots/en/blue-circle.png +0 -0
  86. data/doc/images/screenshots/en/clear-blue-raw.png +0 -0
  87. data/doc/images/screenshots/en/clear-blue.png +0 -0
  88. data/doc/images/screenshots/en/cozmixng-raw.png +0 -0
  89. data/doc/images/screenshots/en/cozmixng.png +0 -0
  90. data/doc/images/screenshots/en/dark-gradation-raw.png +0 -0
  91. data/doc/images/screenshots/en/dark-gradation.png +0 -0
  92. data/doc/images/screenshots/en/day-white-raw.png +0 -0
  93. data/doc/images/screenshots/en/day-white.png +0 -0
  94. data/doc/images/screenshots/en/debian-raw.png +0 -0
  95. data/doc/images/screenshots/en/debian.png +0 -0
  96. data/doc/images/screenshots/en/green-circle-raw.png +0 -0
  97. data/doc/images/screenshots/en/green-circle.png +0 -0
  98. data/doc/images/screenshots/en/night-black-raw.png +0 -0
  99. data/doc/images/screenshots/en/night-black.png +0 -0
  100. data/doc/images/screenshots/en/rabbit-raw.png +0 -0
  101. data/doc/images/screenshots/en/rabbit.png +0 -0
  102. data/doc/images/screenshots/en/ranguba-raw.png +0 -0
  103. data/doc/images/screenshots/en/ranguba.png +0 -0
  104. data/doc/images/screenshots/en/red-frame-raw.png +0 -0
  105. data/doc/images/screenshots/en/red-frame.png +0 -0
  106. data/doc/images/screenshots/en/ruby-gnome2-raw.png +0 -0
  107. data/doc/images/screenshots/en/ruby-gnome2.png +0 -0
  108. data/doc/images/screenshots/en/rubykaigi2011-raw.png +0 -0
  109. data/doc/images/screenshots/en/rubykaigi2011.png +0 -0
  110. data/doc/images/screenshots/ja/blue-circle-raw.png +0 -0
  111. data/doc/images/screenshots/ja/blue-circle.png +0 -0
  112. data/doc/images/screenshots/ja/clear-blue-raw.png +0 -0
  113. data/doc/images/screenshots/ja/clear-blue.png +0 -0
  114. data/doc/images/screenshots/ja/cozmixng-raw.png +0 -0
  115. data/doc/images/screenshots/ja/cozmixng.png +0 -0
  116. data/doc/images/screenshots/ja/dark-gradation-raw.png +0 -0
  117. data/doc/images/screenshots/ja/dark-gradation.png +0 -0
  118. data/doc/images/screenshots/ja/day-white-raw.png +0 -0
  119. data/doc/images/screenshots/ja/day-white.png +0 -0
  120. data/doc/images/screenshots/ja/debian-raw.png +0 -0
  121. data/doc/images/screenshots/ja/debian.png +0 -0
  122. data/doc/images/screenshots/ja/green-circle-raw.png +0 -0
  123. data/doc/images/screenshots/ja/green-circle.png +0 -0
  124. data/doc/images/screenshots/ja/night-black-raw.png +0 -0
  125. data/doc/images/screenshots/ja/night-black.png +0 -0
  126. data/doc/images/screenshots/ja/rabbit-raw.png +0 -0
  127. data/doc/images/screenshots/ja/rabbit.png +0 -0
  128. data/doc/images/screenshots/ja/ranguba-raw.png +0 -0
  129. data/doc/images/screenshots/ja/ranguba.png +0 -0
  130. data/doc/images/screenshots/ja/red-frame-raw.png +0 -0
  131. data/doc/images/screenshots/ja/red-frame.png +0 -0
  132. data/doc/images/screenshots/ja/ruby-gnome2-raw.png +0 -0
  133. data/doc/images/screenshots/ja/ruby-gnome2.png +0 -0
  134. data/doc/images/screenshots/ja/rubykaigi2011-raw.png +0 -0
  135. data/doc/images/screenshots/ja/rubykaigi2011.png +0 -0
  136. data/lib/rabbit/parser/ext/emacs.rb +0 -121
  137. data/lib/rabbit/renderer/display/clutter-embed.rb +0 -606
  138. data/lib/rabbit/theme/clutter-comment/clutter-comment.rb +0 -76
  139. data/lib/rabbit/theme/clutter-comment/property.rb +0 -3
metadata CHANGED
@@ -1,31 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-06-25 00:00:00.000000000 Z
10
+ date: 2025-03-23 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: gdk_pixbuf2
13
+ name: coderay
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 3.0.9
18
+ version: 1.0.0
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 3.0.9
25
+ version: 1.0.0
27
26
  - !ruby/object:Gem::Dependency
28
- name: gtk3
27
+ name: csv
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
@@ -39,49 +38,49 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rsvg2
41
+ name: drb
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
46
45
  - !ruby/object:Gem::Version
47
- version: 3.1.4
46
+ version: '0'
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - ">="
53
52
  - !ruby/object:Gem::Version
54
- version: 3.1.4
53
+ version: '0'
55
54
  - !ruby/object:Gem::Dependency
56
- name: poppler
55
+ name: gdk_pixbuf2
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ">="
60
59
  - !ruby/object:Gem::Version
61
- version: 3.2.5
60
+ version: 3.0.9
62
61
  type: :runtime
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - ">="
67
66
  - !ruby/object:Gem::Version
68
- version: 3.2.5
67
+ version: 3.0.9
69
68
  - !ruby/object:Gem::Dependency
70
- name: hikidoc
69
+ name: gettext
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - ">="
74
73
  - !ruby/object:Gem::Version
75
- version: '0'
74
+ version: 3.0.1
76
75
  type: :runtime
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - ">="
81
80
  - !ruby/object:Gem::Version
82
- version: '0'
81
+ version: 3.0.1
83
82
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
83
+ name: gtk3
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
@@ -95,7 +94,7 @@ dependencies:
95
94
  - !ruby/object:Gem::Version
96
95
  version: '0'
97
96
  - !ruby/object:Gem::Dependency
98
- name: rdtool
97
+ name: hikidoc
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
@@ -109,7 +108,7 @@ dependencies:
109
108
  - !ruby/object:Gem::Version
110
109
  version: '0'
111
110
  - !ruby/object:Gem::Dependency
112
- name: rttool
111
+ name: kramdown-parser-gfm
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - ">="
@@ -123,21 +122,7 @@ dependencies:
123
122
  - !ruby/object:Gem::Version
124
123
  version: '0'
125
124
  - !ruby/object:Gem::Dependency
126
- name: coderay
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 1.0.0
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 1.0.0
139
- - !ruby/object:Gem::Dependency
140
- name: kramdown-parser-gfm
125
+ name: nokogiri
141
126
  requirement: !ruby/object:Gem::Requirement
142
127
  requirements:
143
128
  - - ">="
@@ -151,21 +136,7 @@ dependencies:
151
136
  - !ruby/object:Gem::Version
152
137
  version: '0'
153
138
  - !ruby/object:Gem::Dependency
154
- name: gettext
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: 3.0.1
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: 3.0.1
167
- - !ruby/object:Gem::Dependency
168
- name: rouge
139
+ name: ostruct
169
140
  requirement: !ruby/object:Gem::Requirement
170
141
  requirements:
171
142
  - - ">="
@@ -179,27 +150,27 @@ dependencies:
179
150
  - !ruby/object:Gem::Version
180
151
  version: '0'
181
152
  - !ruby/object:Gem::Dependency
182
- name: test-unit
153
+ name: poppler
183
154
  requirement: !ruby/object:Gem::Requirement
184
155
  requirements:
185
156
  - - ">="
186
157
  - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
158
+ version: 3.2.5
159
+ type: :runtime
189
160
  prerelease: false
190
161
  version_requirements: !ruby/object:Gem::Requirement
191
162
  requirements:
192
163
  - - ">="
193
164
  - !ruby/object:Gem::Version
194
- version: '0'
165
+ version: 3.2.5
195
166
  - !ruby/object:Gem::Dependency
196
- name: test-unit-rr
167
+ name: rdtool
197
168
  requirement: !ruby/object:Gem::Requirement
198
169
  requirements:
199
170
  - - ">="
200
171
  - !ruby/object:Gem::Version
201
172
  version: '0'
202
- type: :development
173
+ type: :runtime
203
174
  prerelease: false
204
175
  version_requirements: !ruby/object:Gem::Requirement
205
176
  requirements:
@@ -207,13 +178,13 @@ dependencies:
207
178
  - !ruby/object:Gem::Version
208
179
  version: '0'
209
180
  - !ruby/object:Gem::Dependency
210
- name: rake
181
+ name: rouge
211
182
  requirement: !ruby/object:Gem::Requirement
212
183
  requirements:
213
184
  - - ">="
214
185
  - !ruby/object:Gem::Version
215
186
  version: '0'
216
- type: :development
187
+ type: :runtime
217
188
  prerelease: false
218
189
  version_requirements: !ruby/object:Gem::Requirement
219
190
  requirements:
@@ -221,27 +192,27 @@ dependencies:
221
192
  - !ruby/object:Gem::Version
222
193
  version: '0'
223
194
  - !ruby/object:Gem::Dependency
224
- name: bundler
195
+ name: rsvg2
225
196
  requirement: !ruby/object:Gem::Requirement
226
197
  requirements:
227
198
  - - ">="
228
199
  - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
200
+ version: 3.1.4
201
+ type: :runtime
231
202
  prerelease: false
232
203
  version_requirements: !ruby/object:Gem::Requirement
233
204
  requirements:
234
205
  - - ">="
235
206
  - !ruby/object:Gem::Version
236
- version: '0'
207
+ version: 3.1.4
237
208
  - !ruby/object:Gem::Dependency
238
- name: jekyll
209
+ name: rttool
239
210
  requirement: !ruby/object:Gem::Requirement
240
211
  requirements:
241
212
  - - ">="
242
213
  - !ruby/object:Gem::Version
243
214
  version: '0'
244
- type: :development
215
+ type: :runtime
245
216
  prerelease: false
246
217
  version_requirements: !ruby/object:Gem::Requirement
247
218
  requirements:
@@ -418,58 +389,6 @@ files:
418
389
  - doc/images/lavie.png
419
390
  - doc/images/rabbit-slide-show-logo.png
420
391
  - doc/images/rabbit-slide-show-logo.svg
421
- - doc/images/screenshots/en/blue-circle-raw.png
422
- - doc/images/screenshots/en/blue-circle.png
423
- - doc/images/screenshots/en/clear-blue-raw.png
424
- - doc/images/screenshots/en/clear-blue.png
425
- - doc/images/screenshots/en/cozmixng-raw.png
426
- - doc/images/screenshots/en/cozmixng.png
427
- - doc/images/screenshots/en/dark-gradation-raw.png
428
- - doc/images/screenshots/en/dark-gradation.png
429
- - doc/images/screenshots/en/day-white-raw.png
430
- - doc/images/screenshots/en/day-white.png
431
- - doc/images/screenshots/en/debian-raw.png
432
- - doc/images/screenshots/en/debian.png
433
- - doc/images/screenshots/en/green-circle-raw.png
434
- - doc/images/screenshots/en/green-circle.png
435
- - doc/images/screenshots/en/night-black-raw.png
436
- - doc/images/screenshots/en/night-black.png
437
- - doc/images/screenshots/en/rabbit-raw.png
438
- - doc/images/screenshots/en/rabbit.png
439
- - doc/images/screenshots/en/ranguba-raw.png
440
- - doc/images/screenshots/en/ranguba.png
441
- - doc/images/screenshots/en/red-frame-raw.png
442
- - doc/images/screenshots/en/red-frame.png
443
- - doc/images/screenshots/en/ruby-gnome2-raw.png
444
- - doc/images/screenshots/en/ruby-gnome2.png
445
- - doc/images/screenshots/en/rubykaigi2011-raw.png
446
- - doc/images/screenshots/en/rubykaigi2011.png
447
- - doc/images/screenshots/ja/blue-circle-raw.png
448
- - doc/images/screenshots/ja/blue-circle.png
449
- - doc/images/screenshots/ja/clear-blue-raw.png
450
- - doc/images/screenshots/ja/clear-blue.png
451
- - doc/images/screenshots/ja/cozmixng-raw.png
452
- - doc/images/screenshots/ja/cozmixng.png
453
- - doc/images/screenshots/ja/dark-gradation-raw.png
454
- - doc/images/screenshots/ja/dark-gradation.png
455
- - doc/images/screenshots/ja/day-white-raw.png
456
- - doc/images/screenshots/ja/day-white.png
457
- - doc/images/screenshots/ja/debian-raw.png
458
- - doc/images/screenshots/ja/debian.png
459
- - doc/images/screenshots/ja/green-circle-raw.png
460
- - doc/images/screenshots/ja/green-circle.png
461
- - doc/images/screenshots/ja/night-black-raw.png
462
- - doc/images/screenshots/ja/night-black.png
463
- - doc/images/screenshots/ja/rabbit-raw.png
464
- - doc/images/screenshots/ja/rabbit.png
465
- - doc/images/screenshots/ja/ranguba-raw.png
466
- - doc/images/screenshots/ja/ranguba.png
467
- - doc/images/screenshots/ja/red-frame-raw.png
468
- - doc/images/screenshots/ja/red-frame.png
469
- - doc/images/screenshots/ja/ruby-gnome2-raw.png
470
- - doc/images/screenshots/ja/ruby-gnome2.png
471
- - doc/images/screenshots/ja/rubykaigi2011-raw.png
472
- - doc/images/screenshots/ja/rubykaigi2011.png
473
392
  - doc/index.html.en
474
393
  - doc/index.html.ja
475
394
  - doc/ja/about.rd
@@ -609,7 +528,6 @@ files:
609
528
  - lib/rabbit/parser/ext/blockdiag.rb
610
529
  - lib/rabbit/parser/ext/charty.rb
611
530
  - lib/rabbit/parser/ext/coderay.rb
612
- - lib/rabbit/parser/ext/emacs.rb
613
531
  - lib/rabbit/parser/ext/enscript.rb
614
532
  - lib/rabbit/parser/ext/entity.rb
615
533
  - lib/rabbit/parser/ext/escape.rb
@@ -649,7 +567,6 @@ files:
649
567
  - lib/rabbit/renderer/display.rb
650
568
  - lib/rabbit/renderer/display/base.rb
651
569
  - lib/rabbit/renderer/display/button-handler.rb
652
- - lib/rabbit/renderer/display/clutter-embed.rb
653
570
  - lib/rabbit/renderer/display/cursor.rb
654
571
  - lib/rabbit/renderer/display/drawing-area-base.rb
655
572
  - lib/rabbit/renderer/display/drawing-area-primitive.rb
@@ -717,8 +634,6 @@ files:
717
634
  - lib/rabbit/theme/clear-blue/property.rb
718
635
  - lib/rabbit/theme/clock/clock.rb
719
636
  - lib/rabbit/theme/clock/property.rb
720
- - lib/rabbit/theme/clutter-comment/clutter-comment.rb
721
- - lib/rabbit/theme/clutter-comment/property.rb
722
637
  - lib/rabbit/theme/color-circle-block-quote/color-circle-block-quote.rb
723
638
  - lib/rabbit/theme/color-circle-block-quote/property.rb
724
639
  - lib/rabbit/theme/color-circle-common/color-circle-common.rb
@@ -1058,7 +973,6 @@ homepage: http://rabbit-shocker.org/
1058
973
  licenses:
1059
974
  - GPLv2+
1060
975
  metadata: {}
1061
- post_install_message:
1062
976
  rdoc_options: []
1063
977
  require_paths:
1064
978
  - lib
@@ -1073,8 +987,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1073
987
  - !ruby/object:Gem::Version
1074
988
  version: '0'
1075
989
  requirements: []
1076
- rubygems_version: 3.5.0.dev
1077
- signing_key:
990
+ rubygems_version: 3.6.2
1078
991
  specification_version: 4
1079
992
  summary: Rabbit is a presentation tool for Rubyist
1080
993
  test_files:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,121 +0,0 @@
1
- require 'rabbit/utils'
2
- require 'rabbit/parser/ext/escape'
3
-
4
- module Rabbit
5
- module Parser
6
- module Ext
7
- module Emacs
8
- include Element
9
- include GetText
10
-
11
- module_function
12
- def highlight(text, logger, mode_line=nil)
13
- begin
14
- require 'nokogiri'
15
- rescue
16
- logger.warning("Syntax highlight by Emacs requires nokogiri.")
17
- return nil
18
- end
19
-
20
- src_file = Tempfile.new("rabbit-emacs")
21
- src_file.open
22
- src_file.print("#{mode_line}\n") if mode_line
23
- src_file.print(text)
24
- src_file.close
25
- html_file = Tempfile.new("rabbit-emacs-html")
26
- args = [
27
- "--batch",
28
- "--eval",
29
- "(htmlize-file \"#{src_file.path}\" \"#{html_file.path}\")",
30
- ]
31
- if SystemRunner.run("emacs", *args)
32
- html_file.open
33
- html_to_rabbit(html_file.read, mode_line, logger)
34
- else
35
- nil
36
- end
37
- end
38
-
39
- def html_to_rabbit(html, mode_line, logger)
40
- html = remove_newline_around_pre(html)
41
- html = remove_mode_line(html, mode_line)
42
- node = Nokogiri::HTML(html)
43
- pre = find_element(node, "pre")
44
- address = find_element(node, "address")
45
- element = node_to_rabbit(pre, logger)
46
- if element
47
- logger.info(address.text) if address
48
- element
49
- else
50
- nil
51
- end
52
- end
53
-
54
- def remove_newline_around_pre(html)
55
- html = html.gsub(/<pre([^>]*)>\n/i, '<pre\1>')
56
- html.gsub(/\n<\/pre>/i, '</pre>')
57
- end
58
-
59
- def remove_mode_line(html, mode_line)
60
- return html if mode_line.nil?
61
- html.gsub(/<pre([^>]*)>([^\n]+\n)/i) do
62
- attributes = $1
63
- mode_line_html = $2
64
- mode_line_text = mode_line_html.gsub(/<.+?>/, '')
65
- if mode_line_text.strip == mode_line.strip
66
- "<pre#{attributes}>"
67
- else
68
- "<pre#{attributes}>#{mode_line_html}"
69
- end
70
- end
71
- end
72
-
73
- def find_element(node, name)
74
- node.css(name)[0]
75
- end
76
-
77
- def node_to_rabbit(node, logger)
78
- case node.name
79
- when "pre"
80
- element = SyntaxHighlightingBlock.new
81
- node.children.each do |child|
82
- if child.text?
83
- element << text_to_rabbit(child.text, "plain")
84
- else
85
- child_element = node_to_rabbit(child, logger)
86
- element << child_element unless child_element.nil?
87
- end
88
- end
89
- element
90
- when "span"
91
- p [node.text, node["class"]] if Utils.syntax_highlighting_debug?
92
- text_to_rabbit(node.text, normalize_class_name(node["class"]))
93
- else
94
- format = _("emacs: unsupported element name: %s")
95
- logger.warn(format % element.name)
96
- nil
97
- end
98
- end
99
-
100
- def normalize_class_name(name)
101
- case name
102
- when "comment-delimiter"
103
- "comment"
104
- when "keyword"
105
- "reserved"
106
- when "variable-name"
107
- "variable"
108
- else
109
- name
110
- end
111
- end
112
-
113
- def text_to_rabbit(text, type)
114
- escaped_text = Escape.escape_meta_character(text)
115
- text_element = SyntaxHighlightingText.new(Text.new(escaped_text))
116
- CustomTag.new("syntax-#{type}", text_element)
117
- end
118
- end
119
- end
120
- end
121
- end