markdown_extension 0.1.4 → 0.1.6

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: 3f44807dea45f0339b4c9cf41a43b97de1dbfc5592636d2d90fdb43be80359da
4
- data.tar.gz: 66e25bf0ccd04b10246cb8a6238d20e3720b82ea8f94db868e3107c391008d0a
3
+ metadata.gz: b3a4927b1f203ac6382d61c3b5661157b41e43fd285dcd807abe5d312148598b
4
+ data.tar.gz: 838fbfa9f13025b11ba0418b2fe650e67e33ebb840c74db486a2507fafaf696e
5
5
  SHA512:
6
- metadata.gz: 04b0a26702f88e04998784415f1861fa2ff47de91586d01efdf075011d45e6e8595e5c5bb9d5f2285c011889b154438c4f3b8e780d4ee8e399f97de55b7e8be3
7
- data.tar.gz: e5ff3b2669a814b5ab772bef10de32bd0a3cdf9a1728122b1a8351f1380eaf40fba37a34dd044b0c0b83d337efe91424ae7717ea36a445f4085ea405bdb5f480
6
+ metadata.gz: b979e7bd361b1f5987ac414e5d185f1a37584b54c3dabc8ff4579d2e3251e3e4260ab2aa95332c8adf6eb0f8b1837071a113d6bd8328c0380d2c7556f08dfad0
7
+ data.tar.gz: 490f49add269f2a7e5561d47786d6424382c2187a2582aea11d9f9b86a81b2e19c4a43daf014d48eede912492d4da591125ba8267795a0c7150ccea0f6c1e93b
@@ -8,7 +8,7 @@ module MarkdownExtension
8
8
 
9
9
  def initialize(file, site)
10
10
  @site = site
11
- if File.exists?(file)
11
+ if File.exist?(file)
12
12
  @markdown = File.read(file)
13
13
  else
14
14
  @markdown = ""
@@ -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
@@ -69,6 +69,9 @@ module MarkdownExtension
69
69
  end
70
70
  @site.citations.get_inner_citation(id)
71
71
  end
72
+ @markdown = @markdown.split("\n").collect {|line|
73
+ (line.strip.index("id:: ") && line.strip.length==41)? nil : line
74
+ }.compact.join("\n")
72
75
  end
73
76
  end
74
77
 
@@ -7,7 +7,7 @@ module MarkdownExtension
7
7
  def initialize(config)
8
8
  @config = config
9
9
  file = config.src+"/summary.md"
10
- if File.exists?(file)
10
+ if File.exist?(file)
11
11
  @markdown = File.read(file)
12
12
  else
13
13
  @markdown = ""
@@ -1,3 +1,3 @@
1
1
  module MarkdownExtension
2
- Version = '0.1.4'
2
+ Version = '0.1.6'
3
3
  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.1.4
4
+ version: 0.1.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: 2023-01-08 00:00:00.000000000 Z
11
+ date: 2023-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb
@@ -61,9 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - lib/markdown_extension.rb
63
63
  - lib/markdown_extension/citations.rb
64
- - lib/markdown_extension/config.rb
65
64
  - lib/markdown_extension/page.rb
66
- - lib/markdown_extension/site.rb
67
65
  - lib/markdown_extension/summary.rb
68
66
  - lib/markdown_extension/version.rb
69
67
  homepage: https://github.com/markdown-world/markdown_extension
@@ -85,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
83
  - !ruby/object:Gem::Version
86
84
  version: '0'
87
85
  requirements: []
88
- rubygems_version: 3.3.5
86
+ rubygems_version: 3.4.6
89
87
  signing_key:
90
88
  specification_version: 4
91
89
  summary: A markdown extension for generating HTML in order to support a wider variety
@@ -1,65 +0,0 @@
1
- require "tomlrb"
2
-
3
- module MarkdownExtension
4
- class Config
5
- attr_accessor :raw_config, :file, :type
6
-
7
- def load_file(file)
8
- @raw_config = begin
9
- Tomlrb.load_file(file)
10
- rescue
11
- {}
12
- end
13
- end
14
-
15
- def initialize(file, type)
16
- @file = file
17
- @type = type
18
- load_file(file)
19
- return self
20
- end
21
-
22
- def get_base_info(name)
23
- if @raw_config
24
- if @raw_config[@type.to_s]
25
- return @raw_config[@type.to_s][name]
26
- end
27
- end
28
- ""
29
- end
30
-
31
- def title
32
- get_base_info("title")
33
- end
34
-
35
- def src
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")
45
- end
46
-
47
- def preprocessing
48
- if @raw_config
49
- return @raw_config["preprocessing"]
50
- end
51
- end
52
-
53
- def giscus
54
- if @raw_config
55
- return @raw_config["giscus"]
56
- end
57
- end
58
-
59
- def citation
60
- if @raw_config
61
- return @raw_config["citation"]
62
- end
63
- end
64
- end
65
- end
@@ -1,111 +0,0 @@
1
- require "json"
2
-
3
- module MarkdownExtension
4
- class Site
5
- attr_accessor :config, :summary, :pages, :journals, :references, :reverse_references
6
- attr_accessor :nodes, :links, :citations
7
-
8
- def initialize(config, type)
9
- @config = MarkdownExtension::Config.new(config, type)
10
- @citations = MarkdownExtension::Citations.new(@config, type)
11
- unless type == :logseq
12
- @summary = MarkdownExtension::Summary.new(@config)
13
- end
14
- @references = {}
15
- @reverse_references = {}
16
- @nodes = []
17
- @links = []
18
- load_source_files()
19
- gen_nodes_links()
20
- end
21
-
22
- def load_source_files
23
- @pages = []
24
- @journals = []
25
- if @config
26
- if @config.type == :logseq
27
- journal_files = Dir.glob(@config.journals + "/*.md")
28
- journal_files.each do |file|
29
- page = MarkdownExtension::Page.new(file, self)
30
- @journals << page
31
- end
32
- pages_path = @config.pages
33
- else
34
- pages_path = @config.src
35
- end
36
- files = Dir.glob(pages_path + "/*.md")
37
- files.each do |file|
38
- unless file == pages_path + "/summary.md"
39
- if file.index("hls_")
40
- @citations.add_inner_citation(file)
41
- else
42
- @citations.add_embed_citation(file)
43
- end
44
- end
45
- end
46
- files.each do |file|
47
- unless file == pages_path + "/summary.md"
48
- unless file.index("hls_")
49
- page = MarkdownExtension::Page.new(file, self)
50
- @pages << page
51
- gen_references(file , page.markdown)
52
- end
53
- end
54
- end
55
- end
56
- end
57
-
58
- def gen_references(file, text)
59
- text.gsub(/\[\[([^\]]+)\]\]/) do |s|
60
- s = s[2..-3]
61
- item_name = file.split("/")[-1].gsub(".md","")
62
- if @references[s]
63
- @references[s] << item_name
64
- else
65
- @references[s] = [item_name]
66
- end
67
- if @reverse_references[item_name]
68
- @reverse_references[item_name] << s
69
- else
70
- @reverse_references[item_name] = [s]
71
- end
72
- end
73
- end
74
-
75
- def gen_nodes_links
76
- @references.each do |k,v|
77
- val = @references[k] ? @references[k].size+1 : 1
78
- val = 5 if val > 5
79
- @nodes << {
80
- "id" => k,
81
- "name" => k,
82
- "color" => "blue",
83
- "val" => val
84
- }
85
- v.each do |item|
86
- val = @references[item] ? @references[item].size+1 : 1
87
- val = 5 if val > 5
88
- @nodes << {
89
- "id" => item,
90
- "name" => item,
91
- "color" => "blue",
92
- "val" => val
93
- }
94
- @links << {
95
- "source" => item,
96
- "target" => k
97
- }
98
- end
99
- end
100
- @nodes = @nodes.uniq
101
- @links = @links.uniq
102
- end
103
-
104
- def write_data_json(file)
105
- data = {"nodes"=>@nodes, "links"=>@links}
106
- f = File.new(file, "w")
107
- f.puts JSON.generate(data)
108
- f.close
109
- end
110
- end
111
- end