inline_fn 0.1.0 → 0.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: 2aea4c765086fc66c89701e21aa1731b859d45b656c59e8eb68c9f4a1d7810fe
4
- data.tar.gz: 7f07d0969719a474ed98e57968db739447c819cfa059ac4ed731ae05f0f2a4d3
3
+ metadata.gz: 03bfc831e12841eee0b0fe684786fed3b32af9b89f9bec3c5fd0e761291a69d7
4
+ data.tar.gz: f197bfbf6147fc1ed496df9f6e32710e6488debb888c641d4775c4c3598968e2
5
5
  SHA512:
6
- metadata.gz: 23106280f4efadad18a2d10ed4f0414bc05e604c9160a11e48f81a28725df4298efe69f20b9a89bc82e89ebf28f1d97a0220134b25363c9eea478b4fe9ed2f6d
7
- data.tar.gz: 68f76f271fc300e4a7f442f881206c4b0dfdbc39772239312ec759d81273a0cbd950423e4f091385edb471958fa44eb3078842bac09a1f12918a545d240d9d65
6
+ metadata.gz: dba9e6151575d891f1f189dd1ebc849c43e283cf1c7766dca30209f7dabfa8711778db1f4bb19e995d8b38d77993b70bea5cf64b8ec52245ed33c77badbd3715
7
+ data.tar.gz: 8041cb6ba60c2d34bfacc7db38bd56c2cc3467f4391d21025221eabf49fcbfa508a058ec7412f77463479d0adfd3a6bef140a1bb1717920320d27ace44e9daf2
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ .nova/Tasks/run.json
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inline_fn (0.1.0)
4
+ inline_fn (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -37,4 +37,4 @@ DEPENDENCIES
37
37
  rubocop (~> 1.7)
38
38
 
39
39
  BUNDLED WITH
40
- 2.2.25
40
+ 2.3.0.dev
Binary file
@@ -0,0 +1,29 @@
1
+ class InlineFn
2
+ def inline_pandoc(str)
3
+ text = str
4
+ counter = 0
5
+ pandoc_mode = true
6
+ loop do
7
+ counter += 1
8
+ cite = "[^#{counter}]"
9
+ ref = "[^#{counter}]:"
10
+ ref_start = text.index(ref)
11
+ break if ref_start.nil?
12
+
13
+ next_ref = "[^#{counter + 1}]:"
14
+ ref_end = text.index(next_ref).nil? ? -1 : text.index(next_ref) - 2
15
+ offset = counter.to_s.length + 5
16
+ note = pandoc_mode ? "^[#{text[ref_start + offset..ref_end].strip}]" : "[^#{text[ref_start + offset..ref_end].strip}]"
17
+
18
+ text.gsub!(cite, note)
19
+ end
20
+
21
+ if counter >= 1
22
+ text = pandoc_mode ? text.gsub(/\n\s*\^\[/, "\n^[") : text.gsub(/\n\s*\[\^/, "\n[^")
23
+ cut_point = pandoc_mode ? text.index("\n^") : text.index("\n[^")
24
+ text = text[0, cut_point]
25
+ # puts "#{counter -= 1} notes replaced."
26
+ end
27
+ puts text
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ class InlineFn
2
+ def inline_mmd(str)
3
+ text = str
4
+ counter = 0
5
+ pandoc_mode = false
6
+ loop do
7
+ counter += 1
8
+ cite = "[^#{counter}]"
9
+ ref = "[^#{counter}]:"
10
+ ref_start = text.index(ref)
11
+ break if ref_start.nil?
12
+
13
+ next_ref = "[^#{counter + 1}]:"
14
+ ref_end = text.index(next_ref).nil? ? -1 : text.index(next_ref) - 2
15
+ offset = counter.to_s.length + 5
16
+ note = pandoc_mode ? "^[#{text[ref_start + offset..ref_end].strip}]" : "[^#{text[ref_start + offset..ref_end].strip}]"
17
+
18
+ text.gsub!(cite, note)
19
+ end
20
+
21
+ if counter >= 1
22
+ text = pandoc_mode ? text.gsub(/\n\s*\^\[/, "\n^[") : text.gsub(/\n\s*\[\^/, "\n[^")
23
+ cut_point = pandoc_mode ? text.index("\n^") : text.index("\n[^")
24
+ text = text[0, cut_point]
25
+ # puts "#{counter -= 1} notes replaced."
26
+ end
27
+ puts text
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InlineFn
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/inline_fn.rb CHANGED
@@ -1,64 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "inline_fn/version"
4
-
4
+ require_relative "inline_fn/inline_mmd"
5
+ require_relative "inline_fn/inline_pandoc"
5
6
  module InlineFn
6
7
  class Error < StandardError; end
7
- class String
8
- def inline_mmd
9
- text = self
10
- counter = 0
11
- pandoc_mode = false
12
- loop do
13
- counter += 1
14
- cite = "[^#{counter}]"
15
- ref = "[^#{counter}]:"
16
- ref_start = text.index(ref)
17
- break if ref_start.nil?
18
-
19
- next_ref = "[^#{counter + 1}]:"
20
- ref_end = text.index(next_ref).nil? ? -1 : text.index(next_ref) - 2
21
- offset = counter.to_s.length + 5
22
- note = pandoc_mode ? "^[#{text[ref_start + offset..ref_end].strip}]" : "[^#{text[ref_start + offset..ref_end].strip}]"
23
-
24
- text.gsub!(cite, note)
25
- end
26
-
27
- if counter >= 1
28
- text = pandoc_mode ? text.gsub(/\n\s*\^\[/, "\n^[") : text.gsub(/\n\s*\[\^/, "\n[^")
29
- cut_point = pandoc_mode ? text.index("\n^") : text.index("\n[^")
30
- text = text[0, cut_point]
31
- # puts "#{counter -= 1} notes replaced."
32
- end
33
- puts text
34
- end
35
-
36
- def inline_pandoc
37
- text = self
38
- counter = 0
39
- pandoc_mode = true
40
- loop do
41
- counter += 1
42
- cite = "[^#{counter}]"
43
- ref = "[^#{counter}]:"
44
- ref_start = text.index(ref)
45
- break if ref_start.nil?
46
-
47
- next_ref = "[^#{counter + 1}]:"
48
- ref_end = text.index(next_ref).nil? ? -1 : text.index(next_ref) - 2
49
- offset = counter.to_s.length + 5
50
- note = pandoc_mode ? "^[#{text[ref_start + offset..ref_end].strip}]" : "[^#{text[ref_start + offset..ref_end].strip}]"
51
-
52
- text.gsub!(cite, note)
53
- end
54
-
55
- if counter >= 1
56
- text = pandoc_mode ? text.gsub(/\n\s*\^\[/, "\n^[") : text.gsub(/\n\s*\[\^/, "\n[^")
57
- cut_point = pandoc_mode ? text.index("\n^") : text.index("\n[^")
58
- text = text[0, cut_point]
59
- # puts "#{counter -= 1} notes replaced."
60
- end
61
- puts text
62
- end
63
- end
8
+ class InlineFn < StandardError; end
64
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_fn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo C.D.A. Vasconcelos
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-09-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: There are two methods that work on strings. Use `str.inline_mmd` for
14
14
  Multimarkdown style or `str.inline_pandoc` for Pandoc style footnotes.
@@ -29,8 +29,11 @@ files:
29
29
  - Rakefile
30
30
  - bin/console
31
31
  - bin/setup
32
+ - inline_fn-0.1.0.gem
32
33
  - inline_fn.gemspec
33
34
  - lib/inline_fn.rb
35
+ - lib/inline_fn/inline_mmd.rb
36
+ - lib/inline_fn/inline_pandoc.rb
34
37
  - lib/inline_fn/version.rb
35
38
  homepage: https://github.com/bcdavasconcelos/inline_fn
36
39
  licenses:
@@ -54,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
57
  - !ruby/object:Gem::Version
55
58
  version: '0'
56
59
  requirements: []
57
- rubygems_version: 3.2.22
60
+ rubygems_version: 3.3.0.dev
58
61
  signing_key:
59
62
  specification_version: 4
60
63
  summary: Change markdown footnotes format from `[^1]/[^1]:Note` to inline Pandoc or