rsyntaxtree 1.3.0 → 1.3.2

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.
data/lib/rsyntaxtree.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # Facade of rsyntaxtree library. When loaded by a driver script, it does all
8
8
  # the necessary 'require' to use the library.
9
- # Copyright (c) 2007-2023 Yoichiro Hasebe <yohasebe@gmail.com>
9
+ # Copyright (c) 2007-2024 Yoichiro Hasebe <yohasebe@gmail.com>
10
10
 
11
11
  FONT_DIR = File.expand_path(File.join(__dir__, "/../fonts"))
12
12
  ETYPE_NODE = 1
@@ -66,8 +66,6 @@ module RSyntaxTree
66
66
  .gsub('-CABRACKET-', '>')
67
67
  .gsub('¥¥', '\¥')
68
68
  .gsub(/(?<!\\)¥/, "\\")
69
- .gsub(/\\\[/, "[")
70
- .gsub(/\\\]/, "]")
71
69
  new_params[key] = data
72
70
 
73
71
  when :symmetrize, :transparent, :polyline, :hide_default_connectors
@@ -162,11 +160,12 @@ module RSyntaxTree
162
160
  context.render_rsvg_handle(rsvg)
163
161
  b = StringIO.new
164
162
  surface.write_to_png(b)
165
- if binary
166
- b
167
- else
168
- b.string
169
- end
163
+ result = binary ? b : b.string
164
+ # Clean up resources
165
+ b.close unless binary
166
+ surface.finish
167
+ context.destroy
168
+ result
170
169
  rescue Cairo::InvalidSize
171
170
  raise RSTError, +"Error: the result syntree is too big"
172
171
  end
@@ -180,11 +179,11 @@ module RSyntaxTree
180
179
  context = Cairo::Context.new(surface)
181
180
  context.render_rsvg_handle(rsvg)
182
181
  surface.finish
183
- if binary
184
- b
185
- else
186
- b.string
187
- end
182
+ result = binary ? b : b.string
183
+ # Clean up resources
184
+ b.close unless binary
185
+ context.destroy
186
+ result
188
187
  rescue Cairo::InvalidSize
189
188
  raise RSTError, +"Error: the result syntree is too big"
190
189
  end
@@ -202,10 +201,12 @@ module RSyntaxTree
202
201
  image, _data = Magick::Image.from_blob(svg) do |im|
203
202
  im.format = 'svg'
204
203
  end
205
- image.to_blob do |im|
204
+ blob = image.to_blob do |im|
206
205
  im.format = @params[:format].upcase
207
206
  end
208
- image
207
+ # Clean up resources
208
+ image.destroy!
209
+ blob
209
210
  end
210
211
  end
211
212
  end
@@ -207,4 +207,11 @@ class MarkupParserTest < Minitest::Test
207
207
  Markup.parse text2
208
208
  # {:status=>:error, :text=>"!^#----\\n\\nX_Y_Z+1+>2"}
209
209
  end
210
+
211
+ def test_escaped_brackets
212
+ text = "[expr [id x] [suffix \\[ [id 2] \\] ] ]"
213
+ @parser = MarkupParser.new
214
+ @parser.parse(text)
215
+ assert true
216
+ end
210
217
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-26 00:00:00.000000000 Z
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optimist
@@ -166,6 +166,7 @@ files:
166
166
  - docs/_examples/050.md
167
167
  - docs/_examples/051.md
168
168
  - docs/_examples/052.md
169
+ - docs/_examples/053.md
169
170
  - docs/_includes/box_and_circle_table.html
170
171
  - docs/_includes/escape_char_table.html
171
172
  - docs/_includes/social_media_links.html
@@ -224,6 +225,7 @@ files:
224
225
  - docs/assets/img/050.png
225
226
  - docs/assets/img/051.png
226
227
  - docs/assets/img/052.png
228
+ - docs/assets/img/053.png
227
229
  - docs/assets/img/elements/arrow_both.png
228
230
  - docs/assets/img/elements/arrow_both_bold.png
229
231
  - docs/assets/img/elements/arrow_left.png
@@ -299,6 +301,7 @@ files:
299
301
  - docs/assets/svg/050.svg
300
302
  - docs/assets/svg/051.svg
301
303
  - docs/assets/svg/052.svg
304
+ - docs/assets/svg/053.svg
302
305
  - docs/documentation.md
303
306
  - docs/documentation_ja.md
304
307
  - docs/examples.html
@@ -355,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
355
358
  - !ruby/object:Gem::Version
356
359
  version: '0'
357
360
  requirements: []
358
- rubygems_version: 3.5.9
361
+ rubygems_version: 3.4.13
359
362
  signing_key:
360
363
  specification_version: 4
361
364
  summary: RSyntaxTree is a graphical syntax tree generator written in Ruby