pandoc2review 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8adcffddd4264746fd310194473ea979a7f884edda769a164fbbf9caa4a40fb0
4
- data.tar.gz: b42b6d77e327254cd472a356736885735984742d16acabf360d337b1fdf09611
3
+ metadata.gz: a11aa7a678f2ccee527f68b25d2617c4b25dbe44fb675316593b4638ccf82252
4
+ data.tar.gz: afe9e95dde61125f788c438128014721cc5825f67f834048a2240d455929e90b
5
5
  SHA512:
6
- metadata.gz: 2b45bf183261d07b0970b8afdfe6f24a68f63aca8505bb082237140b6d377982697f1fecc5463d255cabb5ac38920ebf838b76cfc9feca8d61f9359ff121f32a
7
- data.tar.gz: bea497ce7dba3bba8eaaefd41975bb820840803cf71260ce02901bfa5f30bc572d8c1706bbb68aa38f1d984fb980988fa9aba4c684e095c97d18daeffadce54e
6
+ metadata.gz: 267a8c27385b13c00f835fc73b01dd9f5c27e8c3e85b5d298c185580f1f048aef2537dbde3eb5c39a0d87893ef98c9572f9c53eb152fddf79166e5c7a4744301
7
+ data.tar.gz: 4665b011334f35a3c1444a2aacfcec7bf96771ccd8181c3f14b116f499cd936355b587d1b804e37ed7c99b6b99568e8b27a3855c9e3f50c48edeb96700a832b4
@@ -4,14 +4,20 @@ on: [push, pull_request]
4
4
  jobs:
5
5
  Pandoc:
6
6
  runs-on: ubuntu-latest
7
+ timeout-minutes: 5
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: ['2.7', '3.1']
12
+ pandoc: ['2.11.3', '3.1.4']
7
13
  steps:
8
14
  - uses: actions/checkout@master
9
15
  - uses: ruby/setup-ruby@v1
10
16
  with:
11
- ruby-version: '2.7'
17
+ ruby-version: ${{ matrix.ruby }}
12
18
  - uses: r-lib/actions/setup-pandoc@v1
13
19
  with:
14
- pandoc-version: '2.11.3'
20
+ pandoc-version: ${{ matrix.pandoc }}
15
21
  - run: |
16
22
  gem install bundler --no-document
17
23
  bundle install --retry 3
data/README.md CHANGED
@@ -47,7 +47,7 @@ pandoc2review file > file.re
47
47
 
48
48
  ## Copyright
49
49
 
50
- Copyright 2020-2021 Kenshi Muto
50
+ Copyright 2020-2023 Kenshi Muto
51
51
 
52
52
  GNU General Public License Version 2
53
53
 
