markdown_extension 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ddb3ebd46cfa75b4a02431c3f695df13cf45fac0dae5d30b0d7f710c3bbfcf1
4
- data.tar.gz: 22bc0feb032ec88c5c83c053c0da28397d7b4fa2cd0bf7e030b6659dcf83cfff
3
+ metadata.gz: 6101b1a888999d59f89a4db3050eb8d72cbc8027210b6a113cb6e9250bd2d28e
4
+ data.tar.gz: f962ecfc313df40e61d4d1b320e5e3a542c4c41783d6c03437c6828759aa4904
5
5
  SHA512:
6
- metadata.gz: 5e0322c6afe27efdfdfbf5fd921b8c7896e400809e5b61bcff609ce9881e5d120adec2dcba648f3aa50c97a3411cb67d672f75c0ba05b20162f94c077e4041e4
7
- data.tar.gz: 76c998a06980e6ec32d40819e94323d925fb812a5462660e55999d3d4e7fe1ba413d33e8f6c4564902a053b906ca9393461dab6b70301f4efb005203ec2a9ee4
6
+ metadata.gz: 357d38eab68c50ca38e18c4fa9223f2d40fc1229487f4637128504c481512537274df13a18f9dcc5983759d0935b34649d88a18e670dbcd60f6e714ec44c4ba5
7
+ data.tar.gz: a0d834f4d276778b0de7019acf71d2b95d4912745670c33540b93885d61c8e938d9961d396dd238ec474ccca397e342b73efa49ac959218ace1b03e8bf5c7bed
@@ -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)
@@ -24,9 +23,15 @@ module MarkdownExtension
24
23
 
25
24
  def pre_processing
26
25
  if @site.config.preprocessing["backlinks"]
27
- @markdown = @markdown.gsub(/\[\[(.*)\]\]/) do |s|
28
- s = s[2..-3]
29
- "[#{s}](#{s}.html)"
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
30
35
  end
31
36
  if @site.references[@item_name]
32
37
  @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.7'
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.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: 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