paru 1.0.3 → 1.1.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
  SHA256:
3
- metadata.gz: 24975da849bee7997a85776e257d620b13ed93d6b389841eaebe5946c0e2db0d
4
- data.tar.gz: 861159dc635fdbea547993a479010890b2183cb37b72e20a44b507efd44bcc00
3
+ metadata.gz: 8c755de6d48a630fc826d7fb2f41474c38e4026fb8767b06f64130fbff071ec4
4
+ data.tar.gz: 78b2ebba41c1061afb0cd39c891338dfcd0d56d8dd61de3c1fcb0c8a05dfd4ea
5
5
  SHA512:
6
- metadata.gz: 014d9483bd9a25af560d615f2af241febd6578df578d0635215ea4368cb6e132e00f07ddf105597c60df5b381ac3934bc3d33e1309ac102212eb47ce929313e7
7
- data.tar.gz: 826338759e77839a66968c0105c3a7e90ed08023e0d3dd9b031d62142024686b80642a8a503eef700ad46b22d936277d45e8b5c7d4d046c29f380edac4ed3f68
6
+ metadata.gz: a16c55e12ae8c05503257228f859d2eea710493ef6161b760182cc98a9e8f7901927856c2ab7e0488257d8cae16649c8a1360d5d4e015a3a22dd21b84ab3c34d
7
+ data.tar.gz: 62b9b722c6d1ea351c5cc5a7ef07e5591be7d4be30917d3b0b940a6e8ae728c574a30b1ad35b9a3ac701a7ac81276b4ae059f44b96357a40325d1784bb31f01e
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2020 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2020, 2023 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,12 +17,15 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
  require_relative "./block.rb"
20
+ require_relative "./inner_markdown.rb"
20
21
  require_relative "./short_caption.rb"
21
22
 
22
23
  module Paru
23
24
  module PandocFilter
24
- # A table's caption, can contain an optional short caption
25
+ # A table or figure's caption, can contain an optional short caption
25
26
  class Caption < Block
27
+ include InnerMarkdown
28
+
26
29
  attr_accessor :short
27
30
 
28
31
  # Create a new Caption based on the contents
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016, 2017, 2020 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017, 2020, 2023 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -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, 22]
39
+ CURRENT_PANDOC_VERSION = [1, 23]
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,65 @@
1
+ #--
2
+ # Copyright 2023 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 "./block.rb"
20
+ require_relative "./attr.rb"
21
+ require_relative "./caption.rb"
22
+ require_relative "./inner_markdown.rb"
23
+
24
+ module Paru
25
+ module PandocFilter
26
+ # A Figure node consisting of an attribute object, a caption, and a list of Block nodes.
27
+ class Figure < Block
28
+ include InnerMarkdown
29
+
30
+ # A Figure node has an attribute object
31
+ #
32
+ # @!attribute attr
33
+ # @return [Attr]
34
+ #
35
+ # @!attribute caption
36
+ # @return Caption
37
+ attr_accessor :attr, :caption
38
+
39
+ # Create a new Figure node based on the contents
40
+ #
41
+ # @param contents [Array]
42
+ def initialize(contents)
43
+ @attr = Attr.new contents[0]
44
+ @caption = Caption.new contents[1]
45
+ super contents[2]
46
+ end
47
+
48
+ # Create an AST representation of this Figure node.
49
+ def ast_contents()
50
+ [
51
+ @attr.to_ast,
52
+ @caption.to_ast,
53
+ super
54
+ ]
55
+ end
56
+
57
+ # Has this Figure node Blocks as children?
58
+ #
59
+ # @return [Boolean] true
60
+ def has_block?
61
+ true
62
+ end
63
+ end
64
+ end
65
+ end
@@ -68,6 +68,7 @@ module Paru
68
68
  require_relative './table_foot.rb'
69
69
  require_relative './row.rb'
70
70
  require_relative './cell.rb'
71
+ require_relative './figure.rb'
71
72
 
72
73
  # Inline level nodes
73
74
  require_relative './cite.rb'
@@ -386,7 +387,7 @@ module Paru
386
387
  # Only using first block node (paragraph?)
387
388
  if is_inline?
388
389
  temp_doc = temp_doc.children.first
389
-
390
+
390
391
  if not temp_doc.children.all? {|node| node.is_inline?}
391
392
  raise Error.new "Cannot replace the inline level node represented by '#{self.markdown}' with markdown that converts to block level nodes: '#{markdown}'."
