review-peg 0.2.0 → 0.2.1

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: 02a8314cbab450277e8afa8b82587710657765c4
4
- data.tar.gz: 2a1eb42ee5b296e430b1c8a4f24ca5aee7daa592
3
+ metadata.gz: 1f54ae66ecbce5b66ce484d9fcdb1b56265e7df5
4
+ data.tar.gz: 1d7e98448ac6acfca5b600b2e5dd003bc6eae84e
5
5
  SHA512:
6
- metadata.gz: 5c9daa8c4e7649c01b8fd4579f1b894ad140ee6c6adba721c063cd4633bf3190e2f85bc0eed84aad79a9d1a1b28fd28e27f86a057099f9cbe6d9506dc21ac6ea
7
- data.tar.gz: a94b8dcae6985bdef5bfc5e91a617d962f60003db27f7725029720b694a8309b627425410b56b8fed42be8e91e7fcc9e8b4ab4176453eb48e9d742c92aaef334
6
+ metadata.gz: 2776df52db2e4bfd656f738dce54b8dfe4e65228995f8fb14fd1c125933276e6e3d6e3c30ab9194755b864120bc7e9825a4a6e6cb10a11475fc0d1f685d0f610
7
+ data.tar.gz: a7d35573095992184ac9e2e0c2af2418c62e0007c621b0bb5045f6f77ba1e616eb7de0a81ff9e5d75d14f894734f612dd117e9c0527ad043017e9693c0610d85
@@ -228,8 +228,14 @@ module ReVIEW
228
228
  nofunc_text("[UnknownImage:#{id}]")
229
229
  end
230
230
 
231
- def inline_imgref(id)
232
- img = inline_img(id)
231
+ def node_inline_img(node)
232
+ id = node[0].to_raw
233
+ inline_img(id)
234
+ end
235
+
236
+ def node_inline_imgref(node)
237
+ id = node[0].to_raw
238
+ img = node_inline_img(node)
233
239
 
234
240
  if @chapter.image(id).caption
235
241
  "#{img}#{I18n.t('image_quote', @chapter.image(id).caption)}"
@@ -36,10 +36,18 @@ class ReVIEW::Compiler
36
36
  end
37
37
 
38
38
  def current_line(target=pos)
39
- offset = @sizes_memo.bsearch{|line, cur_offset| cur_offset >= target}
40
- if offset
41
- return offset[0]
42
- end
39
+ if @sizes_memo.respond_to?(:bsearch)
40
+ offset = @sizes_memo.bsearch{|line, cur_offset| cur_offset >= target}
41
+ if offset
42
+ return offset[0]
43
+ end
44
+ else
45
+ @sizes_memo.each do |line, cur_offset|
46
+ if cur_offset >= target
47
+ return cur_offset
48
+ end
49
+ end
50
+ end
43
51
 
44
52
  -1
45
53
  end
@@ -442,7 +442,8 @@ module ReVIEW
442
442
  end
443
443
  end
444
444
 
445
- def inline_img(id)
445
+ def node_inline_img(node)
446
+ id = node[0].to_raw
446
447
  chapter, id = extract_chapter_id(id)
447
448
  if get_chap(chapter).nil?
448
449
  "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}</span>"
@@ -451,10 +452,11 @@ module ReVIEW
451
452
  end
452
453
  end
453
454
 
454
- def inline_imgref(id)
455
+ def node_inline_imgref(node)
456
+ id = node[0].to_raw
455
457
  chapter, id = extract_chapter_id(id)
456
458
  if chapter.image(id).caption.blank?
457
- inline_img(id)
459
+ node_inline_img(node)
458
460
  else
459
461
  if get_chap(chapter).nil?
460
462
  "<span type='image'>#{I18n.t("image")}#{I18n.t("format_number_without_chapter", [chapter.image(id).number])}#{I18n.t('image_quote', chapter.image(id).caption)}</span>"
@@ -230,9 +230,9 @@ module ReVIEW
230
230
  def emlist(lines, caption = nil, lang = nil)
231
231
  buf = "\n"
232
232
  if highlight_listings?
233
- buf << common_code_block_lst(lines, 'reviewemlistlst', 'title', caption, lang)
233
+ buf << common_code_block_lst(nil, lines, 'reviewemlistlst', 'title', caption, lang)
234
234
  else
235
- buf << common_code_block(lines, 'reviewemlist', caption, lang) do |line, idx|
235
+ buf << common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx|
236
236
  detab(line) + "\n"
237
237
  end
238
238
  end
@@ -242,9 +242,9 @@ module ReVIEW
242
242
  def emlistnum(lines, caption = nil, lang = nil)
243
243
  buf = "\n"
244
244
  if highlight_listings?
245
- buf << common_code_block_lst(lines, 'reviewemlistnumlst', 'title', caption, lang)
245
+ buf << common_code_block_lst(nil, lines, 'reviewemlistnumlst', 'title', caption, lang)
246
246
  else
247
- buf << common_code_block(lines, 'reviewemlist', caption, lang) do |line, idx|
247
+ buf << common_code_block(nil, lines, 'reviewemlist', caption, lang) do |line, idx|
248
248
  detab((idx+1).to_s.rjust(2)+": " + line) + "\n"
249
249
  end
250
250
  end
@@ -255,14 +255,9 @@ module ReVIEW
255
255
  def list(lines, id, caption = nil, lang = nil)
