paru 0.2.5.11 → 0.2.5.12
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/lib/paru/filter.rb +23 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b04f0bfc217b81b510d46cc2ef83601123b07e2
|
4
|
+
data.tar.gz: 4c00811eac2de58979daa5958e1331b60f35da8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42f4816cbcdd7b6fc3e52dae360e1305e1e3546b3b28a69cfe7d8c0b2cc1f29b427e96b5c4be4e3ce381c39fbd25003ab475d0c8125e834e9bd4f6b31708bd05
|
7
|
+
data.tar.gz: c3ee0635d919ca0d8aedc0cd2ca790bf05750d21329cdf2340cdd4074474fb770f0f647ef47cd2890144e85704544355a1cb040949d930116d03b9c27c262a47
|
data/lib/paru/filter.rb
CHANGED
@@ -226,7 +226,6 @@ module Paru
|
|
226
226
|
def initialize(input = $stdin, output = $stdout)
|
227
227
|
@input = input
|
228
228
|
@output = output
|
229
|
-
@running = false
|
230
229
|
end
|
231
230
|
|
232
231
|
# Run the filter specified by block. This is a convenience method that
|
@@ -278,30 +277,22 @@ module Paru
|
|
278
277
|
end
|
279
278
|
end
|
280
279
|
|
281
|
-
@running = true # used to be able to stop filtering immediately
|
282
280
|
@current_node = @document
|
283
281
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
@current_node = nodes_to_filter.next
|
291
|
-
end
|
292
|
-
|
293
|
-
@filtered_nodes.push @current_node
|
294
|
-
|
295
|
-
instance_eval(&block) # run the actual filter code
|
296
|
-
rescue StopIteration
|
297
|
-
@running = false
|
282
|
+
nodes_to_filter.each do |node|
|
283
|
+
if @current_node.has_been_replaced?
|
284
|
+
@current_node = @current_node.get_replacement
|
285
|
+
@filtered_nodes.pop
|
286
|
+
else
|
287
|
+
@current_node = node
|
298
288
|
end
|
289
|
+
|
290
|
+
@filtered_nodes.push @current_node
|
291
|
+
|
292
|
+
instance_eval(&block) # run the actual filter code
|
299
293
|
end
|
300
|
-
|
301
|
-
@running = false
|
302
294
|
|
303
|
-
|
304
|
-
@output.write @document.to_JSON
|
295
|
+
write_document
|
305
296
|
end
|
306
297
|
|
307
298
|
# Specify what nodes to filter with a +selector+. If the +current_node+
|
@@ -318,10 +309,15 @@ module Paru
|
|
318
309
|
# This is a great timesaver for filters that only act on a small
|
319
310
|
# number of nodes in a large document, or when you only want to set
|
320
311
|
# the metadata.
|
312
|
+
#
|
313
|
+
# Note, stop will break off the filter immediately after outputting
|
314
|
+
# the document in its current state.
|
321
315
|
def stop!()
|
322
|
-
|
316
|
+
write_document
|
317
|
+
exit true
|
323
318
|
end
|
324
319
|
|
320
|
+
|
325
321
|
private
|
326
322
|
|
327
323
|
# The Document node from JSON formatted pandoc document structure
|
@@ -332,6 +328,12 @@ module Paru
|
|
332
328
|
def read_document()
|
333
329
|
PandocFilter::Document.from_JSON @input.read
|
334
330
|
end
|
331
|
+
|
332
|
+
# Write the document being filtered to STDOUT
|
333
|
+
def write_document()
|
334
|
+
@document.meta = @metadata.to_meta
|
335
|
+
@output.write @document.to_JSON
|
336
|
+
end
|
335
337
|
end
|
336
338
|
|
337
339
|
# FilterError is thrown when there is an error during filtering
|
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.2.5.
|
4
|
+
version: 0.2.5.12
|
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: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Use Pandoc (http://www.pandoc.org) with ruby
|
14
14
|
email: Huub@heerdebeer.org
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.2
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Paru is a ruby wrapper around pandoc
|