bridgetown_markdown_lazylinks 0.2.1 → 0.2.2
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +11 -0
- data/lib/bridgetown_markdown_lazylinks/converter.rb +10 -3
- data/lib/bridgetown_markdown_lazylinks/version.rb +1 -1
- data/lib/bridgetown_markdown_lazylinks.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a944effb47e50a54e844dc41a7394af50a8f8140273794953eb01c2b3cc4a662
|
|
4
|
+
data.tar.gz: 7fbaf75c16eae42ed8911ef74860e557aa20e8bba193796cd356ed8692ff2ada
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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 =~
|
|
38
|
+
while content =~ lazy_links_regex
|
|
36
39
|
self.counter += 1
|
|
37
|
-
content.sub!(
|
|
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
|
|
@@ -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
|
-
|
|
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.
|
|
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-
|
|
11
|
+
date: 2023-06-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bridgetown
|