jekyll-wikilinks 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: e65a8cc36608b07333b7fe02a0f37f100117c7ed94d0b2e0fa500520eee6a2aa
4
- data.tar.gz: 8d28d1930fedbddfd17d13c431f42043cdfb3333493929f78977d8da122c0647
3
+ metadata.gz: 861b1b580036bacff2ddf67c3080e21ec36adfe550944fb637ee07ce6afa5b58
4
+ data.tar.gz: 62380a8fbc94fdb4646055999b1deaf339a561bf3fbdfb8f858b0b8e993573fb
5
5
  SHA512:
6
- metadata.gz: bae180a6824ea1a646d9103a0e6701814e1792275ae1037119db819b91fc35a9d01d8fc5c4b64ea8ba689f9b799309fd662ce66e001fd89e1e83eb1114257fba
7
- data.tar.gz: d9327ed183e0d9ade35f23633a70f01157b388cdb627de5890d63cfd151a0bf070ddf92313b92ca385f187b360b96fbaaa770b2dfc29cf9a28fc4ffdb45caa57
6
+ metadata.gz: fa76884a4da7bdca8ec6d389140a8c7f0b193563bba676abe81ea683b6932444abcfe1fb619c0e6186450f38eb81cced6067c154c275854fd73bc81b932c4455
7
+ data.tar.gz: 4e2ffa8675e1a6d5066f472d3b021d1d8c20a11104c1802b0dd451c45d92120b410aea44c8bf8b6af6a42b0d9d3bb287cb4469382e8c66d7e03448cff650c0da
@@ -15,6 +15,7 @@ module Jekyll
15
15
  NAME_KEY = "name"
16
16
  # names
17
17
  ## valid
18
+ TYPED_KEY = "typed"
18
19
  WEB_KEY = "web"
19
20
  WIKI_KEY = "wiki"
20
21
  ## invalid
@@ -38,6 +39,7 @@ module Jekyll
38
39
 
39
40
  def css_name(name_key)
40
41
  return option_css_name(name_key) if option_css_name(name_key)
42
+ return "typed" if name_key == TYPED_KEY
41
43
  # valid
42
44
  return "wiki-link" if name_key == WIKI_KEY
43
45
  # invalid
@@ -44,7 +44,7 @@ module Jekyll
44
44
  filename,
45
45
  )
46
46
  @wikilink_blocks << typed_link_block_wikilink
47
- doc_content.gsub!(typed_link_block_wikilink.md_regex, "")
47
+ doc_content.gsub!(typed_link_block_wikilink.md_regex, "\n")
48
48
  end
49
49
  end
50
50
  end
@@ -75,7 +75,7 @@ module Jekyll
75
75
  # process previous wikilink_list
76
76
  if !processing_wikilink_list.nil? && processing_wikilink_list.has_items?
77
77
  @wikilink_blocks << processing_wikilink_list
78
- doc_content.gsub!(processing_wikilink_list.md_regex, "")
78
+ doc_content.gsub!(processing_wikilink_list.md_regex, "\n")
79
79
  end
80
80
  processing_link_type = link_type
81
81
  processing_wikilink_list = WikiLinkBlock.new(processing_link_type, bullet_type, link_filename_1)
@@ -88,7 +88,7 @@ module Jekyll
88
88
  # process previous wikilink_list
89
89
  if !processing_wikilink_list.nil? && processing_wikilink_list.has_items?
90
90
  @wikilink_blocks << processing_wikilink_list
91
- doc_content.gsub!(processing_wikilink_list.md_regex, "")
91
+ doc_content.gsub!(processing_wikilink_list.md_regex, "\n")
92
92
  end
93
93
  end
94
94
  end
@@ -131,7 +131,7 @@ module Jekyll
131
131
  # process previous wikilink_list
132
132
  if !processing_wikilink_list.nil? && processing_wikilink_list.has_items?
133
133
  @wikilink_blocks << processing_wikilink_list
134
- doc_content.gsub!(processing_wikilink_list.md_regex, "")
134
+ doc_content.gsub!(processing_wikilink_list.md_regex, "\n")
135
135
  end
136
136
  processing_link_type = link_type
137
137
  processing_wikilink_list = WikiLinkBlock.new(processing_link_type)
@@ -143,7 +143,7 @@ module Jekyll
143
143
  # process previous wikilink_list
144
144
  if !processing_wikilink_list.nil? && processing_wikilink_list.has_items?
145
145
  @wikilink_blocks << processing_wikilink_list
146
- doc_content.gsub!(processing_wikilink_list.md_regex, "")
146
+ doc_content.gsub!(processing_wikilink_list.md_regex, "\n")
147
147
  end
148
148
  end
149
149
  end
@@ -164,6 +164,7 @@ module Jekyll
164
164
  end
165
165
  # replace text
166
166
  return if @wikilink_inlines.nil?
167
+ self.sort_typed_first
167
168
  @wikilink_inlines.each do |wikilink|
168
169
  doc_content.gsub!(
169
170
  wikilink.md_link_regex,
@@ -210,7 +211,7 @@ module Jekyll
210
211
  end
211
212
  linked_doc = @doc_manager.get_doc_by_fname(wikilink.filename)
212
213
  if !linked_doc.nil?
213
- link_type = wikilink.typed? ? " typed #{wikilink.link_type}" : ""
214
+ link_type = wikilink.typed? ? " #{$wiki_conf.css_name("typed")} #{wikilink.link_type}" : ""
214
215
 
215
216
  # label
216
217
  wikilink_inner_txt = wikilink.clean_label_txt if wikilink.labelled?
@@ -242,6 +243,21 @@ module Jekyll
242
243
  return '<span class="' + $wiki_conf.css_name("invalid_wiki") + '">' + wikilink.md_link_str + '</span>'
243
244
  end
244
245
  end
246
+
247
+ # helpers
248
+
249
+ def sort_typed_first
250
+ # sorting inline wikilinks is necessary so when wikilinks are replaced,
251
+ # longer strings are replaced first so as not to accidentally overwrite
252
+ # substrings
253
+ # (this is especially likely if there is a matching wikilink that
254
+ # appears as both untyped and typed in a document)
255
+ temp = @wikilink_inlines.dup
256
+ @wikilink_inlines.clear()
257
+ typed_wikilinks = temp.select { |wl| wl.typed? }
258
+ untyped_wikilinks = temp.select { |wl| !wl.typed? }
259
+ @wikilink_inlines = typed_wikilinks.concat(untyped_wikilinks)
260
+ end
245
261
  end
246
262
 
247
263
  # validation
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module WikiLinks
5
5
 
6
- VERSION = "0.0.6"
7
-
6
+ VERSION = "0.0.7"
7
+
8
8
  end
9
- end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-wikilinks
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
  - manunamz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-17 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.2.17
82
+ rubygems_version: 3.2.27
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Add jekyll support for [[wikilinks]] (in markdown files).