markdown_extension 0.1.3 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f44807dea45f0339b4c9cf41a43b97de1dbfc5592636d2d90fdb43be80359da
|
4
|
+
data.tar.gz: 66e25bf0ccd04b10246cb8a6238d20e3720b82ea8f94db868e3107c391008d0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b0a26702f88e04998784415f1861fa2ff47de91586d01efdf075011d45e6e8595e5c5bb9d5f2285c011889b154438c4f3b8e780d4ee8e399f97de55b7e8be3
|
7
|
+
data.tar.gz: e5ff3b2669a814b5ab772bef10de32bd0a3cdf9a1728122b1a8351f1380eaf40fba37a34dd044b0c0b83d337efe91424ae7717ea36a445f4085ea405bdb5f480
|
@@ -4,7 +4,7 @@ module MarkdownExtension
|
|
4
4
|
def initialize(config, type)
|
5
5
|
@config = config
|
6
6
|
@type = type
|
7
|
-
@inner_citations = {}
|
7
|
+
@inner_citations = {}
|
8
8
|
if config.citation
|
9
9
|
init_citation()
|
10
10
|
end
|
@@ -25,7 +25,37 @@ module MarkdownExtension
|
|
25
25
|
@inner_citations[id] = "P#{page_no} #{content}"
|
26
26
|
i = i + 4
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_embed_citation(file)
|
32
|
+
text = File.read(file)
|
33
|
+
text.gsub!("\t", " ")
|
34
|
+
temp_id = ""
|
35
|
+
temp_context = ""
|
36
|
+
prev_line = ""
|
37
|
+
space = 0
|
38
|
+
if text.index("id:: ")
|
39
|
+
text.split("\n").each do |line|
|
40
|
+
if temp_space = line.index("id:: ")
|
41
|
+
temp_id = line.split("id:: ")[1]
|
42
|
+
temp_context = prev_line + "\n"
|
43
|
+
space = temp_space
|
44
|
+
next
|
45
|
+
end
|
46
|
+
if line.strip == "collapsed:: true"
|
47
|
+
next
|
48
|
+
end
|
49
|
+
if line.length - line.lstrip.length > space
|
50
|
+
temp_context = temp_context + line + "\n"
|
51
|
+
else
|
52
|
+
unless temp_id==""
|
53
|
+
@inner_citations[temp_id] = temp_context
|
54
|
+
end
|
55
|
+
end
|
56
|
+
prev_line = line
|
57
|
+
end
|
58
|
+
end
|
29
59
|
end
|
30
60
|
|
31
61
|
def get_inner_citation(id)
|
@@ -57,6 +57,10 @@ module MarkdownExtension
|
|
57
57
|
j = @markdown.index(":END:", i)
|
58
58
|
@markdown=@markdown[0..i-4] + @markdown[j+5..-1]
|
59
59
|
end
|
60
|
+
@markdown = @markdown.gsub(/{{embed \(\(([^\)]+)\)\)}}/) do |s|
|
61
|
+
id = s[10..-5]
|
62
|
+
"embed #{id}: \n" + @site.citations.get_inner_citation(id)
|
63
|
+
end
|
60
64
|
@markdown = @markdown.gsub(/\(\([^\)]+\)\)/) do |s|
|
61
65
|
if s.index(":")
|
62
66
|
id = s
|