pandoc2review 1.3.0 → 1.5.0
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/.github/workflows/pandoc.yml +8 -2
- data/README.md +8 -1
- data/lib/pandoc2review.rb +16 -3
- data/lua/filters.lua +38 -2
- data/lua/review.lua +43 -15
- data/pandoc2review.gemspec +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a11aa7a678f2ccee527f68b25d2617c4b25dbe44fb675316593b4638ccf82252
|
4
|
+
data.tar.gz: afe9e95dde61125f788c438128014721cc5825f67f834048a2240d455929e90b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
12
18
|
- uses: r-lib/actions/setup-pandoc@v1
|
13
19
|
with:
|
14
|
-
pandoc-version:
|
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-
|
50
|
+
Copyright 2020-2023 Kenshi Muto
|
51
51
|
|
52
52
|
GNU General Public License Version 2
|
53
53
|
|
@@ -57,6 +57,13 @@ 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
|
+
|
63
|
+
### 1.4.0
|
64
|
+
- Fix an error when empty div block is received.
|
65
|
+
- Introduce '--strip-emptydev' to strip empty block `//{-//}`, produced by TeX file.
|
66
|
+
|
60
67
|
### 1.3.0
|
61
68
|
- Fix "attempt to index global 'first' (a nil value)" error in a docx file.
|
62
69
|
|
data/lib/pandoc2review.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright 2020-
|
2
|
+
# Copyright 2020-2023 Kenshi Muto
|
3
3
|
require 'optparse'
|
4
4
|
require 'unicode/eaw'
|
5
5
|
require 'pathname'
|
@@ -29,6 +29,10 @@ class Pandoc2ReVIEW
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
if @stripemptydev
|
33
|
+
args += ['-M', "stripemptydev:true"]
|
34
|
+
end
|
35
|
+
|
32
36
|
if @heading
|
33
37
|
args += ["--shift-heading-level-by=#{@heading}"]
|
34
38
|
end
|
@@ -48,9 +52,10 @@ class Pandoc2ReVIEW
|
|
48
52
|
@heading = nil
|
49
53
|
@disableeaw = nil
|
50
54
|
@hideraw = nil
|
55
|
+
@stripemptydev = nil
|
51
56
|
opts = OptionParser.new
|
52
57
|
opts.banner = 'Usage: pandoc2review [option] file [file ...]'
|
53
|
-
opts.version = '1.
|
58
|
+
opts.version = '1.5'
|
54
59
|
|
55
60
|
opts.on('--help', 'Prints this message and quit.') do
|
56
61
|
puts opts.help
|
@@ -65,8 +70,16 @@ class Pandoc2ReVIEW
|
|
65
70
|
opts.on('--hideraw', "Hide raw inline/block with no review format specified.") do
|
66
71
|
@hideraw = true
|
67
72
|
end
|
73
|
+
opts.on('--strip-emptydev', "Strip <div> without any id or class") do
|
74
|
+
@stripemptydev = true
|
75
|
+
end
|
68
76
|
|
69
|
-
|
77
|
+
begin
|
78
|
+
opts.parse!(ARGV)
|
79
|
+
rescue OptionParser::ParseError
|
80
|
+
puts opts.help
|
81
|
+
exit 1
|
82
|
+
end
|
70
83
|
if ARGV.size != 1
|
71
84
|
puts opts.help
|
72
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
|
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)
|
@@ -102,6 +108,7 @@ local function caption_div(div)
|
|
102
108
|
local caption = div.attributes.caption
|
103
109
|
|
104
110
|
if ((#div.content == 1) and
|
111
|
+
(div.content[1].content) and
|
105
112
|
(#div.content[1].content == 1) and
|
106
113
|
(div.content[1].content[1].tag == "Math") and
|
107
114
|
(div.identifier)) then
|
@@ -149,6 +156,34 @@ local function noindent(para)
|
|
149
156
|
return para
|
150
157
|
end
|
151
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
|
+
|
152
187
|
return {
|
153
188
|
{Emph = support_strong("Strong")},
|
154
189
|
{Strong = support_strong("Emph")},
|
@@ -159,5 +194,6 @@ return {
|
|
159
194
|
{BulletList = nestablelist},
|
160
195
|
{OrderedList = nestablelist},
|
161
196
|
{DefinitionList = nestablelist},
|
162
|
-
{Div = caption_div}
|
197
|
+
{Div = caption_div},
|
198
|
+
{Figure = figure},
|
163
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 .. "]")
|
@@ -522,7 +532,11 @@ function Div(s, attr)
|
|
522
532
|
local classes = attr_classes(attr)
|
523
533
|
|
524
534
|
if next(classes) == nil then
|
525
|
-
|
535
|
+
if metadata.stripemptydev then
|
536
|
+
return s
|
537
|
+
else
|
538
|
+
return "//{\n" .. s .. "\n//}"
|
539
|
+
end
|
526
540
|
end
|
527
541
|
|
528
542
|
if classes["review-internal"] then
|
@@ -592,24 +606,38 @@ function RawBlock(format, text)
|
|
592
606
|
end
|
593
607
|
end
|
594
608
|
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
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
|
+
}
|
603
618
|
|
604
|
-
if (metadata) then
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
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
|
609
625
|
end
|
610
626
|
end
|
611
627
|
end
|
612
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
|
+
|
613
641
|
local meta = {}
|
614
642
|
meta.__index =
|
615
643
|
function(_, key)
|
data/pandoc2review.gemspec
CHANGED
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
|
+
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:
|
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
|
-
|
124
|
-
|
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: []
|