markdown_extension 0.1.3 → 0.1.5

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: 50c08898555f26c59998ab98e23fc1f08c89aabadd12cd3b6d1a7586e2f18ef6
4
- data.tar.gz: '094169ccaf465370f4f3b9f1cbb7af6a9e13756a517c84a911c1e82cc2e7d84f'
3
+ metadata.gz: 3bab0fc1cbab47458d317c5444ed844e94c29c46e6f0c4875f0f7dab3a7a1ac0
4
+ data.tar.gz: c7d700171cbe05cb754cd4b25f8822eb2d5542f68372f4fab465e4e096b647ec
5
5
  SHA512:
6
- metadata.gz: 6c11cbb31990b7b9c4c259edd56a0109af8751235f577e4d99d8f9c705fb06b6adf67344707efde6c399740057d3766f39b383162069756ac91d5734dba74379
7
- data.tar.gz: b1498bf48a772c87fe39d4392f904a4303da6584a930903148e66bdb734809cdc16807f749684c875cf83acecf845d742e9e968572b6dbee7979811119167600
6
+ metadata.gz: 8efaa59df86d779cec7024b8a29252f67188c5355bb946fe7b3107adda604af9f123d5561ab217f6a1b1fed2b6fe04b1485c001619e1fbe32f316b0a0356dab6
7
+ data.tar.gz: ef70615088430a67706d6406298e70635e647827c27181175732d919adc4ebfc4dd4e873f7fae6fce29a840e272b0833a1044655c0895e2adda2f11a8a932b7c
@@ -4,7 +4,7 @@ module MarkdownExtension
4
4
  def initialize(config, type)
5
5
  @config = config
6
6
  @type = type
7
- @inner_citations = {}
7
+ @inner_citations = {}
8
8
  if config.citation
9
9
  init_citation()
10
10
  end
@@ -25,7 +25,37 @@ module MarkdownExtension
25
25
  @inner_citations[id] = "P#{page_no} #{content}"
26
26
  i = i + 4
27
27
  end
28
- end
28
+ end
29
+ end
30
+
31
+ def add_embed_citation(file)
32
+ text = File.read(file)
33
+ text.gsub!("\t", " ")
34
+ temp_id = ""
35
+ temp_context = ""
36
+ prev_line = ""
37
+ space = 0
38
+ if text.index("id:: ")
39
+ text.split("\n").each do |line|
40
+ if temp_space = line.index("id:: ")
41
+ temp_id = line.split("id:: ")[1]
42
+ temp_context = prev_line + "\n"
43
+ space = temp_space
44
+ next
45
+ end
46
+ if line.strip == "collapsed:: true"
47
+ next
48
+ end
49
+ if line.length - line.lstrip.length > space
50
+ temp_context = temp_context + line + "\n"
51
+ else
52
+ unless temp_id==""
53
+ @inner_citations[temp_id] = temp_context
54
+ end
55
+ end
56
+ prev_line = line
57
+ end
58
+ end
29
59
  end
30
60
 
31
61
  def get_inner_citation(id)
@@ -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
@@ -57,6 +57,10 @@ module MarkdownExtension
57
57
  j = @markdown.index(":END:", i)
58
58
  @markdown=@markdown[0..i-4] + @markdown[j+5..-1]
59
59
  end
60
+ @markdown = @markdown.gsub(/{{embed \(\(([^\)]+)\)\)}}/) do |s|
61
+ id = s[10..-5]
62
+ "embed #{id}: \n" + @site.citations.get_inner_citation(id)
63
+ end
60
64
  @markdown = @markdown.gsub(/\(\([^\)]+\)\)/) do |s|
61
65
  if s.index(":")
62
66
  id = s
@@ -38,6 +38,8 @@ module MarkdownExtension
38
38
  unless file == pages_path + "/summary.md"
39
39
  if file.index("hls_")
40
40
  @citations.add_inner_citation(file)
41
+ else
42
+ @citations.add_embed_citation(file)
41
43
  end
42
44
  end
43
45
  end
@@ -1,3 +1,3 @@
1
1
  module MarkdownExtension
2
- Version = '0.1.3'
2
+ Version = '0.1.5'
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.3
4
+ version: 0.1.5
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-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb