inline_fn 0.1.4 → 0.1.5
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/.idea/workspace.xml +7 -3
- data/README.md +3 -1
- data/lib/inline_fn/version.rb +1 -1
- data/lib/inline_fn.rb +35 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d19738fc73f2dd8bd8e97ced36a0c455be956445cc79fb531f0265cc18adf2a
|
4
|
+
data.tar.gz: 25df06d45e878b673c2000aedbedd24ab62ac759e4658d55ed968139c47f218b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b5a526ad0b24bc01a51edeead9b8bd7f6cb3cd7fbfce13c71f9710d6b5d3324d39deb613dc0c6ff864df8d20f4c14adc7addb64dc8d98887bf2c0658ebef56e
|
7
|
+
data.tar.gz: da1eded3fd310d43991fa7f8ec795e7543a202c02b41569cca3fd63d27a58f98cbcb9d3c75b4e83f54dbe86e83e1ba4e7f31c3cddb2ab5e2c8c3b49a6909fdaf
|
data/.idea/workspace.xml
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
</component>
|
6
6
|
<component name="ChangeListManager">
|
7
7
|
<list default="true" id="ca42f8e7-82dc-4786-8148-99f859f55553" name="Changes" comment="2022-07-13-20-54">
|
8
|
+
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
9
|
+
<change beforePath="$PROJECT_DIR$/lib/inline_fn.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/inline_fn.rb" afterDir="false" />
|
8
10
|
<change beforePath="$PROJECT_DIR$/lib/inline_fn/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/inline_fn/version.rb" afterDir="false" />
|
9
11
|
</list>
|
10
12
|
<option name="SHOW_DIALOG" value="false" />
|
@@ -32,7 +34,8 @@
|
|
32
34
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
33
35
|
"nodejs_package_manager_path": "npm",
|
34
36
|
"ruby.rails.projectView.checked": "true",
|
35
|
-
"settings.editor.selected.configurable": "terminal"
|
37
|
+
"settings.editor.selected.configurable": "terminal",
|
38
|
+
"vue.rearranger.settings.migration": "true"
|
36
39
|
}
|
37
40
|
}]]></component>
|
38
41
|
<component name="RunManager" selected="Test::Unit/Shoulda/Minitest.test_inline_fn_mmd">
|
@@ -134,7 +137,8 @@
|
|
134
137
|
<option name="number" value="Default" />
|
135
138
|
<option name="presentableId" value="Default" />
|
136
139
|
<updated>1657691753423</updated>
|
137
|
-
<workItem from="1657691754700" duration="
|
140
|
+
<workItem from="1657691754700" duration="5726000" />
|
141
|
+
<workItem from="1675194856020" duration="190000" />
|
138
142
|
</task>
|
139
143
|
<task id="LOCAL-00001" summary="initial commit">
|
140
144
|
<created>1657693651385</created>
|
@@ -181,8 +185,8 @@
|
|
181
185
|
<option name="LAST_COMMIT_MESSAGE" value="2022-07-13-20-54" />
|
182
186
|
</component>
|
183
187
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
188
|
+
<SUITE FILE_PATH="coverage/inline_fn@test_inline_fn_mmd.rcov" NAME="test_inline_fn_mmd Coverage Results" MODIFIED="1657693593278" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="inline_fn" />
|
184
189
|
<SUITE FILE_PATH="coverage/inline_fn@test_inline_fn_pandoc.rcov" NAME="test_inline_fn_pandoc Coverage Results" MODIFIED="1657693539353" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="inline_fn" />
|
185
190
|
<SUITE FILE_PATH="coverage/inline_fn@inline_fn.rcov" NAME="inline_fn Coverage Results" MODIFIED="1657693319814" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="inline_fn" />
|
186
|
-
<SUITE FILE_PATH="coverage/inline_fn@test_inline_fn_mmd.rcov" NAME="test_inline_fn_mmd Coverage Results" MODIFIED="1657693593278" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="rcov" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" MODULE_NAME="inline_fn" />
|
187
191
|
</component>
|
188
192
|
</project>
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Inline Markdown Footnotes
|
2
|
+
|
3
|
+
[](https://github.com/bcdavasconcelos/inline_fn/actions/workflows/main.yml) [](https://badge.fury.io/rb/inline_fn)
|
2
4
|
|
3
5
|
There are two methods to change regular markdown footnotes to inline mmd/pandoc-style footnotes.
|
4
6
|
|
data/lib/inline_fn/version.rb
CHANGED
data/lib/inline_fn.rb
CHANGED
@@ -6,11 +6,17 @@ require_relative 'inline_fn/version'
|
|
6
6
|
module InlineFn
|
7
7
|
class Error < StandardError; end
|
8
8
|
|
9
|
-
def inline_fn(
|
9
|
+
def inline_fn(text, style, *array_of_strs)
|
10
|
+
# str is the text to be processed
|
11
|
+
# style is the style of the inline footnote: :pandoc or :mmd
|
12
|
+
# text is an optional array of strings `%w{fn cf}` that need to be removed from the footnotes before processing. This is useful in case you are converting Scrivener footnotes (`[^fn1]` or `[^cf1]`).
|
10
13
|
ref_start = ''
|
11
|
-
text = str
|
12
14
|
counter = 0
|
13
15
|
|
16
|
+
array_of_strs.each do |str|
|
17
|
+
text = text.gsub(/\[\^#{str}/, '[^')
|
18
|
+
end
|
19
|
+
|
14
20
|
until ref_start.nil?
|
15
21
|
counter += 1
|
16
22
|
cite = "[^#{counter}]"
|
@@ -40,9 +46,17 @@ module InlineFn
|
|
40
46
|
text = text.gsub(/\n\s*\^\[/, "\n^[")
|
41
47
|
cut_point = text.index("\n^")
|
42
48
|
end
|
49
|
+
# p text
|
50
|
+
error_msg = <<~EOF
|
51
|
+
ERROR: No cut point found.
|
52
|
+
|
53
|
+
Footnotes should be in the format `[^1]` AND NOT `[^fn1]` or `[^cf1]`. If you are converting Scrivener markdown, please use the `scrivener_to_pandoc` (== inline_fn(self, :pandoc, 'fn', 'cf')) or `scrivener_to_mmd` (== inline_fn(self, :mmd, 'fn', 'cf')) methods.
|
54
|
+
|
55
|
+
If you have footnotes in other formats, you can try the `inline_fn` method. It takes as arguments the text to be processed, the style of the inline footnote: :pandoc or :mmd, and an optional array of strings `%w{fn cf}` that need to be removed from the footnotes before processing.
|
56
|
+
EOF
|
43
57
|
|
44
|
-
text = text[0, cut_point]
|
45
|
-
|
58
|
+
text = text[0, cut_point] rescue error_msg
|
59
|
+
puts "#{counter -= 1} notes replaced."
|
46
60
|
end
|
47
61
|
text
|
48
62
|
end
|
@@ -51,9 +65,26 @@ module InlineFn
|
|
51
65
|
inline_fn(self, :pandoc)
|
52
66
|
end
|
53
67
|
|
68
|
+
def pandoc_fn
|
69
|
+
inline_fn_pandoc
|
70
|
+
end
|
71
|
+
|
54
72
|
def inline_fn_mmd
|
55
73
|
inline_fn(self, :mmd)
|
56
74
|
end
|
75
|
+
|
76
|
+
def mmd_fn
|
77
|
+
inline_fn_mmd
|
78
|
+
end
|
79
|
+
|
80
|
+
def scrivener_to_pandoc
|
81
|
+
inline_fn(self, :pandoc, 'fn', 'cf')
|
82
|
+
end
|
83
|
+
|
84
|
+
def scrivener_to_mmd
|
85
|
+
inline_fn(self, :mmd, 'fn', 'cf')
|
86
|
+
end
|
87
|
+
|
57
88
|
end
|
58
89
|
|
59
90
|
class String
|
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.
|
4
|
+
version: 0.1.5
|
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:
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
|
-
rubygems_version: 3.3.
|
84
|
+
rubygems_version: 3.3.22
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Inline markdown footnotes
|