markdown_extension 0.1.6 → 0.1.8
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/page.rb +4 -2
- data/lib/markdown_extension/summary.rb +20 -8
- 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: a8d4001e3e40c922319a6d0b2c00be6df4eea2b74b5b5b20a750bf035464e3c7
|
4
|
+
data.tar.gz: 1d43328253be594468dfcb53df1c7ce363915e9b8782f179c3f2c128044b3ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c60591d3bbd5c50f4b7428493aefce4dc0357bc7d50d97c3eabc092020894199ab66312f83c5db9f212ed339b9603ae3dce3e418e20ed1fdf13176faa522115e
|
7
|
+
data.tar.gz: b95b64b1e930bf987d224cf023d3ff3d2749177cd8328678d2fa88fb7401339798bb35fd54b21a7dc9006a404323e617050482dd37fb79f64b7ebde598f66939
|
@@ -4,9 +4,9 @@ require "tomlrb"
|
|
4
4
|
|
5
5
|
module MarkdownExtension
|
6
6
|
class Page
|
7
|
-
attr_accessor :site, :markdown, :meta, :item_name, :ctime, :mtime
|
7
|
+
attr_accessor :site, :markdown, :meta, :path, :item_name, :ctime, :mtime
|
8
8
|
|
9
|
-
def initialize(file, site)
|
9
|
+
def initialize(file, site, lang=nil)
|
10
10
|
@site = site
|
11
11
|
if File.exist?(file)
|
12
12
|
@markdown = File.read(file)
|
@@ -18,6 +18,7 @@ module MarkdownExtension
|
|
18
18
|
@meta = mds[1]
|
19
19
|
@markdown = mds[2..-1].join("---\n")
|
20
20
|
end
|
21
|
+
@path = file.gsub(site.pages_path+lang.to_s+"/","").gsub(".md","")
|
21
22
|
@item_name = file.split("/")[-1].gsub(".md","")
|
22
23
|
@ctime = File::ctime(file)
|
23
24
|
@mtime = File::mtime(file)
|
@@ -82,6 +83,7 @@ module MarkdownExtension
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def meta_html
|
86
|
+
return nil unless @meta
|
85
87
|
meta_data = Tomlrb.parse(@meta)
|
86
88
|
html = ""
|
87
89
|
meta_data.each do |title, values|
|
@@ -3,28 +3,40 @@ require "kramdown-parser-gfm"
|
|
3
3
|
|
4
4
|
module MarkdownExtension
|
5
5
|
class Summary
|
6
|
-
attr_accessor :config, :markdown
|
7
|
-
def initialize(config)
|
6
|
+
attr_accessor :config, :raw_md, :markdown
|
7
|
+
def initialize(config, lang=nil)
|
8
8
|
@config = config
|
9
|
-
|
9
|
+
if lang
|
10
|
+
file = config.src+"/"+lang+"/summary.md"
|
11
|
+
else
|
12
|
+
file = config.src+"/summary.md"
|
13
|
+
end
|
10
14
|
if File.exist?(file)
|
11
|
-
@
|
15
|
+
@raw_md = File.read(file)
|
12
16
|
else
|
13
|
-
@
|
17
|
+
@raw_md = ""
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
|
-
def pre_processing
|
21
|
+
def pre_processing(dir)
|
22
|
+
@markdown = @raw_md
|
18
23
|
if @config.preprocessing["backlinks"]
|
19
24
|
@markdown = @markdown.gsub(/\[\[(.*)\]\]/) do |s|
|
20
25
|
s = s[2..-3]
|
21
26
|
"[#{s}](#{s}.html)"
|
22
27
|
end
|
23
28
|
end
|
29
|
+
unless dir.empty?
|
30
|
+
@markdown = @markdown.gsub(/\[.*\]\((.*)\)/) do |s|
|
31
|
+
url = Regexp.last_match[1]
|
32
|
+
pn = Pathname.new(url)
|
33
|
+
s.gsub(url, "./"+pn.relative_path_from(dir+"/").to_s)
|
34
|
+
end
|
35
|
+
end
|
24
36
|
end
|
25
37
|
|
26
|
-
def html
|
27
|
-
pre_processing()
|
38
|
+
def html(dir=nil)
|
39
|
+
pre_processing(dir)
|
28
40
|
return Kramdown::Document.new(@markdown, input: 'GFM').to_html
|
29
41
|
end
|
30
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.1.
|
4
|
+
version: 0.1.8
|
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-02-
|
11
|
+
date: 2023-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|