pandoc2review 1.4.0 → 1.6.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 +8 -3
- data/lua/filters.lua +39 -4
- data/lua/review.lua +46 -31
- 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: 4cfd0215db986170226f60ea72af5f323ca588196b0622cfaddd14fe16dbbd0e
|
4
|
+
data.tar.gz: b14fcc9ad8b5146dcbb13fe6e5f3bea7eb66d991596bef2f20fd6c649af4e1b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c441ec53f24068da40cbb31c83a0adce2a80c38c6dcb705227d4a147f019be367bd79b7d9afa7482ecd06d976e2503f5f4ca33cda6af85d63a14994875248fa
|
7
|
+
data.tar.gz: 68f1bfaece899793dc563c423387da38d73574122d90cb98fca45d807f0e35e855eb3d2d67f898965f38f337c6c59dbe219cf37ff41c2f52362e4989dc28e663
|
@@ -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 and atusy
|
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.6.0
|
61
|
+
- Fix inline raw.
|
62
|
+
- Refactoring.
|
63
|
+
|
64
|
+
### 1.5.0
|
65
|
+
- Support Pandoc 3.
|
66
|
+
|
60
67
|
### 1.4.0
|
61
68
|
- Fix an error when empty div block is received.
|
62
69
|
- 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-
|
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.
|
58
|
+
opts.version = '1.6'
|
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
|
-
|
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
|
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)
|
@@ -23,7 +29,7 @@ local function support_blankline(constructor)
|
|
23
29
|
local n_break = 0
|
24
30
|
local content = blocks[i].content
|
25
31
|
|
26
|
-
for
|
32
|
+
for _, elem in ipairs(x.content) do
|
27
33
|
if elem.tag == "LineBreak" then
|
28
34
|
-- Count the repeated number of LineBreak
|
29
35
|
n_break = n_break + 1
|
@@ -136,7 +142,7 @@ local function caption_div(div)
|
|
136
142
|
end
|
137
143
|
|
138
144
|
local function noindent(para)
|
139
|
-
first = para.content[1]
|
145
|
+
local first = para.content[1]
|
140
146
|
|
141
147
|
if (first and (first.tag == "RawInline") and
|
142
148
|
(first.format == "tex") and
|
@@ -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 = {
|
@@ -161,13 +161,7 @@ function Para(s)
|
|
161
161
|
end
|
162
162
|
|
163
163
|
local function attr_val(attr, key)
|
164
|
-
|
165
|
-
for k, v in pairs(attr) do
|
166
|
-
if (k == key and v and v ~= "") then
|
167
|
-
return v
|
168
|
-
end
|
169
|
-
end
|
170
|
-
return ""
|
164
|
+
return attr[key] or ""
|
171
165
|
end
|
172
166
|
|
173
167
|
local function attr_classes(attr)
|
@@ -180,7 +174,7 @@ local function attr_classes(attr)
|
|
180
174
|
end
|
181
175
|
|
182
176
|
local function attr_scale(attr, key) -- a helper for CaptionedImage
|
183
|
-
scale = attr_val(attr, key)
|
177
|
+
local scale, count = attr_val(attr, key), 0
|
184
178
|
if (scale == "") or (key == "scale") then
|
185
179
|
return scale
|
186
180
|
end
|
@@ -195,10 +189,7 @@ local function attr_scale(attr, key) -- a helper for CaptionedImage
|
|
195
189
|
end
|
196
190
|
|
197
191
|
function Header(level, s, attr)
|
198
|
-
local headmark = ""
|
199
|
-
for i = 1, level do
|
200
|
-
headmark = headmark .. "="
|
201
|
-
end
|
192
|
+
local headmark = string.rep("=", level)
|
202
193
|
|
203
194
|
local classes = attr_classes(attr)
|
204
195
|
|
@@ -288,7 +279,7 @@ function CodeBlock(s, attr)
|
|
288
279
|
end
|
289
280
|
command = command or "list"
|
290
281
|
|
291
|
-
is_list = command == "list"
|
282
|
+
local is_list = command == "list"
|
292
283
|
|
293
284
|
|
294
285
|
local num = (is_list == false) and "" or (
|
@@ -411,7 +402,7 @@ function Table(caption, aligns, widths, headers, rows)
|
|
411
402
|
end
|
412
403
|
local tmp = {}
|
413
404
|
for i, h in pairs(headers) do
|
414
|
-
align = html_align(aligns[i])
|
405
|
+
local align = html_align(aligns[i])
|
415
406
|
if (config.use_table_align == "true") and (align ~= "") then
|
416
407
|
h = format_inline("dtp", "table align=" .. align) .. h
|
417
408
|
end
|
@@ -422,7 +413,7 @@ function Table(caption, aligns, widths, headers, rows)
|
|
422
413
|
for _, row in pairs(rows) do
|
423
414
|
tmp = {}
|
424
415
|
for i, c in pairs(row) do
|
425
|
-
align = html_align(aligns[i])
|
416
|
+
local align = html_align(aligns[i])
|
426
417
|
if (config.use_table_align == "true") and (align ~= "") then
|
427
418
|
c = format_inline("dtp", "table align=" .. align) .. c
|
428
419
|
end
|
@@ -477,6 +468,16 @@ function CaptionedImage(s, src, tit, attr)
|
|
477
468
|
)
|
478
469
|
end
|
479
470
|
|
471
|
+
function Image(s, src, tit, attr)
|
472
|
+
-- Re:VIEW @<icon> ignores caption and title
|
473
|
+
if attr.is_figure then
|
474
|
+
return CaptionedImage(src, s, tit, attr)
|
475
|
+
end
|
476
|
+
local id = string.gsub(src, "%.%w+$", "")
|
477
|
+
id = string.gsub(id, "^images/", "")
|
478
|
+
return format_inline("icon", id)
|
479
|
+
end
|
480
|
+
|
480
481
|
function Note(s)
|
481
482
|
note_num = note_num + 1
|
482
483
|
table.insert(footnotes, "//footnote[fn" .. note_num .. "][" .. s .. "]")
|
@@ -513,7 +514,7 @@ function Div(s, attr)
|
|
513
514
|
local blankline = attr_val(attr, "blankline")
|
514
515
|
if blankline ~= "" then
|
515
516
|
local buffer = {}
|
516
|
-
for
|
517
|
+
for _ = 1, tonumber(blankline) do
|
517
518
|
table.insert(buffer, "//blankline")
|
518
519
|
end
|
519
520
|
return table.concat(buffer, "\n")
|
@@ -576,7 +577,7 @@ function RawInline(format, text)
|
|
576
577
|
if (format == "tex") then
|
577
578
|
return format_inline("embed", "|latex|" .. text)
|
578
579
|
else
|
579
|
-
return format_inline("embed", "|" .. format .. "|"
|
580
|
+
return format_inline("embed", "|" .. format .. "|" .. text)
|
580
581
|
end
|
581
582
|
end
|
582
583
|
|
@@ -596,24 +597,38 @@ function RawBlock(format, text)
|
|
596
597
|
end
|
597
598
|
end
|
598
599
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
600
|
+
local function configure()
|
601
|
+
try_catch {
|
602
|
+
try = function()
|
603
|
+
metadata = PANDOC_DOCUMENT.meta
|
604
|
+
end,
|
605
|
+
catch = function(error)
|
606
|
+
log("Due to your pandoc version is too old, config.yml loader is disabled.\n")
|
607
|
+
end
|
608
|
+
}
|
607
609
|
|
608
|
-
if (metadata) then
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
610
|
+
if (metadata) then
|
611
|
+
-- Load config from YAML
|
612
|
+
for k, _ in pairs(config) do
|
613
|
+
if metadata[k] ~= nil then
|
614
|
+
config[k] = stringify(metadata[k])
|
615
|
+
end
|
613
616
|
end
|
614
617
|
end
|
615
618
|
end
|
616
619
|
|
620
|
+
if PANDOC_VERSION >= "3.0.0" then
|
621
|
+
-- NOTE: A wrapper to support Pandoc >= 3.0 https://pandoc.org/custom-writers.html#changes-in-pandoc-3.0
|
622
|
+
function Writer (doc, opts)
|
623
|
+
PANDOC_DOCUMENT = doc
|
624
|
+
PANDOC_WRITER_OPTIONS = opts
|
625
|
+
configure()
|
626
|
+
return pandoc.write_classic(doc, opts)
|
627
|
+
end
|
628
|
+
else
|
629
|
+
configure()
|
630
|
+
end
|
631
|
+
|
617
632
|
local meta = {}
|
618
633
|
meta.__index =
|
619
634
|
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.6.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-05 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: []
|