lifer 0.10.0 → 0.10.1
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 +18 -2
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/lifer/entry/markdown.rb +20 -23
- data/lib/lifer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae7d44054aac227a4d75940cf8c6d30b46ba403780f5d8583d0db22dfd8cf36e
|
4
|
+
data.tar.gz: 7c8ac4e684afa95e23f22dc1b6ad0472391c3fc946a6b7bbbdf9acfbf46ac31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464566f240f05e2c5e199582555ccecd9bc6449ad477d53adb24905d76e07b9f93c13d050f69cd6c5923f9f9434edca1d14b4d01d674c5b4148bb5d9c85723df
|
7
|
+
data.tar.gz: 270f4d8c20bc24b180ae474a6d62037b2f2347a4d9e25f7a4af207d0e85d6df66fec0f92a82f57248e05ac34966ba69ff542a30c9e36d4f90e99fe41a46eeba6
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
## Next
|
2
2
|
|
3
|
+
## v0.10.1
|
4
|
+
|
5
|
+
This release resolves a bug with `Entry#summary`. When I originally implemented
|
6
|
+
summaries as first paragraphs, I didn't realize that using the Kramdown
|
7
|
+
representation of the document would result in special characters being
|
8
|
+
transformed badly:
|
9
|
+
|
10
|
+
In the ldquorealmrdquo where dreams dance
|
11
|
+
|
12
|
+
This change ensures that we don't end up with trash like that, or other HTML
|
13
|
+
trash.
|
14
|
+
|
15
|
+
The summary is meant to be ideal for things like `<meta>` description tags,
|
16
|
+
which should only contain plain text.
|
17
|
+
|
18
|
+
|
3
19
|
## v0.10.0
|
4
20
|
|
5
|
-
|
6
|
-
|
21
|
+
This release lets all layout files (either Liquid or ERB files) provide a
|
22
|
+
reference to parent, or "root", layout files that should wrap the via
|
7
23
|
frontmatter.
|
8
24
|
|
9
25
|
Previously, we did this for Liquid layouts using the custom `layout` tag. But
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -107,6 +107,10 @@ Then, build and push the gem to RubyGems:
|
|
107
107
|
$ gem build
|
108
108
|
$ gem push lifer-<new_version_without_the_v_prefix>.gem
|
109
109
|
|
110
|
+
And ensure that the release commit(s) are on the `main` branch:
|
111
|
+
|
112
|
+
$ git push origin main
|
113
|
+
|
110
114
|
## Contributing
|
111
115
|
|
112
116
|
I'm not currently accepting unsolicited contributions to Lifer. I'm still
|
data/lib/lifer/entry/markdown.rb
CHANGED
@@ -30,14 +30,16 @@ class Lifer::Entry::Markdown < Lifer::Entry
|
|
30
30
|
def summary
|
31
31
|
return super if super
|
32
32
|
|
33
|
-
return if
|
34
|
-
return first_paragraph if first_paragraph.length <= TRUNCATION_THRESHOLD
|
33
|
+
return if raw_first_paragraph_text.nil?
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
text = raw_first_paragraph_text
|
36
|
+
return text if text.length <= TRUNCATION_THRESHOLD
|
37
|
+
|
38
|
+
truncated_text = text[0..TRUNCATION_THRESHOLD]
|
39
|
+
if (index_of_final_fullstop = text.rindex ". ")
|
40
|
+
truncated_text[0..index_of_final_fullstop]
|
39
41
|
else
|
40
|
-
"%s..." %
|
42
|
+
"%s..." % truncated_text
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -57,7 +59,7 @@ class Lifer::Entry::Markdown < Lifer::Entry
|
|
57
59
|
#
|
58
60
|
# @return [String] The HTML for the body of the entry.
|
59
61
|
def to_html
|
60
|
-
Kramdown::Document.new(body).to_html
|
62
|
+
@to_html ||= Kramdown::Document.new(body).to_html
|
61
63
|
end
|
62
64
|
|
63
65
|
private
|
@@ -75,25 +77,20 @@ class Lifer::Entry::Markdown < Lifer::Entry
|
|
75
77
|
end.uniq
|
76
78
|
end
|
77
79
|
|
78
|
-
#
|
80
|
+
# Detects the raw paragraph text from the entry.
|
79
81
|
#
|
82
|
+
# @fixme It would be easier and less error prone to do this with Nokogiri. But
|
83
|
+
# we currently don't need the dependency for any other reason, so let's
|
84
|
+
# defer adding it until then.
|
80
85
|
# @private
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
Kramdown::Document.new(body).root
|
85
|
-
.children
|
86
|
-
.detect { |child| child.type == :p }
|
87
|
-
)
|
88
|
-
end
|
86
|
+
def raw_first_paragraph_text
|
87
|
+
paragraphs = to_html.match %r{<p[^>]*>(.*?)</p>}im
|
88
|
+
paragraph = paragraphs ? paragraphs[1].strip : nil
|
89
89
|
|
90
|
-
|
91
|
-
def kramdown_paragraph_text(kramdown_element)
|
92
|
-
return if kramdown_element.nil?
|
90
|
+
return unless paragraph
|
93
91
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
.gsub(/\n/, " ")
|
92
|
+
paragraph = paragraph.gsub /<\/?[^>]*>/, ""
|
93
|
+
paragraph = CGI.unescapeHTML paragraph
|
94
|
+
paragraph.gsub(/[\s\n\t]+/, " ").strip
|
98
95
|
end
|
99
96
|
end
|
data/lib/lifer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- benjamin wil
|
@@ -210,8 +210,8 @@ licenses:
|
|
210
210
|
- MIT
|
211
211
|
metadata:
|
212
212
|
allowed_push_host: https://rubygems.org
|
213
|
-
homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.10.
|
214
|
-
source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.10.
|
213
|
+
homepage_uri: https://github.com/benjaminwil/lifer/blob/v0.10.1/README.md
|
214
|
+
source_code_uri: https://github.com/benjaminwil/lifer/tree/v0.10.1
|
215
215
|
changelog_uri: https://github.com/benjaminwil/lifer/blob/main/CHANGELOG.md
|
216
216
|
post_install_message:
|
217
217
|
rdoc_options: []
|