markdown_extension 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/markdown_extension/config.rb +17 -10
- data/lib/markdown_extension/page.rb +9 -3
- data/lib/markdown_extension/site.rb +19 -6
- data/lib/markdown_extension/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6101b1a888999d59f89a4db3050eb8d72cbc8027210b6a113cb6e9250bd2d28e
|
4
|
+
data.tar.gz: f962ecfc313df40e61d4d1b320e5e3a542c4c41783d6c03437c6828759aa4904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357d38eab68c50ca38e18c4fa9223f2d40fc1229487f4637128504c481512537274df13a18f9dcc5983759d0935b34649d88a18e670dbcd60f6e714ec44c4ba5
|
7
|
+
data.tar.gz: a0d834f4d276778b0de7019acf71d2b95d4912745670c33540b93885d61c8e938d9961d396dd238ec474ccca397e342b73efa49ac959218ace1b03e8bf5c7bed
|
@@ -4,7 +4,7 @@ module MarkdownExtension
|
|
4
4
|
class Config
|
5
5
|
attr_accessor :raw_config, :file, :type
|
6
6
|
|
7
|
-
def load_file(file
|
7
|
+
def load_file(file)
|
8
8
|
@raw_config = begin
|
9
9
|
Tomlrb.load_file(file)
|
10
10
|
rescue
|
@@ -15,26 +15,33 @@ module MarkdownExtension
|
|
15
15
|
def initialize(file, type)
|
16
16
|
@file = file
|
17
17
|
@type = type
|
18
|
-
load_file(file
|
18
|
+
load_file(file)
|
19
19
|
return self
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def get_base_info(name)
|
23
23
|
if @raw_config
|
24
24
|
if @raw_config[@type.to_s]
|
25
|
-
return @raw_config[@type.to_s][
|
25
|
+
return @raw_config[@type.to_s][name]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
""
|
29
29
|
end
|
30
30
|
|
31
|
+
def title
|
32
|
+
get_base_info("title")
|
33
|
+
end
|
34
|
+
|
31
35
|
def src
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
get_base_info("src")
|
37
|
+
end
|
38
|
+
|
39
|
+
def pages
|
40
|
+
get_base_info("pages")
|
41
|
+
end
|
42
|
+
|
43
|
+
def journals
|
44
|
+
get_base_info("journals")
|
38
45
|
end
|
39
46
|
|
40
47
|
def preprocessing
|
@@ -23,9 +23,15 @@ module MarkdownExtension
|
|
23
23
|
|
24
24
|
def pre_processing
|
25
25
|
if @site.config.preprocessing["backlinks"]
|
26
|
-
@markdown = @markdown.gsub(/\[\[(
|
27
|
-
|
28
|
-
|
26
|
+
@markdown = @markdown.gsub(/\[\[([^\]]+)\]\]/) do |s|
|
27
|
+
index = @markdown.index(s)
|
28
|
+
if (@markdown[index-1]=="(" && @markdown[index+s.size]==")")
|
29
|
+
s = s[2..-3]
|
30
|
+
"#{s}.html"
|
31
|
+
else
|
32
|
+
s = s[2..-3]
|
33
|
+
"[#{s}](#{s}.html)"
|
34
|
+
end
|
29
35
|
end
|
30
36
|
if @site.references[@item_name]
|
31
37
|
@markdown += "\n\n\n"
|
@@ -2,12 +2,14 @@ require "json"
|
|
2
2
|
|
3
3
|
module MarkdownExtension
|
4
4
|
class Site
|
5
|
-
attr_accessor :config, :summary, :pages, :references, :reverse_references
|
5
|
+
attr_accessor :config, :summary, :pages, :journals, :references, :reverse_references
|
6
6
|
attr_accessor :nodes, :links
|
7
7
|
|
8
8
|
def initialize(config, type)
|
9
9
|
@config = MarkdownExtension::Config.new(config, type)
|
10
|
-
|
10
|
+
unless type == :logseq
|
11
|
+
@summary = MarkdownExtension::Summary.new(@config)
|
12
|
+
end
|
11
13
|
@references = {}
|
12
14
|
@reverse_references = {}
|
13
15
|
@nodes = []
|
@@ -18,12 +20,23 @@ module MarkdownExtension
|
|
18
20
|
|
19
21
|
def load_source_files
|
20
22
|
@pages = []
|
23
|
+
@journals = []
|
21
24
|
if @config
|
22
|
-
|
25
|
+
if @config.type == :logseq
|
26
|
+
journal_files = Dir.glob(@config.journals + "/*.md")
|
27
|
+
journal_files.each do |file|
|
28
|
+
page = MarkdownExtension::Page.new(file, self)
|
29
|
+
@journals << page
|
30
|
+
end
|
31
|
+
pages_path = @config.pages
|
32
|
+
else
|
33
|
+
pages_path = @config.src
|
34
|
+
end
|
35
|
+
files = Dir.glob(pages_path + "/*.md")
|
23
36
|
files.each do |file|
|
24
|
-
unless file == @config.
|
37
|
+
unless file == @config.pages + "/summary.md"
|
25
38
|
page = MarkdownExtension::Page.new(file, self)
|
26
|
-
pages << page
|
39
|
+
@pages << page
|
27
40
|
gen_references(file , page.markdown)
|
28
41
|
end
|
29
42
|
end
|
@@ -31,7 +44,7 @@ module MarkdownExtension
|
|
31
44
|
end
|
32
45
|
|
33
46
|
def gen_references(file, text)
|
34
|
-
text.gsub(/\[\[(
|
47
|
+
text.gsub(/\[\[([^\]]+)\]\]/) do |s|
|
35
48
|
s = s[2..-3]
|
36
49
|
item_name = file.split("/")[-1].gsub(".md","")
|
37
50
|
if @references[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.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhuang Biaowei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|