256
256
  buf = ""
257
257
  if highlight_listings?
258
- buf << common_code_block_lst(lines, 'reviewlistlst', 'caption', caption, lang)
258
+ buf << common_code_block_lst(id, lines, 'reviewlistlst', 'caption', caption, lang)
259
259
  else
260
- begin
261
- buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n"
262
- rescue KeyError
263
- error "no such list: #{id}"
264
- end
265
- buf << common_code_block(lines, 'reviewlist', nil, lang) do |line, idx|
260
+ buf << common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
266
261
  detab(line) + "\n"
267
262
  end
268
263
  end
@@ -274,14 +269,9 @@ module ReVIEW
274
269
  def listnum(lines, id, caption = nil, lang = nil)
275
270
  buf = ""
276
271
  if highlight_listings?
277
- buf << common_code_block_lst(lines, 'reviewlistnumlst', 'caption', caption, lang)
272
+ buf << common_code_block_lst(id, lines, 'reviewlistnumlst', 'caption', caption, lang)
278
273
  else
279
- begin
280
- buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n"
281
- rescue KeyError
282
- error "no such list: #{id}"
283
- end
284
- buf << common_code_block(lines, 'reviewlist', caption, lang) do |line, idx|
274
+ buf << common_code_block(id, lines, 'reviewlist', caption, lang) do |line, idx|
285
275
  detab((idx+1).to_s.rjust(2)+": " + line) + "\n"
286
276
  end
287
277
  end
@@ -291,20 +281,29 @@ module ReVIEW
291
281
  def cmd(lines, caption = nil, lang = nil)
292
282
  buf = ""
293
283
  if highlight_listings?
294
- buf << common_code_block_lst(lines, 'reviewcmdlst', 'title', caption, lang)
284
+ buf << common_code_block_lst(nil, lines, 'reviewcmdlst', 'title', caption, lang)
295
285
  else
296
286
  buf << "\n"
297
- buf << common_code_block(lines, 'reviewcmd', caption, lang) do |line, idx|
287
+ buf << common_code_block(nil, lines, 'reviewcmd', caption, lang) do |line, idx|
298
288
  detab(line) + "\n"
299
289
  end
300
290
  end
301
291
  buf
302
292
  end
303
293
 
304
- def common_code_block(lines, command, caption, lang)
294
+ def common_code_block(id, lines, command, caption, lang)
305
295
  buf = ""
306
296
  if caption
307
- buf << macro(command + 'caption', "#{caption}") + "\n"
297
+ if command =~ /emlist/ || command =~ /cmd/
298
+ buf << macro(command + 'caption', "#{caption}") + "\n"
299
+ else
300
+ begin
301
+ buf << "\n"
302
+ buf << macro('reviewlistcaption', "#{I18n.t("list")}#{I18n.t("format_number_header", [@chapter.number, @chapter.list(id).number])}#{I18n.t("caption_prefix")}#{caption}") + "\n"
303
+ rescue KeyError
304
+ error "no such list: #{id}"
305
+ end
306
+ end
308
307
  end
309
308
  body = ""
310
309
  lines.each_with_index do |line, idx|
@@ -316,7 +315,7 @@ module ReVIEW
316
315
  buf
317
316
  end
318
317
 
319
- def common_code_block_lst(lines, command, title, caption, lang)
318
+ def common_code_block_lst(id, lines, command, title, caption, lang)
320
319
  buf = ""
321
320
  caption_str = (caption || "")
322
321
  if title == "title" && caption_str == ""
@@ -338,7 +337,7 @@ module ReVIEW
338
337
 
339
338
  def source(lines, caption = nil, lang = nil)
340
339
  if highlight_listings?
341
- common_code_block_lst(lines, 'reviewlistlst', 'title', caption, lang)
340
+ common_code_block_lst(nil, lines, 'reviewlistlst', 'title', caption, lang)
342
341
  else
343
342
  buf = "\n"
344
343
  buf << '\begin{reviewlist}' << "\n"
@@ -681,7 +680,7 @@ module ReVIEW
681
680
 
682
681
  def node_inline_title(node)
683
682
  id = node[0].to_raw
684
- title = super
683
+ title = @book.chapter_index.title(id)
685
684
  if @book.config["chapterlink"]
686
685
  "\\hyperref[chap:#{id}]{#{title}}"
687
686
  else
@@ -1,3 +1,3 @@
1
1
  module ReVIEW
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -279,7 +279,7 @@ class LATEXBuidlerTest < Test::Unit::TestCase
279
279
 
280
280
  def test_listnum
281
281
  actual = compile_block("//listnum[test1][ruby]{\nclass Foo\n def foo\n bar\n\n buz\n end\nend\n//}\n")
282
- assert_equal %Q|\\reviewlistcaption{リスト1.1: ruby}\n\\reviewlistcaption{ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
282
+ assert_equal %Q|\n\\reviewlistcaption{リスト1.1: ruby}\n\\begin{reviewlist}\n 1: class Foo\n 2: def foo\n 3: bar\n 4: \n 5: buz\n 6: end\n 7: end\n\\end{reviewlist}\n|, actual
283
283
  end
284
284
 
285
285
  def test_listnum_lst
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: review-peg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmuto
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-13 00:00:00.000000000 Z
12
+ date: 2015-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake