bridgetown_markdown_lazylinks 0.2.1 → 0.2.2

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: 86e6cb9298548d242ddb0b0019dd56e9ee5a8289ee887537d8c32fd3dd9d6d33
4
- data.tar.gz: 4b182e8ef852ed145a3d15a6de43c929e42d9eca32497d5476b22d300efb31d4
3
+ metadata.gz: a944effb47e50a54e844dc41a7394af50a8f8140273794953eb01c2b3cc4a662
4
+ data.tar.gz: 7fbaf75c16eae42ed8911ef74860e557aa20e8bba193796cd356ed8692ff2ada
5
5
  SHA512:
6
- metadata.gz: 1055b153830c96dfdfe461e1742c28ff5291c1feaa0b3f60cc69f036e45dda52435717c7e4a2fa255d8a8db28428523068b1870149e1ada525ec7f7cf0ef23b2
7
- data.tar.gz: a84e40e426ff56b0446c3841cf7070d1d8691bddfb65863d06798639a9838e6ef5fa52e2f5857879e233b6b8f2ca4a0c370a49e52cfdabe18332a37e1a76d0d7
6
+ metadata.gz: d56b2bf3438a69233e4c1bc407c30c97adcf9cd8e814ea7867e72c0f444ccf3ebdcc179091fe975dda7ca7ba072e7af5b0334cf759bea7ca74296f6dbb0b9acb
7
+ data.tar.gz: 4a908bf5d842001475673bf092fc6f4a8d21f45932cc0be9c0633a1733d25252f37ef6e63175c5e318f545e6233fb84deb90beb8d5eb05f7e35ab3adf3d5e70e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.2] - 2023-06-26
11
+
12
+ - allow placeholder customization
13
+
10
14
  ## [0.2.1] - 2023-06-19
11
15
 
12
16
  - add a plugin initializer
@@ -23,3 +27,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
27
  [0.1.0]: https://github.com/akarzim/bridgetown_markdown_lazylinks/releases/tag/v0.1.0
24
28
  [0.2.0]: https://github.com/akarzim/bridgetown_markdown_lazylinks/releases/tag/v0.2.0
25
29
  [0.2.1]: https://github.com/akarzim/bridgetown_markdown_lazylinks/releases/tag/v0.2.1
30
+ [0.2.2]: https://github.com/akarzim/bridgetown_markdown_lazylinks/releases/tag/v0.2.2
data/README.md CHANGED
@@ -22,6 +22,17 @@ Or if there's a `bridgetown.automation.rb` automation script, you can run that i
22
22
  bin/bridgetown apply https://github.com/akarzim/bridgetown_markdown_lazylinks
23
23
  ```
24
24
 
25
+ ### Customization
26
+
27
+ You can customize the lazylinks placeholder in this way to use `+` instead of `*`:
28
+
29
+ ```ruby
30
+ init :bridgetown_markdown_lazylinks do
31
+ placeholder "+"
32
+ end
33
+ ```
34
+
35
+
25
36
  ## Usage
26
37
 
27
38
  The plugin will allow you to use `*` as link references in your markdown
@@ -21,20 +21,23 @@ module BridgetownMarkdownLazylinks
21
21
  class Converter < Bridgetown::Converter
22
22
  priority :high
23
23
 
24
- LAZY_LINKS_REGEX = %r!(?<link>\[[^\]]+\]\s*\[)\*(?<url>\].*?^\[)\*\]:!m.freeze
24
+ DEFAULT_PLACEHOLDER = :*
25
25
 
26
26
  def initialize(config = {})
27
27
  super
28
28
 
29
29
  self.class.input @config["markdown_ext"].split(",")
30
30
  @counter = 0
31
+ @placeholder = config.bridgetown_markdown_lazylinks.placeholder || DEFAULT_PLACEHOLDER
31
32
  end
32
33
 
33
34
  def convert(content)
35
+ lazy_links_regex = %r!(\[[^\]]+\]\s*\[)#{placeholder}(\].*?^\[)#{placeholder}\]:!m.freeze
36
+
34
37
  cache.getset(content) do
35
- while content =~ LAZY_LINKS_REGEX
38
+ while content =~ lazy_links_regex
36
39
  self.counter += 1
37
- content.sub!(LAZY_LINKS_REGEX, "\\k<link>#{counter}\\k<url>#{counter}]:")
40
+ content.sub!(lazy_links_regex, "\\1#{counter}\\2#{counter}]:")
38
41
  end
39
42
 
40
43
  content
@@ -45,6 +48,10 @@ module BridgetownMarkdownLazylinks
45
48
 
46
49
  attr_accessor :counter
47
50
 
51
+ def placeholder
52
+ Regexp.quote(@placeholder)
53
+ end
54
+
48
55
  def cache
49
56
  @cache ||= Bridgetown::Cache.new("BridgetownMarkdownLazylinks")
50
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgetownMarkdownLazylinks
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -8,6 +8,7 @@ require "bridgetown_markdown_lazylinks/converter"
8
8
  # @see https://github.com/bridgetownrb/bridgetown/issues/769#issuecomment-1596520674
9
9
  #
10
10
  # @param config [Bridgetown::Configuration::ConfigurationDSL]
11
- Bridgetown.initializer :bridgetown_markdown_lazylinks do |_|
12
- # noop
11
+ Bridgetown.initializer :bridgetown_markdown_lazylinks do |config, placeholder: :*|
12
+ config.bridgetown_markdown_lazylinks ||= {}
13
+ config.bridgetown_markdown_lazylinks.placeholder = placeholder
13
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown_markdown_lazylinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - François Vantomme
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown