markdown_extension 0.1.3 → 0.1.5
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: 3bab0fc1cbab47458d317c5444ed844e94c29c46e6f0c4875f0f7dab3a7a1ac0
|
4
|
+
data.tar.gz: c7d700171cbe05cb754cd4b25f8822eb2d5542f68372f4fab465e4e096b647ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8efaa59df86d779cec7024b8a29252f67188c5355bb946fe7b3107adda604af9f123d5561ab217f6a1b1fed2b6fe04b1485c001619e1fbe32f316b0a0356dab6
|
7
|
+
data.tar.gz: ef70615088430a67706d6406298e70635e647827c27181175732d919adc4ebfc4dd4e873f7fae6fce29a840e272b0833a1044655c0895e2adda2f11a8a932b7c
|
@@ -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)
|
@@ -49,7 +49,7 @@ module MarkdownExtension
|
|
49
49
|
@markdown = @markdown[0..-2]
|
50
50
|
end
|
51
51
|
@markdown.gsub!("(../assets/", "(./assets/")
|
52
|
-
@markdown.gsub!(/(.+)collapsed:: true\n/, "")
|
52
|
+
# @markdown.gsub!(/(.+)collapsed:: true\n/, "")
|
53
53
|
@markdown = @markdown.gsub(/.+([0-9]+\. )/) do |s|
|
54
54
|
s.gsub(".",".")
|
55
55
|
end
|
@@ -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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_extension
|
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
|
- Zhuang Biaowei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|