markdown_extension 0.1.3 → 0.1.4

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: 50c08898555f26c59998ab98e23fc1f08c89aabadd12cd3b6d1a7586e2f18ef6
4
- data.tar.gz: '094169ccaf465370f4f3b9f1cbb7af6a9e13756a517c84a911c1e82cc2e7d84f'
3
+ metadata.gz: 3f44807dea45f0339b4c9cf41a43b97de1dbfc5592636d2d90fdb43be80359da
4
+ data.tar.gz: 66e25bf0ccd04b10246cb8a6238d20e3720b82ea8f94db868e3107c391008d0a
5
5
  SHA512:
6
- metadata.gz: 6c11cbb31990b7b9c4c259edd56a0109af8751235f577e4d99d8f9c705fb06b6adf67344707efde6c399740057d3766f39b383162069756ac91d5734dba74379
7
- data.tar.gz: b1498bf48a772c87fe39d4392f904a4303da6584a930903148e66bdb734809cdc16807f749684c875cf83acecf845d742e9e968572b6dbee7979811119167600
6
+ metadata.gz: 04b0a26702f88e04998784415f1861fa2ff47de91586d01efdf075011d45e6e8595e5c5bb9d5f2285c011889b154438c4f3b8e780d4ee8e399f97de55b7e8be3
7
+ data.tar.gz: e5ff3b2669a814b5ab772bef10de32bd0a3cdf9a1728122b1a8351f1380eaf40fba37a34dd044b0c0b83d337efe91424ae7717ea36a445f4085ea405bdb5f480
@@ -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)
@@ -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.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhuang Biaowei