@@ -57,6 +57,9 @@ GNU General Public License Version 2
57
57
  - [@takahashim](https://github.com/takahashim)
58
58
 
59
59
  ## Changelog
60
+ ### 1.5.0
61
+ - Support Pandoc 3.
62
+
60
63
  ### 1.4.0
61
64
  - Fix an error when empty div block is received.
62
65
  - Introduce '--strip-emptydev' to strip empty block `//{-//}`, produced by TeX file.
data/lib/pandoc2review.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright 2020-2021 Kenshi Muto
2
+ # Copyright 2020-2023 Kenshi Muto
3
3
  require 'optparse'
4
4
  require 'unicode/eaw'
5
5
  require 'pathname'
@@ -55,7 +55,7 @@ class Pandoc2ReVIEW
55
55
  @stripemptydev = nil
56
56
  opts = OptionParser.new
57
57
  opts.banner = 'Usage: pandoc2review [option] file [file ...]'
58
- opts.version = '1.4'
58
+ opts.version = '1.5'
59
59
 
60
60
  opts.on('--help', 'Prints this message and quit.') do
61
61
  puts opts.help
@@ -74,7 +74,12 @@ class Pandoc2ReVIEW
74
74
  @stripemptydev = true
75
75
  end
76
76
 
77
- opts.parse!(ARGV)
77
+ begin
78
+ opts.parse!(ARGV)
79
+ rescue OptionParser::ParseError
80
+ puts opts.help
81
+ exit 1
82
+ end
78
83
  if ARGV.size != 1
79
84
  puts opts.help
80
85
  exit 0
data/lua/filters.lua CHANGED
@@ -1,3 +1,5 @@
1
+ -- Copyright 2020-2023 atusy and Kenshi Muto
2
+
1
3
  local function review_inline(x)
2
4
  return pandoc.RawInline("review", x)
3
5
  end
@@ -6,7 +8,11 @@ local beginchild = {pandoc.Plain(review_inline("//beginchild"))}
6
8
  local endchild = {pandoc.Plain(review_inline("//endchild"))}
7
9
 
8
10
  local function markdown(text)
9
- return(pandoc.read(text, "markdown").blocks[1].content)
11
+ return pandoc.read(
12
+ text,
13
+ "markdown-auto_identifiers-smart+east_asian_line_breaks",
14
+ PANDOC_READER_OPTIONS
15
+ ).blocks[1].content
10
16
  end
11
17
 
12
18
  local function support_blankline(constructor)
@@ -150,6 +156,34 @@ local function noindent(para)
150
156
  return para
151
157
  end
152
158
 
159
+ local function figure(fig)
160
+ -- Pandoc 3.x adds pandoc.Figure
161
+ if #fig.content > 1 or #fig.content[1].content > 1 then
162
+ error("NotImplemented")
163
+ end
164
+
165
+ local base = fig.content[1].content[1]
166
+
167
+ local attr = {}
168
+ for k, v in pairs(base.attributes) do
169
+ attr[k] = v
170
+ end
171
+ local classes = {}
172
+ for _, v in pairs(base.classes) do
173
+ table.insert(classes, "." .. v)
174
+ end
175
+ attr.classes = table.concat(classes, " ")
176
+ attr.identifier = base.attr.identifier
177
+ attr.is_figure = "true"
178
+
179
+ return pandoc.Image(
180
+ base.title,
181
+ base.src,
182
+ pandoc.utils.stringify(fig.caption),
183
+ attr
184
+ )
185
+ end
186
+
153
187
  return {
154
188
  {Emph = support_strong("Strong")},
155
189
  {Strong = support_strong("Emph")},
@@ -160,5 +194,6 @@ return {
160
194
  {BulletList = nestablelist},
161
195
  {OrderedList = nestablelist},
162
196
  {DefinitionList = nestablelist},
163
- {Div = caption_div}
197
+ {Div = caption_div},
198
+ {Figure = figure},
164
199
  }
data/lua/review.lua CHANGED
@@ -1,6 +1,6 @@
1
1
  -- -*- coding: utf-8 -*-
2
2
  -- Re:VIEW Writer for Pandoc
3
- -- Copyright 2020 Kenshi Muto
3
+ -- Copyright 2020-2023 atusy and Kenshi Muto
4
4
 
5
5
  -- config
6
6
  local config = {
@@ -477,6 +477,16 @@ function CaptionedImage(s, src, tit, attr)
477
477
  )
478
478
  end
479
479
 
480
+ function Image(s, src, tit, attr)
481
+ -- Re:VIEW @<icon> ignores caption and title
482
+ if attr.is_figure then
483
+ return CaptionedImage(src, s, tit, attr)
484
+ end
485
+ local id = string.gsub(src, "%.%w+$", "")
486
+ id = string.gsub(id, "^images/", "")
487
+ return format_inline("icon", id)
488
+ end
489
+
480
490
  function Note(s)
481
491
  note_num = note_num + 1
482
492
  table.insert(footnotes, "//footnote[fn" .. note_num .. "][" .. s .. "]")
@@ -596,24 +606,38 @@ function RawBlock(format, text)
596
606
  end
597
607
  end
598
608
 
599
- try_catch {
600
- try = function()
601
- metadata = PANDOC_DOCUMENT.meta
602
- end,
603
- catch = function(error)
604
- log("Due to your pandoc version is too old, config.yml loader is disabled.\n")
605
- end
606
- }
609
+ local function configure()
610
+ try_catch {
611
+ try = function()
612
+ metadata = PANDOC_DOCUMENT.meta
613
+ end,
614
+ catch = function(error)
615
+ log("Due to your pandoc version is too old, config.yml loader is disabled.\n")
616
+ end
617
+ }
607
618
 
608
- if (metadata) then
609
- -- Load config from YAML
610
- for k,v in pairs(config) do
611
- if metadata[k] ~= nil then
612
- config[k] = stringify(metadata[k])
619
+ if (metadata) then
620
+ -- Load config from YAML
621
+ for k,v in pairs(config) do
622
+ if metadata[k] ~= nil then
623
+ config[k] = stringify(metadata[k])
624
+ end
613
625
  end
614
626
  end
615
627
  end
616
628
 
629
+ if PANDOC_VERSION >= "3.0.0" then
630
+ -- NOTE: A wrapper to support Pandoc >= 3.0 https://pandoc.org/custom-writers.html#changes-in-pandoc-3.0
631
+ function Writer (doc, opts)
632
+ PANDOC_DOCUMENT = doc
633
+ PANDOC_WRITER_OPTIONS = opts
634
+ configure()
635
+ return pandoc.write_classic(doc, opts)
636
+ end
637
+ else
638
+ configure()
639
+ end
640
+
617
641
  local meta = {}
618
642
  meta.__index =
619
643
  function(_, key)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pandoc2review"
3
- spec.version = "1.4.0"
3
+ spec.version = "1.5.0"
4
4
  spec.authors = ["Kenshi Muto"]
5
5
  spec.email = ["kmuto@kmuto.jp"]
6
6
  spec.license = "GPL-2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandoc2review
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenshi Muto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2023-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode-eaw
@@ -104,7 +104,7 @@ licenses:
104
104
  metadata:
105
105
  homepage_uri: https://github.com/kmuto/pandoc2review
106
106
  source_code_uri: https://github.com/kmuto/pandoc2review
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -120,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.7.6.2
125
- signing_key:
123
+ rubygems_version: 3.3.15
124
+ signing_key:
126
125
  specification_version: 4
127
126
  summary: Pandoc2review is a converter from any document to Re:VIEW format (using Pandoc)
128
127
  test_files: []