markdown_extension 0.0.6 → 0.0.8

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: 3ddb3ebd46cfa75b4a02431c3f695df13cf45fac0dae5d30b0d7f710c3bbfcf1
4
- data.tar.gz: 22bc0feb032ec88c5c83c053c0da28397d7b4fa2cd0bf7e030b6659dcf83cfff
3
+ metadata.gz: 84d0ed37fd3f0cdd2a3d4579784f4a551332e348e6045b6b6b528007ecd1bd1d
4
+ data.tar.gz: 48499780c8921299b1d4163a7874ff459c77a41005c6318e655abf03a6976a1a
5
5
  SHA512:
6
- metadata.gz: 5e0322c6afe27efdfdfbf5fd921b8c7896e400809e5b61bcff609ce9881e5d120adec2dcba648f3aa50c97a3411cb67d672f75c0ba05b20162f94c077e4041e4
7
- data.tar.gz: 76c998a06980e6ec32d40819e94323d925fb812a5462660e55999d3d4e7fe1ba413d33e8f6c4564902a053b906ca9393461dab6b70301f4efb005203ec2a9ee4
6
+ metadata.gz: 04f94cc25c7a5d5e345aec0db1bfba01df9280460f53c214598d65bf0a413dd4373459d203a6f9f7d31482c6072923a33ebecb86409e243bdc900aded7961814
7
+ data.tar.gz: ad24ee78e8fe8496484accdb3de029e53f01164c7149c3389a42dc19aa8f9531f89df17e74f591de94eaec813ac81ea791c34a2918ea9b9a3414d628e14280b1
@@ -4,10 +4,9 @@ require "tomlrb"
4
4
 
5
5
  module MarkdownExtension
6
6
  class Page
7
- attr_accessor :site, :markdown, :meta, :item_name, :title
7
+ attr_accessor :site, :markdown, :meta, :item_name
8
8
 
9
9
  def initialize(file, site)
10
- @title = file.split("/")[-1].gsub(".md","")
11
10
  @site = site
12
11
  if File.exists?(file)
13
12
  @markdown = File.read(file)
@@ -19,14 +18,23 @@ module MarkdownExtension
19
18
  @meta = mds[1]
20
19
  @markdown = mds[2..-1].join("---\n")
21
20
  end
21
+ if @markdown[-1]=="-"
22
+ @markdown = @markdown[0..-2]
23
+ end
22
24
  @item_name = file.split("/")[-1].gsub(".md","")
23
25
  end
24
26
 
25
27
  def pre_processing
26
28
  if @site.config.preprocessing["backlinks"]
27
- @markdown = @markdown.gsub(/\[\[(.*)\]\]/) do |s|
28
- s = s[2..-3]
29
- "[#{s}](#{s}.html)"
29
+ @markdown = @markdown.gsub(/\[\[([^\]]+)\]\]/) do |s|
30
+ index = @markdown.index(s)
31
+ if (@markdown[index-1]=="(" && @markdown[index+s.size]==")")
32
+ s = s[2..-3]
33
+ "#{s}.html"
34
+ else
35
+ s = s[2..-3]
36
+ "[#{s}](#{s}.html)"
37
+ end
30
38
  end
31
39
  if @site.references[@item_name]
32
40
  @markdown += "\n\n\n"
@@ -44,7 +44,7 @@ module MarkdownExtension
44
44
  end
45
45
 
46
46
  def gen_references(file, text)
47
- text.gsub(/\[\[(.*)\]\]/) do |s|
47
+ text.gsub(/\[\[([^\]]+)\]\]/) do |s|
48
48
  s = s[2..-3]
49
49
  item_name = file.split("/")[-1].gsub(".md","")
50
50
  if @references[s]
@@ -1,3 +1,3 @@
1
1
  module MarkdownExtension
2
- Version = '0.0.6'
2
+ Version = '0.0.8'
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.0.6
4
+ version: 0.0.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-01-04 00:00:00.000000000 Z
11
+ date: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb