pandocomatic 1.1.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pandocomatic/cli.rb +57 -5
- data/lib/pandocomatic/command/command.rb +3 -10
- data/lib/pandocomatic/command/convert_dir_command.rb +4 -1
- data/lib/pandocomatic/command/convert_file_command.rb +28 -12
- data/lib/pandocomatic/command/convert_file_multiple_command.rb +6 -4
- data/lib/pandocomatic/command/convert_list_command.rb +4 -2
- data/lib/pandocomatic/command/copy_file_command.rb +4 -1
- data/lib/pandocomatic/command/create_link_command.rb +4 -1
- data/lib/pandocomatic/configuration.rb +124 -12
- data/lib/pandocomatic/default_configuration.yaml +1 -0
- data/lib/pandocomatic/error/pandocomatic_error.rb +1 -1
- data/lib/pandocomatic/input.rb +1 -3
- data/lib/pandocomatic/pandoc_metadata.rb +18 -9
- data/lib/pandocomatic/pandocomatic.rb +109 -5
- data/lib/pandocomatic/pandocomatic_yaml.rb +1 -1
- data/lib/pandocomatic/printer/command_printer.rb +1 -1
- data/lib/pandocomatic/printer/configuration_errors_printer.rb +8 -2
- data/lib/pandocomatic/printer/error_printer.rb +3 -2
- data/lib/pandocomatic/printer/finish_printer.rb +1 -1
- data/lib/pandocomatic/printer/help_printer.rb +1 -1
- data/lib/pandocomatic/printer/printer.rb +1 -0
- data/lib/pandocomatic/printer/summary_printer.rb +1 -1
- data/lib/pandocomatic/printer/unknown_error_printer.rb +39 -0
- data/lib/pandocomatic/printer/version_printer.rb +1 -1
- data/lib/pandocomatic/printer/views/cli_error.txt +3 -0
- data/lib/pandocomatic/printer/views/help.txt +26 -9
- data/lib/pandocomatic/printer/views/pandoc_metadata_error.txt +1 -1
- data/lib/pandocomatic/printer/views/unknown_error.txt +2 -0
- data/lib/pandocomatic/printer/warning_printer.rb +3 -2
- data/lib/pandocomatic/processors/fileinfo_preprocessor.rb +17 -12
- data/lib/pandocomatic/processors/metadata_preprocessor.rb +7 -5
- data/lib/pandocomatic/template.rb +1 -1
- data/lib/pandocomatic/version.rb +2 -2
- metadata +50 -20
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2014-
|
4
|
+
# Copyright 2014-2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -26,6 +26,7 @@ module Pandocomatic
|
|
26
26
|
require_relative 'error/pandoc_metadata_error'
|
27
27
|
require_relative 'pandocomatic_yaml'
|
28
28
|
|
29
|
+
# Regular expression to find the start of metadata blocks in a string.
|
29
30
|
BLOCK_START = /^---[ \t]*$/
|
30
31
|
|
31
32
|
# Regular expression to find metadata blocks in a string. This regular
|
@@ -45,6 +46,15 @@ module Pandocomatic
|
|
45
46
|
extract_metadata(input).first
|
46
47
|
end
|
47
48
|
|
49
|
+
# Create an empty metadata object with only the source format set.
|
50
|
+
#
|
51
|
+
# @param src_format [String] the source format
|
52
|
+
# @return [PandocMetadata[ empty metadata with only pandoc's source format
|
53
|
+
# set.
|
54
|
+
def self.empty(src_format)
|
55
|
+
PandocMetadata.new({ 'pandocomatic_' => { 'pandoc' => { 'from' => src_format } } })
|
56
|
+
end
|
57
|
+
|
48
58
|
# Collect the metadata embedded in the src file and create a new
|
49
59
|
# PandocMetadata instance
|
50
60
|
#
|
@@ -236,20 +246,19 @@ module Pandocomatic
|
|
236
246
|
|
237
247
|
def extract_blocks(input, path)
|
238
248
|
starts = input.scan(BLOCK_START)
|
249
|
+
|
239
250
|
if starts.empty?
|
240
251
|
# No YAML metadata blocks expected
|
241
252
|
return []
|
242
253
|
end
|
243
254
|
|
244
255
|
# Expect YAML metadata blocks
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
raise PandocMetadataError.new :expected_to_find_YAML_metadata_blocks, e, path
|
252
|
-
end
|
256
|
+
input
|
257
|
+
.scan(METADATA_BLOCK)
|
258
|
+
.map { |match| PandocomaticYAML.load "---#{match.join}...", path }
|
259
|
+
.select { |block| !block.nil? and !block.empty? }
|
260
|
+
rescue StandardError => e
|
261
|
+
raise PandocMetadataError.new :expected_to_find_YAML_metadata_blocks, e, path
|
253
262
|
end
|
254
263
|
end
|
255
264
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2014—
|
4
|
+
# Copyright 2014—2024, Huub de Beer <huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -22,6 +22,7 @@ module Pandocomatic
|
|
22
22
|
Encoding.default_external = Encoding::UTF_8 # ensure unicode encoding
|
23
23
|
Encoding.default_internal = Encoding::UTF_8
|
24
24
|
|
25
|
+
require 'logger'
|
25
26
|
require 'paru'
|
26
27
|
require 'tempfile'
|
27
28
|
|
@@ -36,6 +37,7 @@ module Pandocomatic
|
|
36
37
|
require_relative 'printer/configuration_errors_printer'
|
37
38
|
require_relative 'printer/finish_printer'
|
38
39
|
require_relative 'printer/summary_printer'
|
40
|
+
require_relative 'printer/unknown_error_printer'
|
39
41
|
|
40
42
|
require_relative 'command/convert_dir_command'
|
41
43
|
require_relative 'command/convert_list_command'
|
@@ -45,7 +47,98 @@ module Pandocomatic
|
|
45
47
|
require_relative 'version'
|
46
48
|
|
47
49
|
# The Pandocomatic class controlls the pandocomatic conversion process
|
48
|
-
|
50
|
+
module Pandocomatic
|
51
|
+
# Pandocomatic's log. Depending on given command-line arguments,
|
52
|
+
# pandocomatic will log its actions to file or not log anything at all.
|
53
|
+
class Log
|
54
|
+
# Add pandocomatic's command-line arguments to the log
|
55
|
+
#
|
56
|
+
# @param [String[]] args
|
57
|
+
def pandocomatic_called_with(args)
|
58
|
+
@args = if args.respond_to? :join
|
59
|
+
args.join(' ')
|
60
|
+
else
|
61
|
+
args
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Install a logger that writes to a given log file for given log level
|
66
|
+
#
|
67
|
+
# @param log_file [String] name or path to log file
|
68
|
+
# @param log_level [String] log level, one of "fatal", "error",
|
69
|
+
# "warning", or "debug". Defaults to "info"
|
70
|
+
def install_file_logger(log_file, log_level = 'info')
|
71
|
+
unless log_file.nil?
|
72
|
+
begin
|
73
|
+
@logger = Logger.new(log_file, level: log_level)
|
74
|
+
@logger.formatter = proc do |severity, datetime, _progname, msg|
|
75
|
+
date_format = datetime.strftime('%Y-%m-%d %H:%M:%S')
|
76
|
+
"#{date_format} #{severity.ljust(5)}: #{msg}\n"
|
77
|
+
end
|
78
|
+
rescue StandardError => e
|
79
|
+
warn "Unable to create log file '#{log_file}' with log level '#{log_level}' because:\n#{e}."
|
80
|
+
warn 'Continuing with logging disabled.'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
info '------------ START ---------------'
|
85
|
+
info "Running #{$PROGRAM_NAME} #{@args}"
|
86
|
+
end
|
87
|
+
|
88
|
+
# Log a debug message
|
89
|
+
#
|
90
|
+
# @param [String] msg
|
91
|
+
def debug(msg)
|
92
|
+
@logger&.debug(msg)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Log an error message
|
96
|
+
#
|
97
|
+
# @param [String] msg
|
98
|
+
def error(msg)
|
99
|
+
@logger&.error(msg)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Log a fatal message
|
103
|
+
#
|
104
|
+
# @param [String] msg
|
105
|
+
def fatal(msg)
|
106
|
+
@logger&.fatal(msg)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Log an informational message
|
110
|
+
#
|
111
|
+
# @param [String] msg
|
112
|
+
def info(msg)
|
113
|
+
@logger&.info(msg)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Log a warning message
|
117
|
+
#
|
118
|
+
# @param [String] msg
|
119
|
+
def warn(msg)
|
120
|
+
@logger&.warn(msg)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Indent given string with given number of spaces. Intended for logging
|
124
|
+
# purposes.
|
125
|
+
#
|
126
|
+
# @param str [String] string to indent
|
127
|
+
# @param number_of_spaces [Number] number of spaces to indent string
|
128
|
+
# @return [String] indented string
|
129
|
+
def indent(str, number_of_spaces)
|
130
|
+
str.split("\n").join("\n#{' ' * number_of_spaces}")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
private_constant :Log
|
135
|
+
|
136
|
+
# Global logger for pandocomatic
|
137
|
+
LOG = Log.new
|
138
|
+
|
139
|
+
# Feature toggles supported by pandocomatic
|
140
|
+
FEATURES = [:pandoc_verbose].freeze
|
141
|
+
|
49
142
|
# Pandocomatic error status codes start from ERROR_STATUS
|
50
143
|
ERROR_STATUS = 1266 # This is the sum of the ASCII values of the characters in 'pandocomatic'
|
51
144
|
|
@@ -55,8 +148,12 @@ module Pandocomatic
|
|
55
148
|
#
|
56
149
|
# @param args [String[]] list of options to configure pandocomatic
|
57
150
|
def self.run(args)
|
151
|
+
LOG.pandocomatic_called_with args
|
58
152
|
start_time = Time.now
|
59
|
-
|
153
|
+
|
154
|
+
# Depending on given command-line arguments, CLI#parse! also
|
155
|
+
# installs a file logger in LOG.
|
156
|
+
configuration = CLI.parse! args
|
60
157
|
|
61
158
|
if configuration.show_version?
|
62
159
|
# The version option has precedence over all other options; if
|
@@ -75,6 +172,12 @@ module Pandocomatic
|
|
75
172
|
exit ERROR_STATUS
|
76
173
|
end
|
77
174
|
|
175
|
+
if configuration.dry_run?
|
176
|
+
LOG.debug 'Start dry-run conversion:'
|
177
|
+
else
|
178
|
+
LOG.debug 'Start conversion:'
|
179
|
+
end
|
180
|
+
|
78
181
|
# Run the pandocomatic converter configured according to the options
|
79
182
|
# given.
|
80
183
|
#
|
@@ -115,10 +218,11 @@ module Pandocomatic
|
|
115
218
|
rescue StandardError => e
|
116
219
|
# An unexpected error has occurred; break off the program drastically
|
117
220
|
# for now. This is likely a bug: ask the user to report it.
|
118
|
-
|
119
|
-
|
221
|
+
UnknownErrorPrinter.new(e).print
|
222
|
+
exit ERROR_STATUS + 2
|
120
223
|
ensure
|
121
224
|
configuration&.clean_up!
|
225
|
+
LOG.info "------------ END ---------------\n"
|
122
226
|
end
|
123
227
|
end
|
124
228
|
|
@@ -61,7 +61,7 @@ module Pandocomatic
|
|
61
61
|
str.gsub(VAR_PATTERN) do |_match|
|
62
62
|
key = Regexp.last_match(1)
|
63
63
|
|
64
|
-
raise TemplateError.new(:environment_variable_does_not_exist, { key
|
64
|
+
raise TemplateError.new(:environment_variable_does_not_exist, { key:, path: }) unless ENV.key? key
|
65
65
|
|
66
66
|
ENV.fetch(key, nil)
|
67
67
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
|
4
|
+
# Copyright 2017—2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -25,8 +25,14 @@ module Pandocomatic
|
|
25
25
|
class ConfigurationErrorsPrinter < Printer
|
26
26
|
# Create a new ConfigurationErrorsPrinter
|
27
27
|
def initialize(errors)
|
28
|
-
super
|
28
|
+
super('configuration_errors.txt')
|
29
29
|
@errors = errors
|
30
30
|
end
|
31
|
+
|
32
|
+
# Print configuration errors to STDOUT
|
33
|
+
def print
|
34
|
+
Pandocomatic::LOG.warn self
|
35
|
+
warn self
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
|
4
|
+
# Copyright 2017—2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -30,12 +30,13 @@ module Pandocomatic
|
|
30
30
|
else
|
31
31
|
'error.txt'
|
32
32
|
end
|
33
|
-
super
|
33
|
+
super(template)
|
34
34
|
@error = error
|
35
35
|
end
|
36
36
|
|
37
37
|
# Print an Error to STDERR rather than STDOUT
|
38
38
|
def print
|
39
|
+
Pandocomatic::LOG.error self
|
39
40
|
warn self
|
40
41
|
end
|
41
42
|
end
|
@@ -33,7 +33,7 @@ module Pandocomatic
|
|
33
33
|
# pandocomatic invokation
|
34
34
|
# @param start_time [Time] the time the command was started
|
35
35
|
def initialize(command, configuration, start_time)
|
36
|
-
super
|
36
|
+
super(command, configuration)
|
37
37
|
template 'finish.txt'
|
38
38
|
|
39
39
|
@start_time = start_time
|
@@ -29,7 +29,7 @@ module Pandocomatic
|
|
29
29
|
# @param configuration [Configuration] the configuration of the
|
30
30
|
# pandocomatic invokation
|
31
31
|
def initialize(command, configuration)
|
32
|
-
super
|
32
|
+
super('summary.txt')
|
33
33
|
@command = command
|
34
34
|
@input = configuration.input.to_s
|
35
35
|
@output = if configuration.stdout?
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright 2024, Huub de Beer <Huub@heerdebeer.org>
|
5
|
+
#
|
6
|
+
# This file is part of pandocomatic.
|
7
|
+
#
|
8
|
+
# Pandocomatic is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by the
|
10
|
+
# Free Software Foundation, either version 3 of the License, or (at your
|
11
|
+
# option) any later version.
|
12
|
+
#
|
13
|
+
# Pandocomatic is distributed in the hope that it will be useful, but
|
14
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
# for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License along
|
19
|
+
# with pandocomatic. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#++
|
21
|
+
module Pandocomatic
|
22
|
+
require_relative 'printer'
|
23
|
+
|
24
|
+
# Printer for Errors in non-quiet mode
|
25
|
+
class UnknownErrorPrinter < Printer
|
26
|
+
# Create a new ErrorPrinter
|
27
|
+
def initialize(error)
|
28
|
+
template = 'unknown_error.txt'
|
29
|
+
super(template)
|
30
|
+
@error = error
|
31
|
+
end
|
32
|
+
|
33
|
+
# Print an Error to STDERR rather than STDOUT
|
34
|
+
def print
|
35
|
+
Pandocomatic::LOG.error self
|
36
|
+
warn self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -17,6 +17,9 @@ Using `--stdout/-s` with an input directory is not allowed.
|
|
17
17
|
<% when :cannot_use_both_output_and_stdout %>
|
18
18
|
Using both `--output/-o` and `--stdout/-s` is not allowed.
|
19
19
|
Use eiter a specific output file or directory, or standard out, not both.
|
20
|
+
<% when :feature_toggle_does_not_exist %>
|
21
|
+
'<%= @error.data %>'.
|
22
|
+
Pandocomatic supports the following feature toggles: <%= Pandocomatic::FEATURES.map{|f| f.to_s}.join(", ") %>.
|
20
23
|
<% else %>
|
21
24
|
'<%= @error.data %>'.
|
22
25
|
<% end %>
|
@@ -105,26 +105,43 @@ OPTIONS
|
|
105
105
|
Default is FALSE.
|
106
106
|
|
107
107
|
-V, --verbose Run pandocomatic verbosely. Default is FALSE. Pandocomatic
|
108
|
-
runs quietly unless the verbose,
|
109
|
-
are given.
|
110
|
-
|
111
|
-
-b, --debug Run pandocomatic in debug mode: show the pandoc invocations
|
112
|
-
before each conversion. Default is FALSE. In debug mode,
|
113
|
-
pandocomatic runs verbosely.
|
108
|
+
runs quietly unless the verbose, or dry-run options are given.
|
114
109
|
|
115
110
|
-y, --dry-run Configure pandocomatic to run the conversion process, but do
|
116
111
|
not actually run it. Default is FALSE. When using this
|
117
112
|
dry-run option, pandocomatic runs verbosely.
|
118
113
|
|
119
|
-
|
120
|
-
Experimental:
|
121
|
-
|
122
114
|
-r PATH, --root-path PATH
|
123
115
|
Set the root path to use with paths that are specified as
|
124
116
|
relative to that root path. It is used mostly with the
|
125
117
|
--css pandoc option. It defaults to the directory of the
|
126
118
|
specified output.
|
127
119
|
|
120
|
+
-e FEATURE, --enable FEATURE
|
121
|
+
Enable FEATURE in pandocomatic. Pandocomatic supports the
|
122
|
+
following feature toggles:
|
123
|
+
|
124
|
+
- "pandoc-verbose" to enable using pandoc's verbose option.
|
125
|
+
By default pandocomatic removes that verbose option
|
126
|
+
because it can interfere with running pandoc filters or
|
127
|
+
pandocomatic processors.
|
128
|
+
|
129
|
+
Logging:
|
130
|
+
|
131
|
+
-l [FILE], --log [FILE]
|
132
|
+
|
133
|
+
Let pandocomatic log what it is doing to FILE. If FILE is
|
134
|
+
not given, pandocomatic uses 'pandocomatic.log'. Control
|
135
|
+
detail of logging with option '--log-level'.
|
136
|
+
|
137
|
+
--log-level [LEVEL]
|
138
|
+
|
139
|
+
Let pandocomatic log with detail LEVEL. LEVEL should be one
|
140
|
+
of 'fatal', 'error', 'warn', 'info', or 'debug'. By default,
|
141
|
+
pandocomatic logs at detail level info. Choose level 'debug'
|
142
|
+
to see all steps pandocomatic takes to convert every
|
143
|
+
directory and file.
|
144
|
+
|
128
145
|
|
129
146
|
Common:
|
130
147
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Expected to extract YAML metadata blocks from file '<%= @error.data %>', but did not succeed. Check YAML syntax of all metadata blocks; make sure that all horizontal lines have at least four (4) dashes.
|
1
|
+
Expected to extract YAML metadata blocks from file '<%= @error.data %>', but did not succeed. Make sure '<%= @error.data %>' is a pandoc markdown file. Check YAML syntax of all metadata blocks; make sure that all horizontal lines have at least four (4) dashes.
|
2
2
|
|
3
3
|
<% if @error.error? %>Reported cause(s):
|
4
4
|
<%= @error.error.to_s %><% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
|
4
|
+
# Copyright 2017—2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -28,12 +28,13 @@ module Pandocomatic
|
|
28
28
|
# @param warning [Warning] the warning to print
|
29
29
|
def initialize(warning)
|
30
30
|
template = 'warning.txt'
|
31
|
-
super
|
31
|
+
super(template)
|
32
32
|
@warning = warning
|
33
33
|
end
|
34
34
|
|
35
35
|
# Print warnings to STDERR rather than STDOUT
|
36
36
|
def print
|
37
|
+
Pandocomatic::LOG.warn self
|
37
38
|
warn self
|
38
39
|
end
|
39
40
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2014,
|
4
|
+
# Copyright 2014—2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -37,17 +37,22 @@ module Pandocomatic
|
|
37
37
|
def self.run(input, path, src_path, options)
|
38
38
|
created_at = File.stat(path).ctime
|
39
39
|
modified_at = File.stat(path).mtime
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
40
|
+
|
41
|
+
file_info = "\npandocomatic-fileinfo:\n"
|
42
|
+
file_info += " from: #{options['from']}\n" if options.key? 'from'
|
43
|
+
file_info += " to: #{options['to']}\n" if options.key? 'to'
|
44
|
+
file_info += " template: #{options['template']}\n" if options.key? 'template'
|
45
|
+
file_info += " path: '#{path}'\n"
|
46
|
+
file_info += " src_path: '#{src_path}'\n"
|
47
|
+
file_info += " created: #{created_at.strftime '%Y-%m-%d'}\n"
|
48
|
+
file_info += " modified: #{modified_at.strftime '%Y-%m-%d'}"
|
49
|
+
|
50
|
+
Pandocomatic::LOG.debug ' | FileInfoPreprocessor. Adding file information to metadata:' \
|
51
|
+
"#{Pandocomatic::LOG.indent(
|
52
|
+
file_info, 37
|
53
|
+
)}"
|
54
|
+
|
55
|
+
"#{input}\n\n---#{file_info}\n...\n\n"
|
51
56
|
end
|
52
57
|
|
53
58
|
# rubocop:enable Metrics/AbcSize
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2017, Huub de Beer <Huub@heerdebeer.org>
|
4
|
+
# Copyright 2017—2024, Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -32,10 +32,12 @@ module Pandocomatic
|
|
32
32
|
# preprocessed
|
33
33
|
# @param metadata [Hash = {}] the metadata to mix-in
|
34
34
|
def self.run(input, metadata = {})
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
yaml = YAML.dump(metadata)
|
36
|
+
Pandocomatic::LOG.debug ' | MetadataPreprocessor. Adding mined YAML blocks to metadata:' \
|
37
|
+
"#{Pandocomatic::LOG.indent(
|
38
|
+
yaml.sub('---', ''), 37
|
39
|
+
)}"
|
40
|
+
"#{input}\n\n#{yaml}...\n\n"
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/pandocomatic/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright 2023
|
4
|
+
# Copyright 2023—2024 Huub de Beer <Huub@heerdebeer.org>
|
5
5
|
#
|
6
6
|
# This file is part of pandocomatic.
|
7
7
|
#
|
@@ -20,5 +20,5 @@
|
|
20
20
|
#++
|
21
21
|
module Pandocomatic
|
22
22
|
# Pandocomatic's current version.
|
23
|
-
VERSION = [
|
23
|
+
VERSION = [2, 0, 0].freeze
|
24
24
|
end
|