msgtrail 0.9.4 → 0.9.5

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: 37b3e65f039cda9ff376bbea5476a4e2ed3f867cf65cf7454366280d433b587e
4
- data.tar.gz: 3cec58c5e959057b87d17ad66453e96beb4b6c87efae0b78472992e4f626b6a6
3
+ metadata.gz: 2b20e814763f7c87e18d49d963781d18d7520016fe813264071cbf001957443c
4
+ data.tar.gz: b960e7bda415b67366027a78ca183e195f30d0a75879720e7963aaabcd86c198
5
5
  SHA512:
6
- metadata.gz: 10141e2815729de2799466e5e8b02b7b5ee9960ba87f327bf76f83aae02ae14cc715ba940f9e67d6d2444d8f06b85187600f2b126f215e86a485b6804ad8593b
7
- data.tar.gz: 72503d1dec88d0794977667838591c2b923d0aaefca49765e9af750e79f5dccc3b879f1be68b5d139ff07c108c01cdf6bb286ee014cdba509bf27b77b3237f2a
6
+ metadata.gz: b6228df3a2905ad14e343aa7f521b8943c5b2f2a3600467099abed217a75c764167f8cbe3b5367a44a9e48741529a3b7683a83e9e519ea1398895876108ec5ef
7
+ data.tar.gz: 72a56bc8be30fc848cc0c5c285b744fdd19541aa240260df1c2fbf912b35ba7ff9743ba697e6b17b43b87c854deceadd3916037b51540523875a139be95503b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.9.5
4
+
5
+ - Add support for ~~strikethrough~~.
6
+
3
7
  ## Version 0.9.4
4
8
 
5
9
  - Add `titlecase` method based on [John Gruber's title casing](https://daringfireball.net/2008/08/title_case_update) rules.
@@ -16,7 +16,7 @@ module RenderHelper
16
16
  end
17
17
 
18
18
  def xml_safe(str)
19
- str.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;").gsub("\"", "&quot;").gsub("'", "&apos;")
19
+ ERB::Util.h(str)
20
20
  end
21
21
 
22
22
  end
@@ -32,7 +32,7 @@ module Msgtrail
32
32
  def initialize(layout_filepath, template_filepath, config)
33
33
  self.article = {}
34
34
  self.config = config
35
- self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true)
35
+ self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true, strikethrough: true)
36
36
  self.plaintext = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
37
37
  self.theme_directory = File.join(config.working_directory, config.settings.file_matter.theme_directory)
38
38
  begin
@@ -99,7 +99,7 @@ module Msgtrail
99
99
  exit(2)
100
100
  end
101
101
  self.config = config
102
- self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true)
102
+ self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true, strikethrough: true)
103
103
  self.plaintext = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
104
104
  self.variables = variables
105
105
  end
@@ -1,21 +1,10 @@
1
1
  module Msgtrail
2
2
  class Titlecase
3
3
 
4
- SMALL_WORDS = [
5
- /\Aa(nd|n|s|t)?\z/,
6
- /\Ab(ut|y)\z/,
7
- /\Aen\z/,
8
- /\Afor\z/,
9
- /\Ai(f|n)\z/,
10
- /\Ao(f|n|r)\z/,
11
- /\At(he|o)\z/,
12
- /\Avs?\.?\z/
13
- ].freeze
14
-
15
- RE = Regexp.new('\b(a(nd|n|s|t)?|b(ut|y)|en|for|i(f|n)|o(f|n|r)|t(he|o)|vs?\.?)\b').freeze
4
+ SMALL_WORDS = Regexp.new('\b(a(nd|n|s|t)?|b(ut|y)|en|for|i(f|n)|o(f|n|r)|t(he|o)|vs?\.?)\b').freeze
16
5
 
17
6
  def self.is_small_word?(word)
18
- !RE.match(word).nil?
7
+ SMALL_WORDS.match(word)
19
8
  end
20
9
 
21
10
  # "__foo" => "__Foo"
@@ -30,22 +19,23 @@ module Msgtrail
30
19
 
31
20
  # before/after => Before/After
32
21
  def self.upcase_word_with_slashes(word)
33
- word.split('/').map { |part| part.capitalize }.join('/')
22
+ word.split('/').map(&:capitalize).join('/')
34
23
  end
35
24
 
36
25
  def self.titlecase(str)
37
- return if (str || '').strip.empty?
26
+ # Replace tabs by single space
27
+ # Replace weird spaces by regular space
28
+ str = (str || '').gsub(/\t/, ' ').gsub("\u{2011}", ' ').strip
29
+ return if str.empty?
38
30
 
39
31
  # Downcase an all-upcase sentence
40
32
  str.downcase! if str.scan(/[A-Z]|\s|\W/).length == str.length
41
33
 
42
- # Replace tabs by single space
43
- # Replace weird spaces by regular space
44
34
  # Split sentence at space boundaries
45
- word_arr = str.gsub(/\t/, ' ').gsub("\u{2011}", ' ').split(' ')
35
+ word_arr = str.split(' ')
46
36
 
47
37
  # Initialize operand array
48
- operand_arr = Array.new(word_arr.size, :nop)
38
+ operand_arr = Array.new(word_arr.size, :capitalize)
49
39
 
50
40
  word_arr.each_with_index do |word, idx|
51
41
  # Don't capitalize small words...
@@ -72,10 +62,10 @@ module Msgtrail
72
62
  word_arr[idx] = upcase_first_real_letter(word) if operand_arr[idx] == :upcase_later
73
63
  word_arr[idx] = upcase_word_with_dashes(word) if operand_arr[idx] == :upcase_dashed
74
64
  word_arr[idx] = upcase_word_with_slashes(word) if operand_arr[idx] == :upcase_slashed
75
- word_arr[idx] = word.capitalize if operand_arr[idx] == :nop
65
+ word_arr[idx] = word.capitalize if operand_arr[idx] == :capitalize
76
66
  end
77
67
 
78
- return word_arr.join(' ')
68
+ word_arr.join(' ')
79
69
  end
80
70
 
81
71
  end
@@ -1,3 +1,3 @@
1
1
  module Msgtrail
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgtrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik van Eykelen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-25 00:00:00.000000000 Z
11
+ date: 2019-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  requirements: []
177
- rubygems_version: 3.0.1
177
+ rubygems_version: 3.0.3
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: A simple blog publication tool