markdown_extension 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
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)
|
@@ -4,7 +4,7 @@ require "tomlrb"
|
|
4
4
|
|
5
5
|
module MarkdownExtension
|
6
6
|
class Page
|
7
|
-
attr_accessor :site, :markdown, :meta, :item_name
|
7
|
+
attr_accessor :site, :markdown, :meta, :item_name, :ctime, :mtime
|
8
8
|
|
9
9
|
def initialize(file, site)
|
10
10
|
@site = site
|
@@ -18,7 +18,9 @@ module MarkdownExtension
|
|
18
18
|
@meta = mds[1]
|
19
19
|
@markdown = mds[2..-1].join("---\n")
|
20
20
|
end
|
21
|
-
@item_name = file.split("/")[-1].gsub(".md","")
|
21
|
+
@item_name = file.split("/")[-1].gsub(".md","")
|
22
|
+
@ctime = File::ctime(file)
|
23
|
+
@mtime = File::mtime(file)
|
22
24
|
end
|
23
25
|
|
24
26
|
def pre_processing
|
@@ -55,6 +57,10 @@ module MarkdownExtension
|
|
55
57
|
j = @markdown.index(":END:", i)
|
56
58
|
@markdown=@markdown[0..i-4] + @markdown[j+5..-1]
|
57
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
|
58
64
|
@markdown = @markdown.gsub(/\(\([^\)]+\)\)/) do |s|
|
59
65
|
if s.index(":")
|
60
66
|
id = s
|
@@ -38,6 +38,8 @@ module MarkdownExtension
|
|
38
38
|
unless file == pages_path + "/summary.md"
|
39
39
|
if file.index("hls_")
|
40
40
|
@citations.add_inner_citation(file)
|
41
|
+
else
|
42
|
+
@citations.add_embed_citation(file)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -72,18 +74,22 @@ module MarkdownExtension
|
|
72
74
|
|
73
75
|
def gen_nodes_links
|
74
76
|
@references.each do |k,v|
|
77
|
+
val = @references[k] ? @references[k].size+1 : 1
|
78
|
+
val = 5 if val > 5
|
75
79
|
@nodes << {
|
76
80
|
"id" => k,
|
77
81
|
"name" => k,
|
78
82
|
"color" => "blue",
|
79
|
-
"val" =>
|
83
|
+
"val" => val
|
80
84
|
}
|
81
85
|
v.each do |item|
|
86
|
+
val = @references[item] ? @references[item].size+1 : 1
|
87
|
+
val = 5 if val > 5
|
82
88
|
@nodes << {
|
83
89
|
"id" => item,
|
84
90
|
"name" => item,
|
85
91
|
"color" => "blue",
|
86
|
-
"val" =>
|
92
|
+
"val" => val
|
87
93
|
}
|
88
94
|
@links << {
|
89
95
|
"source" => item,
|