rabbit 2.1.3 → 2.1.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.
- checksums.yaml +4 -4
- data/doc/_config.yml +2 -2
- data/doc/en/faq.rd +5 -5
- data/doc/en/install/windows.rd +4 -49
- data/doc/en/news.rd +96 -0
- data/doc/en/slides.rd +2 -0
- data/doc/en/usage/rabbit-slide.rd +1 -1
- data/doc/ja/faq.rd +37 -32
- data/doc/ja/how-to-make/theme.rd +50 -50
- data/doc/ja/index.rd +35 -35
- data/doc/ja/install/windows.rd +4 -46
- data/doc/ja/news.rd +127 -30
- data/doc/ja/sample/hiki/rabbit.hiki +4 -4
- data/doc/ja/usage/rabbit-slide.rd +8 -8
- data/doc/ja/usage/rabbit-theme.rd +7 -7
- data/doc/ja/usage/rabbit.rd +124 -124
- data/lib/rabbit/action/basic.rb +1 -1
- data/lib/rabbit/canvas.rb +19 -19
- data/lib/rabbit/command/rabbit-slide.rb +5 -4
- data/lib/rabbit/command/rabbit.rb +2 -1
- data/lib/rabbit/cursor-manager.rb +14 -14
- data/lib/rabbit/element/poppler-slide.rb +6 -0
- data/lib/rabbit/element/poppler-title-slide.rb +6 -0
- data/lib/rabbit/element/slide-element.rb +4 -0
- data/lib/rabbit/element/text-renderer.rb +1 -1
- data/lib/rabbit/formatter.rb +9 -9
- data/lib/rabbit/frame.rb +5 -5
- data/lib/rabbit/front.rb +2 -2
- data/lib/rabbit/graffiti/processor.rb +9 -9
- data/lib/rabbit/html/template.erb +1 -1
- data/lib/rabbit/image/default.rb +2 -2
- data/lib/rabbit/image/eps.rb +5 -5
- data/lib/rabbit/image/pdf.rb +1 -1
- data/lib/rabbit/image/svg.rb +1 -1
- data/lib/rabbit/logger/base.rb +5 -5
- data/lib/rabbit/logger/stderr.rb +4 -1
- data/lib/rabbit/menu.rb +4 -4
- data/lib/rabbit/parser/ext/aafigure.rb +6 -4
- data/lib/rabbit/parser/ext/blockdiag.rb +5 -3
- data/lib/rabbit/parser/ext/entity.rb +26 -26
- data/lib/rabbit/parser/markdown.rb +42 -0
- data/lib/rabbit/parser/markdown/converter.rb +115 -18
- data/lib/rabbit/parser/pdf.rb +1 -5
- data/lib/rabbit/parser/rd/rt/rt2rabbit-lib.rb +2 -2
- data/lib/rabbit/rabbit.rb +1 -1
- data/lib/rabbit/renderer/base.rb +15 -23
- data/lib/rabbit/renderer/color.rb +3 -3
- data/lib/rabbit/renderer/display/base.rb +81 -6
- data/lib/rabbit/renderer/display/clutter-embed.rb +1 -1
- data/lib/rabbit/renderer/display/drawing-area-base.rb +2 -2
- data/lib/rabbit/renderer/display/drawing-area-primitive.rb +1 -1
- data/lib/rabbit/renderer/engine/cairo.rb +1 -70
- data/lib/rabbit/renderer/kernel.rb +11 -19
- data/lib/rabbit/renderer/pixmap/base.rb +3 -3
- data/lib/rabbit/renderer/print/base.rb +5 -5
- data/lib/rabbit/renderer/print/cairo.rb +10 -17
- data/lib/rabbit/renderer/print/layout.rb +6 -6
- data/lib/rabbit/renderer/print/multiple.rb +11 -14
- data/lib/rabbit/size.rb +65 -0
- data/lib/rabbit/soap/driver.rb +1 -1
- data/lib/rabbit/soap/server.rb +1 -1
- data/lib/rabbit/source/argf.rb +4 -4
- data/lib/rabbit/source/base.rb +2 -1
- data/lib/rabbit/source/file.rb +8 -8
- data/lib/rabbit/source/hiki.rb +1 -1
- data/lib/rabbit/source/memory.rb +2 -2
- data/lib/rabbit/source/uri.rb +4 -2
- data/lib/rabbit/theme/applier.rb +1 -0
- data/lib/rabbit/theme/default-block-quote/default-block-quote.rb +3 -1
- data/lib/rabbit/theme/pdf/pdf.rb +12 -6
- data/lib/rabbit/utils.rb +6 -6
- data/lib/rabbit/version.rb +1 -1
- data/lib/rabbit/xmlrpc/server.rb +1 -1
- data/po/en/rabbit.edit.po +29 -30
- data/po/fr/rabbit.edit.po +29 -30
- data/po/ja/rabbit.edit.po +29 -29
- data/sample/rabbit-en.hiki +3 -3
- data/sample/rabbit-en.md +27 -8
- data/sample/rabbit-en.rd +2 -2
- data/sample/rabbit.hiki +3 -3
- data/sample/rabbit.md +27 -8
- data/sample/rabbit.rd +2 -2
- data/test/parser/test-markdown.rb +210 -6
- data/test/test-size.rb +152 -0
- data/test/test-source.rb +17 -0
- metadata +5 -2
data/lib/rabbit/image/default.rb
CHANGED
data/lib/rabbit/image/eps.rb
CHANGED
@@ -7,7 +7,7 @@ module Rabbit
|
|
7
7
|
class EPS < Base
|
8
8
|
|
9
9
|
unshift_loader(self)
|
10
|
-
|
10
|
+
|
11
11
|
GS_COMMANDS = %w(gs gswin32c)
|
12
12
|
|
13
13
|
include SystemRunner
|
@@ -45,15 +45,15 @@ module Rabbit
|
|
45
45
|
end
|
46
46
|
load_data(data)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def eps_to_png(width=nil, height=nil)
|
50
50
|
eps_to(width, height, "pngalpha")
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def eps_to_pnm(width=nil, height=nil)
|
54
54
|
eps_to(width, height, "pnm")
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def eps_to(width, height, device, *gs_options)
|
58
58
|
x, y, w, h, r = eps_size
|
59
59
|
resolution = (r || Canvas::INTERNAL_DPI).round
|
@@ -81,7 +81,7 @@ module Rabbit
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def eps_size
|
86
86
|
sx, sy, w, h, r = nil
|
87
87
|
File.read(@filename).split(/(?:\r\n?|\n)/).each do |line|
|
data/lib/rabbit/image/pdf.rb
CHANGED
data/lib/rabbit/image/svg.rb
CHANGED
data/lib/rabbit/logger/base.rb
CHANGED
@@ -50,18 +50,18 @@ module Rabbit
|
|
50
50
|
@prog_name = prog_name
|
51
51
|
@webrick_mode = false
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def debug?; @level <= Severity::DEBUG; end
|
55
55
|
def info?; @level <= Severity::INFO; end
|
56
56
|
def warning?; @level <= Severity::WARNING; end
|
57
57
|
def error?; @level <= Severity::ERROR; end
|
58
58
|
def fatal?; @level <= Severity::FATAL; end
|
59
59
|
def unknown?; @level <= Severity::UNKNOWN; end
|
60
|
-
|
60
|
+
|
61
61
|
def debug(message_or_error=nil, &block)
|
62
62
|
log(Severity::DEBUG, message_or_error, &block)
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def info(message_or_error=nil, &block)
|
66
66
|
log(Severity::INFO, message_or_error, &block)
|
67
67
|
end
|
@@ -78,7 +78,7 @@ module Rabbit
|
|
78
78
|
def fatal(message_or_error=nil, &block)
|
79
79
|
log(Severity::FATAL, message_or_error, &block)
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def unknown(message_or_error=nil, &block)
|
83
83
|
log(Severity::UNKNOWN, message_or_error, &block)
|
84
84
|
end
|
@@ -86,7 +86,7 @@ module Rabbit
|
|
86
86
|
def <<(message_or_error)
|
87
87
|
info(message_or_error)
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
def log(severity, message_or_error, prog_name=nil, &block)
|
91
91
|
severity ||= Severity::UNKNOWN
|
92
92
|
prog_name ||= @prog_name
|
data/lib/rabbit/logger/stderr.rb
CHANGED
@@ -13,7 +13,10 @@ module Rabbit
|
|
13
13
|
message = message.encode("locale")
|
14
14
|
rescue EncodingError
|
15
15
|
format = _("can't convert to current locale from UTF-8: %s")
|
16
|
-
|
16
|
+
sanitized_message = message.encode(format.encoding,
|
17
|
+
:invalid => :replace,
|
18
|
+
:undef => :replace)
|
19
|
+
$stderr.puts(format % sanitized_message)
|
17
20
|
end
|
18
21
|
$stderr.puts(format_severity(severity))
|
19
22
|
$stderr.print("[#{prog_name}]: ") if prog_name
|
data/lib/rabbit/menu.rb
CHANGED
@@ -89,7 +89,7 @@ module Rabbit
|
|
89
89
|
action.name, Gtk::UIManager::AUTO, false)
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def update_ui
|
94
94
|
@merge_ui = @merge.add_ui(ui_xml)
|
95
95
|
@menu = @merge.get_widget("/popup")
|
@@ -101,13 +101,13 @@ module Rabbit
|
|
101
101
|
def update_theme_menu(canvas)
|
102
102
|
@merge.remove_ui(@theme_merge_id) if @theme_merge_id
|
103
103
|
@merge.remove_action_group(@theme_actions) if @theme_actions
|
104
|
-
|
104
|
+
|
105
105
|
@theme_merge_id = @merge.new_merge_id
|
106
106
|
@theme_actions = Gtk::ActionGroup.new("ThemeActions")
|
107
107
|
@merge.insert_action_group(@theme_actions, 0)
|
108
108
|
|
109
109
|
themes = Theme::Searcher.collect_theme
|
110
|
-
|
110
|
+
|
111
111
|
categories = themes.collect do |entry|
|
112
112
|
entry.category
|
113
113
|
end.uniq.sort_by {|cat| _(cat)}
|
@@ -220,7 +220,7 @@ module Rabbit
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
end
|
223
|
-
|
223
|
+
|
224
224
|
def items
|
225
225
|
[
|
226
226
|
[:item, "ToggleIndexMode"],
|
@@ -9,10 +9,12 @@ module Rabbit
|
|
9
9
|
"option"]
|
10
10
|
def make_image(path, prop, logger)
|
11
11
|
image_file = Tempfile.new("rabbit-image-aafigure")
|
12
|
-
command = [
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
command = [
|
13
|
+
"aafigure",
|
14
|
+
"--type", "svg",
|
15
|
+
"--encoding", "utf-8",
|
16
|
+
"--output", image_file.path,
|
17
|
+
]
|
16
18
|
aafigure_options = []
|
17
19
|
AVAILABLE_OPTIONS.each do |name|
|
18
20
|
command.concat(["--#{name}", prop[name]]) if prop.has_key?(name)
|
@@ -10,9 +10,11 @@ module Rabbit
|
|
10
10
|
AVAILABLE_VALUE_OPTIONS = []
|
11
11
|
def make_image(path, prop, logger)
|
12
12
|
image_file = Tempfile.new("rabbit-image-blockdiag")
|
13
|
-
command = [
|
14
|
-
|
15
|
-
|
13
|
+
command = [
|
14
|
+
"blockdiag",
|
15
|
+
"-T", "svg",
|
16
|
+
"-o", image_file.path,
|
17
|
+
]
|
16
18
|
font = find_font(prop)
|
17
19
|
command.concat(["-f", font]) if font
|
18
20
|
AVAILABLE_FLAG_OPTIONS.each do |name|
|
@@ -3963,13 +3963,13 @@ module Rabbit
|
|
3963
3963
|
"zeetrf" => "ℨ",
|
3964
3964
|
# character showing function application in presentation tagging
|
3965
3965
|
"af" => "⁡",
|
3966
|
-
#
|
3966
|
+
#
|
3967
3967
|
"aopf" => "𝕒",
|
3968
3968
|
# Old ISOAMSR asymp (for HTML compatibility)
|
3969
3969
|
"asympeq" => "≍",
|
3970
|
-
#
|
3970
|
+
#
|
3971
3971
|
"bopf" => "𝕓",
|
3972
|
-
#
|
3972
|
+
#
|
3973
3973
|
"copf" => "𝕔",
|
3974
3974
|
# cross or vector product
|
3975
3975
|
"Cross" => "⨯",
|
@@ -3977,7 +3977,7 @@ module Rabbit
|
|
3977
3977
|
"DD" => "ⅅ",
|
3978
3978
|
# d for use in differentials, e.g., within integrals
|
3979
3979
|
"dd" => "ⅆ",
|
3980
|
-
#
|
3980
|
+
#
|
3981
3981
|
"dopf" => "𝕕",
|
3982
3982
|
# down arrow to bar
|
3983
3983
|
"DownArrowBar" => "⤓",
|
@@ -3997,7 +3997,7 @@ module Rabbit
|
|
3997
3997
|
"EmptySmallSquare" => "◻",
|
3998
3998
|
# empty small square
|
3999
3999
|
"EmptyVerySmallSquare" => "▫",
|
4000
|
-
#
|
4000
|
+
#
|
4001
4001
|
"eopf" => "𝕖",
|
4002
4002
|
# two consecutive equal signs
|
4003
4003
|
"Equal" => "⩵",
|
@@ -4005,15 +4005,15 @@ module Rabbit
|
|
4005
4005
|
"FilledSmallSquare" => "◼",
|
4006
4006
|
# filled very small square
|
4007
4007
|
"FilledVerySmallSquare" => "▪",
|
4008
|
-
#
|
4008
|
+
#
|
4009
4009
|
"fopf" => "𝕗",
|
4010
|
-
#
|
4010
|
+
#
|
4011
4011
|
"gopf" => "𝕘",
|
4012
4012
|
# alias for GT
|
4013
4013
|
"GreaterGreater" => "⪢",
|
4014
4014
|
# circumflex accent
|
4015
4015
|
"Hat" => "^",
|
4016
|
-
#
|
4016
|
+
#
|
4017
4017
|
"hopf" => "𝕙",
|
4018
4018
|
# short horizontal line
|
4019
4019
|
"HorizontalLine" => "─",
|
@@ -4021,13 +4021,13 @@ module Rabbit
|
|
4021
4021
|
"ic" => "⁣",
|
4022
4022
|
# i for use as a square root of -1
|
4023
4023
|
"ii" => "ⅈ",
|
4024
|
-
#
|
4024
|
+
#
|
4025
4025
|
"iopf" => "𝕚",
|
4026
4026
|
# marks multiplication when it is understood without a mark
|
4027
4027
|
"it" => "⁢",
|
4028
|
-
#
|
4028
|
+
#
|
4029
4029
|
"jopf" => "𝕛",
|
4030
|
-
#
|
4030
|
+
#
|
4031
4031
|
"kopf" => "𝕜",
|
4032
4032
|
# leftwards arrow to bar
|
4033
4033
|
"larrb" => "⇤",
|
@@ -4051,7 +4051,7 @@ module Rabbit
|
|
4051
4051
|
"LeftVectorBar" => "⥒",
|
4052
4052
|
# alias for Lt
|
4053
4053
|
"LessLess" => "⪡",
|
4054
|
-
#
|
4054
|
+
#
|
4055
4055
|
"lopf" => "𝕝",
|
4056
4056
|
# downwards arrow from bar
|
4057
4057
|
"mapstodown" => "↧",
|
@@ -4061,7 +4061,7 @@ module Rabbit
|
|
4061
4061
|
"mapstoup" => "↥",
|
4062
4062
|
# space of width 4/18 em
|
4063
4063
|
"MediumSpace" => " ",
|
4064
|
-
#
|
4064
|
+
#
|
4065
4065
|
"mopf" => "𝕞",
|
4066
4066
|
# not bumpy equals
|
4067
4067
|
"nbump" => "≎̸",
|
@@ -4073,7 +4073,7 @@ module Rabbit
|
|
4073
4073
|
"NewLine" => "
",
|
4074
4074
|
# never break line here
|
4075
4075
|
"NoBreak" => "⁠",
|
4076
|
-
#
|
4076
|
+
#
|
4077
4077
|
"nopf" => "𝕟",
|
4078
4078
|
# alias for &nasymp;
|
4079
4079
|
"NotCupCap" => "≭",
|
@@ -4093,7 +4093,7 @@ module Rabbit
|
|
4093
4093
|
"NotSquareSuperset" => "⊐̸",
|
4094
4094
|
# not succeeds or similar
|
4095
4095
|
"NotSucceedsTilde" => "≿̸",
|
4096
|
-
#
|
4096
|
+
#
|
4097
4097
|
"oopf" => "𝕠",
|
4098
4098
|
# over bar
|
4099
4099
|
"OverBar" => "¯",
|
@@ -4105,11 +4105,11 @@ module Rabbit
|
|
4105
4105
|
"OverParenthesis" => "︵",
|
4106
4106
|
# the ring (skew field) of quaternions
|
4107
4107
|
"planckh" => "ℎ",
|
4108
|
-
#
|
4108
|
+
#
|
4109
4109
|
"popf" => "𝕡",
|
4110
4110
|
# alias for ∏
|
4111
4111
|
"Product" => "∏",
|
4112
|
-
#
|
4112
|
+
#
|
4113
4113
|
"qopf" => "𝕢",
|
4114
4114
|
# leftwards arrow to bar
|
4115
4115
|
"rarrb" => "⇥",
|
@@ -4129,19 +4129,19 @@ module Rabbit
|
|
4129
4129
|
"RightUpVectorBar" => "⥔",
|
4130
4130
|
# up-right harpoon to bar
|
4131
4131
|
"RightVectorBar" => "⥓",
|
4132
|
-
#
|
4132
|
+
#
|
4133
4133
|
"ropf" => "𝕣",
|
4134
4134
|
# round implies
|
4135
4135
|
"RoundImplies" => "⥰",
|
4136
4136
|
# rule-delayed (colon right arrow)
|
4137
4137
|
"RuleDelayed" => "⧴",
|
4138
|
-
#
|
4138
|
+
#
|
4139
4139
|
"sopf" => "𝕤",
|
4140
4140
|
# tabulator stop; horizontal tabulation
|
4141
4141
|
"Tab" => "	",
|
4142
4142
|
# space of width 5/18 em
|
4143
4143
|
"ThickSpace" => "   ",
|
4144
|
-
#
|
4144
|
+
#
|
4145
4145
|
"topf" => "𝕥",
|
4146
4146
|
# under brace
|
4147
4147
|
"UnderBrace" => "︸",
|
@@ -4149,7 +4149,7 @@ module Rabbit
|
|
4149
4149
|
"UnderBracket" => "⎵",
|
4150
4150
|
# under parenthesis
|
4151
4151
|
"UnderParenthesis" => "︶",
|
4152
|
-
#
|
4152
|
+
#
|
4153
4153
|
"uopf" => "𝕦",
|
4154
4154
|
# up arrow to bar
|
4155
4155
|
"UpArrowBar" => "⤒",
|
@@ -4159,17 +4159,17 @@ module Rabbit
|
|
4159
4159
|
"VerticalLine" => "|",
|
4160
4160
|
# vertical separating operator
|
4161
4161
|
"VerticalSeparator" => "❘",
|
4162
|
-
#
|
4162
|
+
#
|
4163
4163
|
"vopf" => "𝕧",
|
4164
|
-
#
|
4164
|
+
#
|
4165
4165
|
"wopf" => "𝕨",
|
4166
|
-
#
|
4166
|
+
#
|
4167
4167
|
"xopf" => "𝕩",
|
4168
|
-
#
|
4168
|
+
#
|
4169
4169
|
"yopf" => "𝕪",
|
4170
4170
|
# zero width space
|
4171
4171
|
"ZeroWidthSpace" => "​",
|
4172
|
-
#
|
4172
|
+
#
|
4173
4173
|
"zopf" => "𝕫",
|
4174
4174
|
}
|
4175
4175
|
end
|
@@ -1,7 +1,49 @@
|
|
1
1
|
require "kramdown"
|
2
|
+
require "kramdown/parser/kramdown"
|
3
|
+
require "kramdown/parser/gfm"
|
2
4
|
|
3
5
|
require "rabbit/parser/base"
|
4
6
|
|
7
|
+
module Kramdown
|
8
|
+
module Parser
|
9
|
+
class Kramdown
|
10
|
+
alias_method :handle_extension_raw, :handle_extension
|
11
|
+
def handle_extension(name, opts, body, type, line_no=nil)
|
12
|
+
case name
|
13
|
+
when "wait"
|
14
|
+
@tree.children << Element.new(:wait, body, nil, :category => type, :location => line_no)
|
15
|
+
true
|
16
|
+
else
|
17
|
+
handle_extension_raw(name, opts, body, type, line_no)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
alias_method :configure_parser_raw, :configure_parser
|
22
|
+
def configure_parser
|
23
|
+
position = @block_parsers.index(:codeblock_fenced)
|
24
|
+
@block_parsers.insert(position, :codeblock_fenced_gfm)
|
25
|
+
|
26
|
+
configure_parser_raw
|
27
|
+
end
|
28
|
+
|
29
|
+
parser(:codeblock_fenced_gfm).method = "parse_codeblock_fenced_gfm"
|
30
|
+
|
31
|
+
def parse_codeblock_fenced_gfm
|
32
|
+
original_match = self.class::FENCED_CODEBLOCK_MATCH
|
33
|
+
begin
|
34
|
+
self.class.send(:remove_const, :FENCED_CODEBLOCK_MATCH)
|
35
|
+
self.class.const_set(:FENCED_CODEBLOCK_MATCH,
|
36
|
+
GFM::FENCED_CODEBLOCK_MATCH)
|
37
|
+
parse_codeblock_fenced
|
38
|
+
ensure
|
39
|
+
self.class.send(:remove_const, :FENCED_CODEBLOCK_MATCH)
|
40
|
+
self.class.const_set(:FENCED_CODEBLOCK_MATCH, original_match)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
5
47
|
module Rabbit
|
6
48
|
module Parser
|
7
49
|
class Markdown < Base
|
@@ -1,8 +1,18 @@
|
|
1
|
+
require "English"
|
2
|
+
|
3
|
+
require "rabbit/parser/pause-support"
|
4
|
+
require "rabbit/parser/ext/blockdiag"
|
5
|
+
require "rabbit/parser/ext/coderay"
|
6
|
+
require "rabbit/parser/ext/escape"
|
7
|
+
require "rabbit/parser/ext/image"
|
8
|
+
require "rabbit/parser/ext/tex"
|
9
|
+
|
1
10
|
module Rabbit
|
2
11
|
module Parser
|
3
12
|
class Markdown
|
4
13
|
class Converter
|
5
14
|
include Element
|
15
|
+
include PauseSupport
|
6
16
|
|
7
17
|
def initialize(canvas)
|
8
18
|
@canvas = canvas
|
@@ -11,15 +21,17 @@ module Rabbit
|
|
11
21
|
@slide_property_mode = false
|
12
22
|
end
|
13
23
|
|
14
|
-
def convert(element)
|
15
|
-
|
24
|
+
def convert(element, context=nil)
|
25
|
+
method_name = "convert_#{element.type}"
|
26
|
+
method_name << "_#{context}" if context
|
27
|
+
__send__(method_name, element)
|
16
28
|
end
|
17
29
|
|
18
30
|
private
|
19
|
-
def convert_container(element)
|
31
|
+
def convert_container(element, context=nil)
|
20
32
|
elements = []
|
21
33
|
element.children.each do |child|
|
22
|
-
element = convert(child)
|
34
|
+
element = convert(child, context)
|
23
35
|
case element
|
24
36
|
when nil, :no_element
|
25
37
|
# ignore
|
@@ -39,7 +51,7 @@ module Rabbit
|
|
39
51
|
next
|
40
52
|
when nil
|
41
53
|
mode = :ignore
|
42
|
-
when Slide
|
54
|
+
when Element::Slide
|
43
55
|
target = content.body
|
44
56
|
@canvas << content
|
45
57
|
mode = :display
|
@@ -59,6 +71,7 @@ module Rabbit
|
|
59
71
|
end
|
60
72
|
end
|
61
73
|
end
|
74
|
+
burn_out_pause_targets
|
62
75
|
end
|
63
76
|
|
64
77
|
def convert_header(element)
|
@@ -69,7 +82,7 @@ module Rabbit
|
|
69
82
|
if @slides.empty?
|
70
83
|
@slide = TitleSlide.new(Title.new(contents))
|
71
84
|
else
|
72
|
-
@slide = Slide.new(HeadLine.new(contents))
|
85
|
+
@slide = Element::Slide.new(HeadLine.new(contents))
|
73
86
|
@slide << Body.new
|
74
87
|
end
|
75
88
|
@slides << @slide
|
@@ -114,8 +127,14 @@ module Rabbit
|
|
114
127
|
list
|
115
128
|
end
|
116
129
|
|
130
|
+
def create_paragraph(elements)
|
131
|
+
paragraph = Paragraph.new(elements)
|
132
|
+
register_pause(paragraph) if paragraph.have_wait_tag?
|
133
|
+
paragraph
|
134
|
+
end
|
135
|
+
|
117
136
|
def convert_dt(element)
|
118
|
-
DescriptionTerm.new(
|
137
|
+
DescriptionTerm.new(create_paragraph(convert_container(element)))
|
119
138
|
end
|
120
139
|
|
121
140
|
def convert_dd(element)
|
@@ -130,17 +149,61 @@ module Rabbit
|
|
130
149
|
raise ParseError,
|
131
150
|
_("multiple ![alt]{image} in a paragraph isn't supported.")
|
132
151
|
else
|
133
|
-
|
152
|
+
create_paragraph(convert_container(element))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def create_list(list_class, contents)
|
158
|
+
list = list_class.new
|
159
|
+
contents.each do |content|
|
160
|
+
list << content
|
161
|
+
if block_given?
|
162
|
+
yield(list, content)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
list
|
166
|
+
end
|
167
|
+
|
168
|
+
def create_list_item(list_item_class, contents)
|
169
|
+
list_item = list_item_class.new(contents)
|
170
|
+
|
171
|
+
waited_paragraphs = list_item.elements.find_all do |element|
|
172
|
+
element.is_a?(Paragraph) and element.have_wait_tag?
|
173
|
+
end
|
174
|
+
unless waited_paragraphs.empty?
|
175
|
+
waited_paragraphs.each do |paragraph|
|
176
|
+
paragraph.default_visible = true
|
177
|
+
paragraph.clear_theme
|
178
|
+
unregister_pause(paragraph)
|
134
179
|
end
|
180
|
+
|
181
|
+
list_item.default_visible = false
|
182
|
+
list_item.clear_theme
|
183
|
+
register_pause(list_item)
|
135
184
|
end
|
185
|
+
|
186
|
+
list_item
|
136
187
|
end
|
137
188
|
|
138
189
|
def convert_ul(element)
|
139
|
-
ItemList
|
190
|
+
create_list(ItemList, convert_container(element, "ul"))
|
140
191
|
end
|
141
192
|
|
142
|
-
def
|
143
|
-
ItemListItem
|
193
|
+
def convert_li_ul(element)
|
194
|
+
create_list_item(ItemListItem, convert_container(element))
|
195
|
+
end
|
196
|
+
|
197
|
+
def convert_ol(element)
|
198
|
+
i = 1
|
199
|
+
create_list(EnumList, convert_container(element, "ol")) do |list, item|
|
200
|
+
item.order = i
|
201
|
+
i += 1
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def convert_li_ol(element)
|
206
|
+
create_list_item(EnumListItem, convert_container(element))
|
144
207
|
end
|
145
208
|
|
146
209
|
def convert_smart_quote(element)
|
@@ -198,12 +261,42 @@ module Rabbit
|
|
198
261
|
|
199
262
|
def convert_codeblock(element)
|
200
263
|
content = element.value.chomp
|
264
|
+
language = detect_codeblock_language(element)
|
265
|
+
if language
|
266
|
+
converted = convert_codeblock_language(element, language, content)
|
267
|
+
end
|
268
|
+
converted || PreformattedBlock.new(PreformattedText.new(text(content)))
|
269
|
+
end
|
270
|
+
|
271
|
+
def detect_codeblock_language(element)
|
201
272
|
lang = element.attr["lang"]
|
202
|
-
if lang
|
203
|
-
|
204
|
-
|
273
|
+
return lang if lang
|
274
|
+
|
275
|
+
language = element.attr["language"]
|
276
|
+
return language if language
|
277
|
+
|
278
|
+
klass = element.attr["class"]
|
279
|
+
if klass and /\Alanguage-/ =~ klass
|
280
|
+
return $POSTMATCH
|
281
|
+
end
|
282
|
+
|
283
|
+
nil
|
284
|
+
end
|
285
|
+
|
286
|
+
def convert_codeblock_language(element, language, content)
|
287
|
+
case language
|
288
|
+
when "blockdiag"
|
289
|
+
args = [@canvas, content]
|
290
|
+
Ext::Image.make_image_from_file(*args) do |src_file_path|
|
291
|
+
[
|
292
|
+
Ext::BlockDiag.make_image(src_file_path, element.attr, @canvas),
|
293
|
+
element.attr,
|
294
|
+
]
|
295
|
+
end
|
296
|
+
else
|
297
|
+
logger = @canvas.logger
|
298
|
+
Ext::CodeRay.highlight(language, content, logger)
|
205
299
|
end
|
206
|
-
PreformattedBlock.new(PreformattedText.new(text(content)))
|
207
300
|
end
|
208
301
|
|
209
302
|
def convert_blockquote(element)
|
@@ -226,7 +319,7 @@ module Rabbit
|
|
226
319
|
end
|
227
320
|
body["background-image"] = uri
|
228
321
|
options.each do |name, value|
|
229
|
-
name = name.to_s.gsub(/_/,
|
322
|
+
name = name.to_s.gsub(/_/, "-")
|
230
323
|
body["background-image-#{name}"] = value
|
231
324
|
end
|
232
325
|
:no_element
|
@@ -253,7 +346,7 @@ module Rabbit
|
|
253
346
|
|
254
347
|
def convert_a(element)
|
255
348
|
ref = ReferText.new(convert_container(element))
|
256
|
-
ref.to = element.attr[
|
349
|
+
ref.to = element.attr["href"]
|
257
350
|
ref
|
258
351
|
end
|
259
352
|
|
@@ -262,7 +355,11 @@ module Rabbit
|
|
262
355
|
end
|
263
356
|
|
264
357
|
def convert_codespan(element)
|
265
|
-
Code.new(
|
358
|
+
Code.new(text(element.value))
|
359
|
+
end
|
360
|
+
|
361
|
+
def convert_wait(element)
|
362
|
+
WaitTag.new
|
266
363
|
end
|
267
364
|
end
|
268
365
|
end
|