paru 0.4.1.2 → 0.4.2.3

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
  SHA256:
3
- metadata.gz: cd33d3d1738034e8ffeb4edcf0430d51f8f0dc05f23511535a4ba3e33c923d23
4
- data.tar.gz: c430452f484459c451088ad84db7b603748ed67b3397250c6ad0e1c1773fb89d
3
+ metadata.gz: 4922ee36a90c757e70a7b386cd25496c748a441191f1ea61160ab949aaa3672f
4
+ data.tar.gz: '0882bda88d548eb798bc526d76c38b85c3e64a2308a77a167146a6a6656fd6b6'
5
5
  SHA512:
6
- metadata.gz: 89f884fd65ffa81c1be750c5d5ad82d96805c81cfedd3d52c9481e817f9d3cdc47d4a4c79f8d396264d18e9ac4d5dc574e7e5a720ce288a38441eefbc32649e7
7
- data.tar.gz: 3c12fd5b577195595dec08a398a01dcec4d1297b41a97768fa3077b13c224a385aa0eec624275b98c2db5a938a12efccdc6cfc984f968331ddaf1b6b98c9bf48
6
+ metadata.gz: e20858edc2f613c76592e4f4ef8daba573298d3d843234e64aa2f06fb5d94890ebf125000a287efff2395decf1d25907b1cb09fd023a31578b5866ac3651f142
7
+ data.tar.gz: 66181db17a164acfb7776e2cf4f06f56cf6b757122da039dacbfd8b032f2b5e4b3f296fa1752013d6b343652ce961a4efab200d8b05a983b32fc08b6a816aaa1
@@ -60,6 +60,10 @@ module Paru
60
60
  @children.map {|row| row.to_ast}
61
61
  ]
62
62
  end
63
+
64
+ def to_ast()
65
+ ast_contents()
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -18,6 +18,7 @@
18
18
  #++
19
19
  require_relative "./block.rb"
20
20
  require_relative "./value.rb"
21
+ require_relative "./int_value.rb"
21
22
 
22
23
  module Paru
23
24
  module PandocFilter
@@ -44,8 +45,8 @@ module Paru
44
45
  def initialize(contents)
45
46
  @attr = Attr.new contents[0]
46
47
  @alignment = Value.new contents[1]
47
- @rowspan = Value.new contents[2]
48
- @colspan = Value.new contents[3]
48
+ @rowspan = IntValue.new contents[2]
49
+ @colspan = IntValue.new contents[3]
49
50
 
50
51
  super contents[4]
51
52
  end
@@ -62,6 +63,10 @@ module Paru
62
63
  @children.map {|child| child.to_ast}
63
64
  ]
64
65
  end
66
+
67
+ def to_ast()
68
+ ast_contents()
69
+ end
65
70
  end
66
71
  end
67
72
  end
@@ -36,7 +36,7 @@ module Paru
36
36
 
37
37
  # The current pandoc type version
38
38
  # @see https://hackage.haskell.org/package/pandoc-types
39
- CURRENT_PANDOC_VERSION = [1, 21]
39
+ CURRENT_PANDOC_VERSION = [1, 22]
40
40
 
41
41
  # Each file that is being filtered by pandoc is represented by a root
42
42
  # Document. It is the root node of the AST of the document in the file.
@@ -0,0 +1,39 @@
1
+ #--
2
+ # Copyright 2020 Huub de Beer <Huub@heerdebeer.org>
3
+ #
4
+ # This file is part of Paru
5
+ #
6
+ # Paru is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Paru is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+ require_relative "./node.rb"
20
+ require_relative "../filter_error.rb"
21
+
22
+ module Paru
23
+ module PandocFilter
24
+
25
+ # An IntValue represents some sort of integer metadata about block or
26
+ # inline nodes
27
+ class IntValue
28
+ attr_accessor :value
29
+
30
+ def initialize(value)
31
+ @value = value
32
+ end
33
+
34
+ def to_ast()
35
+ @value
36
+ end
37
+ end
38
+ end
39
+ end
@@ -38,7 +38,10 @@ module Paru
38
38
  # this Row node
39
39
  def initialize(contents = [])
40
40
  @attr = Attr.new contents[0]
41
- super contents[1]
41
+ super []
42
+ contents[1].each do |cell|
43
+ @children.push Cell.new cell
44
+ end
42
45
  end
43
46
 
44
47
  # The cells of this row
@@ -58,6 +61,10 @@ module Paru
58
61
  ]
59
62
  end
60
63
 
64
+ def to_ast()
65
+ ast_contents()
66
+ end
67
+
61
68
  # Convert this Row to an array of markdown strings, one for
62
69
  # each cell
63
70
  #
@@ -54,11 +54,14 @@ module Paru
54
54
  # @param contents [Array]
55
55
  def initialize(contents)
56
56
  @attr = Attr.new contents[0]
57
- @caption = Caption.new contents[1]["c"]
57
+ @caption = Caption.new contents[1]
58
58
  @colspec = contents[2].map {|p| ColSpec.new p}
59
- @head = TableHead.new contents[3]["c"]
60
- super contents[4]
61
- @foot = TableFoot.new contents[5]["c"]
59
+ @head = TableHead.new contents[3]
60
+ super []
61
+ contents[4].each do |table_body|
62
+ @children.push TableBody.new table_body
63
+ end
64
+ @foot = TableFoot.new contents[5]
62
65
  end
63
66
 
64
67
  # The AST contents of this Table node
@@ -83,7 +86,7 @@ module Paru
83
86
  #
84
87
  # @return [String[][]] This Table as a 2D array of cells
85
88
  # represented by their markdown strings.
86
- def to_array(**config)
89
+ def to_array(config = {})
87
90
  headers = if config.has_key? :headers then config[:headers] else false end
88
91
  footers = if config.has_key? :footers then config[:footers] else false end
89
92
 
@@ -108,9 +111,9 @@ module Paru
108
111
  #
109
112
  # @param filename [String] filename to write to
110
113
  # @param config [Hash] See #to_array for config options
111
- def to_file(filename, **config)
114
+ def to_file(filename, config = {})
112
115
  CSV.open(filename, "wb") do |csv|
113
- to_array(config).each {|row| csv << row}
116
+ to_array(**config).each {|row| csv << row}
114
117
  end
115
118
  end
116
119
 
@@ -127,7 +130,7 @@ module Paru
127
130
  # default to false.
128
131
  #
129
132
  # @return [Table]
130
- def self.from_array(data, **config)
133
+ def self.from_array(data, config = {})
131
134
  # With the updated Table definition, it has become complicated
132
135
  # to construct a table manually. It has gotten easier to just
133
136
  # construct a string containing a table in Pandoc's markdown and
@@ -177,7 +180,7 @@ module Paru
177
180
  # @param config [Hash] See #from_file for details
178
181
  #
179
182
  # @return [Table]
180
- def self.from_file(filename, **config)
183
+ def self.from_file(filename, config = {})
181
184
  data = []
182
185
  CSV.foreach(filename) do |row|
183
186
  data << row
@@ -44,12 +44,12 @@ module Paru
44
44
  # @param contents [Array] The contents of this TableBody
45
45
  def initialize(contents)
46
46
  @attr = Attr.new contents[0]
47
- @rowheadcolumns = Value.new contents[1]
47
+ @rowheadcolumns = IntValue.new contents[1]
48
48
  @rowheadercolumns = contents[2].map {|r| Row.new r}
49
49
 
50
50
  super []
51
51
  contents[3].each do |row|
52
- @children.push Row.new row["c"]
52
+ @children.push Row.new row
53
53
  end
54
54
  end
55
55
 
@@ -71,6 +71,10 @@ module Paru
71
71
  @children.map {|child| child.to_ast}
72
72
  ]
73
73
  end
74
+
75
+ def to_ast()
76
+ ast_contents()
77
+ end
74
78
 
75
79
  # Convert this table end to a 2D table of markdown strings for each
76
80
  # cell
@@ -38,7 +38,10 @@ module Paru
38
38
  # @param contents [Array]
39
39
  def initialize(contents)
40
40
  @attr = Attr.new contents[0]
41
- super contents[1]
41
+ super []
42
+ contents[1].each do |row|
43
+ @children.push Row.new row
44
+ end
42
45
  end
43
46
 
44
47
  def rows()
@@ -54,6 +57,10 @@ module Paru
54
57
  @children.map {|row| row.to_ast},
55
58
  ]
56
59
  end
60
+
61
+ def to_ast()
62
+ ast_contents()
63
+ end
57
64
 
58
65
  # Convert this table end to a 2D table of markdown strings for each
59
66
  # cell
data/lib/paru/pandoc.rb CHANGED
@@ -230,26 +230,23 @@ module Paru
230
230
  .match(/pandoc.* (\d+\.\d+.*)$/)[1]
231
231
  .split(".")
232
232
  .map {|s| s.to_i}