392
393
  end
data/lib/paru/filter.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016, 2017, 2022 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017, 2022, 2023 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -22,7 +22,7 @@ require_relative "./filter/metadata.rb"
22
22
 
23
23
  module Paru
24
24
  # Paru filter is a wrapper around pandoc's JSON api, which is based on
25
- # {pandoc-types}[https://hackage.haskell.org/package/pandoc-types-1.17.0.4/docs/Text-Pandoc-Definition.html].
25
+ # {pandoc-types}[https://hackage.haskell.org/package/pandoc-types-1.23/docs/Text-Pandoc-Definition.html].
26
26
  # Pandoc treats block elements and inline elements differently.
27
27
  #
28
28
  # Pandoc's block elements are:
@@ -44,6 +44,7 @@ module Paru
44
44
  "TableBody",
45
45
  "Row",
46
46
  "Cell",
47
+ "Figure",
47
48
  "Caption",
48
49
  "Div",
49
50
  "Null"
@@ -284,13 +285,13 @@ module Paru
284
285
  end
285
286
  end
286
287
 
288
+ @current_node = @document
289
+
287
290
  @ran_before = false
288
291
  @ran_after = false
289
292
  instance_eval(&block) # run filter with before block
290
293
  @ran_before = true
291
294
 
292
- @current_node = @document
293
-
294
295
  nodes_to_filter.each do |node|
295
296
  if @current_node.has_been_replaced?
296
297
  @current_node = @current_node.get_replacement
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016, 2017, 2022 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015, 2016, 2017, 2022, 2023 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -17,7 +17,7 @@
17
17
  # along with Paru. If not, see <http://www.gnu.org/licenses/>.
18
18
  # See http://pandoc.org/README.html for an overview of all options
19
19
  #++
20
- # In order as listed on http://pandoc.org/MANUAL.html (version 2)
20
+ # In order as listed on http://pandoc.org/MANUAL.html (version 3)
21
21
  #####
22
22
  # General options:
23
23
  #####
@@ -96,6 +96,7 @@ ascii: true
96
96
  reference_links: true
97
97
  reference_location: "block"
98
98
  markdown_headings: "atx"
99
+ list_tables: true
99
100
  atx_headers: true
100
101
  top_level_division: "section"
101
102
  number_sections: true
@@ -109,7 +110,10 @@ id_prefix: ""
109
110
  title_prefix: ""
110
111
  css: [""]
111
112
  reference_doc: ""
113
+ split_level: 1
114
+ chunk_template: ""
112
115
  epub_cover_image: ""
116
+ epub_title_page: true
113
117
  epub_metadata: ""
114
118
  epub_embed_font: ""
115
119
  epub_chapter_level: 1
data/lib/paru.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2015, 2016, 2017, 2018, 2019, 2020, 2022 Huub de Beer <Huub@heerdebeer.org>
2
+ # Copyright 2015--2023 Huub de Beer <Huub@heerdebeer.org>
3
3
  #
4
4
  # This file is part of Paru
5
5
  #
@@ -18,5 +18,5 @@
18
18
  #++
19
19
  module Paru
20
20
  # Paru's current version
21
- VERSION = [1, 0, 3].freeze
21
+ VERSION = [1, 1, 1].freeze
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: 1.0.3
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huub de Beer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-07 00:00:00.000000000 Z
11
+ date: 2023-05-13 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
@@ -42,6 +42,7 @@ files:
42
42
  - lib/paru/filter/emph.rb
43
43
  - lib/paru/filter/empty_block.rb
44
44
  - lib/paru/filter/empty_inline.rb
45
+ - lib/paru/filter/figure.rb
45
46
  - lib/paru/filter/header.rb
46
47
  - lib/paru/filter/horizontal_rule.rb
47
48
  - lib/paru/filter/image.rb
@@ -102,7 +103,7 @@ homepage: https://heerdebeer.org/Software/markdown/paru/
102
103
  licenses:
103
104
  - GPL-3.0
104
105
  metadata: {}
105
- post_install_message:
106
+ post_install_message:
106
107
  rdoc_options: []
107
108
  require_paths:
108
109
  - lib
@@ -117,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.3.7
121
- signing_key:
121
+ rubygems_version: 3.4.10
122
+ signing_key:
122
123
  specification_version: 4
123
124
  summary: Paru is a ruby wrapper around pandoc
124
125
  test_files: []