markdown_extension 0.0.4 → 0.0.6
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 +23 -10
- data/lib/markdown_extension/page.rb +2 -1
- data/lib/markdown_extension/site.rb +18 -5
- 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: 3ddb3ebd46cfa75b4a02431c3f695df13cf45fac0dae5d30b0d7f710c3bbfcf1
|
4
|
+
data.tar.gz: 22bc0feb032ec88c5c83c053c0da28397d7b4fa2cd0bf7e030b6659dcf83cfff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0322c6afe27efdfdfbf5fd921b8c7896e400809e5b61bcff609ce9881e5d120adec2dcba648f3aa50c97a3411cb67d672f75c0ba05b20162f94c077e4041e4
|
7
|
+
data.tar.gz: 76c998a06980e6ec32d40819e94323d925fb812a5462660e55999d3d4e7fe1ba413d33e8f6c4564902a053b906ca9393461dab6b70301f4efb005203ec2a9ee4
|
@@ -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
|
@@ -42,5 +49,11 @@ module MarkdownExtension
|
|
42
49
|
return @raw_config["preprocessing"]
|
43
50
|
end
|
44
51
|
end
|
52
|
+
|
53
|
+
def giscus
|
54
|
+
if @raw_config
|
55
|
+
return @raw_config["giscus"]
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
46
59
|
end
|
@@ -4,9 +4,10 @@ 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, :title
|
8
8
|
|
9
9
|
def initialize(file, site)
|
10
|
+
@title = file.split("/")[-1].gsub(".md","")
|
10
11
|
@site = site
|
11
12
|
if File.exists?(file)
|
12
13
|
@markdown = File.read(file)
|
@@ -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
|
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.6
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|