233
- major_version, minor_version = version
234
-
235
- if major_version >= 2 and minor_version >= 7 then
236
- # Pandoc version 2.7 introduced a new default data dir to comply
237
- # with XDG Base Directory Specification
238
- xdg_data_dir, old_data_dir = version_string.match(/Default user data directory: (.+)$/)[1].split(" or ")
239
-
240
- if File.directory? xdg_data_dir then
241
- data_dir = xdg_data_dir
242
- elsif not old_data_dir.nil? and File.directory? old_data_dir then
243
- # The new-style data directory does not exist, but the
244
- # old-style does, so use the old-style data directory for
245
- # backwards compatibility
246
- data_dir = old_data_dir
247
- else
248
- # Neither data directory exists, default to the new default
249
- data_dir = xdg_data_dir
250
- end
233
+ major_version = version[0]
234
+
235
+ # Pandoc version 2.7 introduced a new default data dir to comply
236
+ # with XDG Base Directory Specification
237
+
238
+ xdg_data_dir, old_data_dir = version_string.match(/User data directory: (.+)$/)[1].split(" or ")
239
+
240
+ if File.directory? xdg_data_dir then
241
+ data_dir = xdg_data_dir
242
+ elsif not old_data_dir.nil? and File.directory? old_data_dir then
243
+ # The new-style data directory does not exist, but the
244
+ # old-style does, so use the old-style data directory for
245
+ # backwards compatibility
246
+ data_dir = old_data_dir
251
247
  else
252
- data_dir = version_string.match(/Default user data directory: (.+)$/)[1]
248
+ # Neither data directory exists, default to the new default
249
+ data_dir = xdg_data_dir
253
250
  end
254
251
 
255
252
  @@info = {
@@ -44,8 +44,10 @@ help: true
44
44
  # General reader options:
45
45
  #####
46
46
  shift_heading_level_by: 1
47
+ base_header_level: 1
48
+ strip_empty_paragraphs: true
47
49
  indented_code_classes: ""
48
- default_image_extension: ""
50
+ default_image_extension: "png"
49
51
  file_scope: true
50
52
  filter: [""]
51
53
  lua_filter: [""]
@@ -59,6 +61,7 @@ abbreviations: ""
59
61
  #####
60
62
  # General writing options:
61
63
  #####
64
+ sandbox: false
62
65
  standalone: true
63
66
  template: ""
64
67
  variable: [""]
@@ -68,7 +71,6 @@ eol: "native"
68
71
  dpi: 96
69
72
  wrap: "auto"
70
73
  columns: 78
71
- strip_comments: true
72
74
  toc: true
73
75
  table_of_contents: true
74
76
  toc_depth: 3
@@ -91,7 +93,8 @@ html_q_tags: true
91
93
  ascii: true
92
94
  reference_links: true
93
95
  reference_location: "block"
94
- atx_headers: ""
96
+ markdown_headings: "atx"
97
+ atx_headers: false
95
98
  top_level_division: "section"
96
99
  number_sections: true
97
100
  number_offset: 2
@@ -99,7 +102,6 @@ listings: true
99
102
  incremental: true
100
103
  slide_level: 1
101
104
  section_divs: true
102
- default_image_extension: "png"
103
105
  email_obfuscation: "none"
104
106
  id_prefix: ""
105
107
  title_prefix: ""
@@ -116,9 +118,10 @@ pdf_engine_opt: [""]
116
118
  #####
117
119
  # Citation rendering
118
120
  #####
121
+ citeproc: true
119
122
  bibliography: ""
120
123
  csl: ""
121
- citation_abbreviations: ""
124
+ citation_abbreviations: ""
122
125
  natbib: true
123
126
  biblatex: true
124
127
  #####
data/lib/paru.rb CHANGED
@@ -18,5 +18,5 @@
18
18
  #++
19
19
  module Paru
20
20
  # Paru's current version
21
- VERSION = [0, 4, 1, 2]
21
+ VERSION = [0, 4, 2, 3]
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1.2
4
+ version: 0.4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-16 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Control pandoc with Ruby and write pandoc filters in Ruby
14
14
  email: Huub@heerdebeer.org
@@ -47,6 +47,7 @@ files:
47
47
  - lib/paru/filter/image.rb
48
48
  - lib/paru/filter/inline.rb
49
49
  - lib/paru/filter/inner_markdown.rb
50
+ - lib/paru/filter/int_value.rb
50
51
  - lib/paru/filter/line_block.rb
51
52
  - lib/paru/filter/line_break.rb
52
53
  - lib/paru/filter/link.rb
@@ -109,15 +110,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
110
  requirements:
110
111
  - - ">="
111
112
  - !ruby/object:Gem::Version
112
- version: '2.5'
113
+ version: 2.6.8
113
114
  required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  requirements:
115
116
  - - ">="
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
119
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 2.7.7
120
+ rubygems_version: 3.2.3
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Paru is a ruby wrapper around pandoc