mdless 1.0.1 → 1.0.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: 7ad40bdc7ff7382f5205104ee7ef2983f1f04a97f9723723265e0efe1abf9ad9
4
- data.tar.gz: b39655a8c2bcf3d619ab4dae8fe596bc40a160e22cfeef22d6677296e47f8c89
3
+ metadata.gz: 60b3541746585a41e0cdd5ef8d078b7c64c3afa7024710f5a0af7d22b33e8722
4
+ data.tar.gz: 5e877c78b1924f7d34b1b13225702d6c236c75c0055cd7c3c2aea78c1dc802d8
5
5
  SHA512:
6
- metadata.gz: c3bef39bca518259bd974527b6bd2f834a32db954bc4d6c91fdf2e0e312e705807aa78bd74c3d11f95eb96a510de8c72c493cab704829bea7df2bf38bfd0932f
7
- data.tar.gz: 5f28c0eaccca18314dd0c6645e720c27221c81d68ad5500239c830f27ff0737da0e19c2ee75460058de5afe68fdd6361c778849a2da2b40d649a5d2878cea14e
6
+ metadata.gz: 60bffe2be11c62398ccba8e29c95f786b6eb9cdc0e86cf79dca7b3d29554426e75bf7221d01f6c52270075e8732fe26a554da2948e6a47598d7507dcfb928177
7
+ data.tar.gz: 44cde0fea6749c4d71a29c044dcece8385663c65e2540a2cbbb24d758895e371917f6e710dd0f599b416412b709b22dd15dfad7a8866b119eb40599eefaa5dfe
@@ -31,6 +31,11 @@ module CLIMarkdown
31
31
  'marker' => 'd black on_black',
32
32
  'color' => 'd white on_black'
33
33
  },
34
+ 'emphasis' => {
35
+ 'bold' => 'b',
36
+ 'italic' => 'u i',
37
+ 'bold-italic' => 'b u i'
38
+ },
34
39
  'h1' => {
35
40
  'color' => 'b intense_black on_white',
36
41
  'pad' => 'd black on_white',
@@ -122,6 +127,11 @@ module CLIMarkdown
122
127
  new_theme = YAML.load(IO.read(theme_file))
123
128
  begin
124
129
  @theme = theme_defaults.deep_merge(new_theme)
130
+ # write merged theme back in case there are new keys since
131
+ # last updated
132
+ File.open(theme_file,'w') {|f|
133
+ f.puts @theme.to_yaml
134
+ }
125
135
  rescue
126
136
  @log.warn('Error merging user theme')
127
137
  @theme = theme_defaults
@@ -172,8 +182,11 @@ module CLIMarkdown
172
182
  @options[:local_images] = false
173
183
  @options[:remote_images] = false
174
184
 
175
- if exec_available('imgcat') && ENV['TERM_PROGRAM'] == 'iTerm.app'
176
- opts.on('-i', '--images=TYPE', 'Include [local|remote (both)] images in output (requires imgcat and iTerm2, default NONE)' ) do |type|
185
+
186
+ opts.on('-i', '--images=TYPE', 'Include [local|remote (both)] images in output (requires imgcat and iTerm2, default NONE)' ) do |type|
187
+ unless exec_available('imgcat')# && ENV['TERM_PROGRAM'] == 'iTerm.app'
188
+ @log.warn('images turned on but imgcat not found')
189
+ else
177
190
  if type =~ /^(r|b|a)/i
178
191
  @options[:local_images] = true
179
192
  @options[:remote_images] = true
@@ -181,7 +194,11 @@ module CLIMarkdown
181
194
  @options[:local_images] = true
182
195
  end
183
196
  end
184
- opts.on('-I', '--all-images', 'Include local and remote images in output (requires imgcat and iTerm2)' ) do
197
+ end
198
+ opts.on('-I', '--all-images', 'Include local and remote images in output (requires imgcat and iTerm2)' ) do
199
+ unless exec_available('imgcat')# && ENV['TERM_PROGRAM'] == 'iTerm.app'
200
+ @log.warn('images turned on but imgcat not found')
201
+ else
185
202
  @options[:local_images] = true
186
203
  @options[:remote_images] = true
187
204
  end
@@ -802,8 +819,11 @@ module CLIMarkdown
802
819
  color('hr color') + '_'*@cols + xc
803
820
  end
804
821
 
822
+ # escaped characters
823
+ line.gsub!(/\\(\S)/,'\1')
824
+
805
825
  # bold, bold/italic
806
- line.gsub!(/(?<pre>^|\s)(?<open>[\*_]{2,3})(?<content>[^\*_\s][^\*_]+?[^\*_\s])[\*_]{2,3}/) do |m|
826
+ line.gsub!(/(?<pre>^|[ "'\(“])(?<open>[\*_]{2,3})(?<content>[^\*_\s][^\*_]+?[^\*_\s])[\*_]{2,3}/) do |m|
807
827
  match = Regexp.last_match
808
828
  last = find_color(match.pre_match, true)
809
829
  counter = i
@@ -811,12 +831,12 @@ module CLIMarkdown
811
831
  counter -= 1
812
832
  last = find_color(lines[counter])
813
833
  end
814
- emph = match['open'].length == 2 ? c([:b]) : c(%i[b u i])
834
+ emph = match['open'].length == 2 ? color('emphasis bold') : color('emphasis bold-italic')
815
835
  "#{match['pre']}#{emph}#{match['content']}" + (last ? last : xc)
816
836
  end
817
837
 
818
838
  # italic
819
- line.gsub!(/(^|\s)[\*_]([^\*_\s][^\*_]+?[^\*_\s])[\*_]/) do |m|
839
+ line.gsub!(/(?<pre>^|[ "'\(“])[\*_](?<content>[^\*_\s][^\*_]+?[^\*_\s])[\*_]/) do |m|
820
840
  match = Regexp.last_match
821
841
  last = find_color(match.pre_match, true)
822
842
  counter = i
@@ -824,7 +844,7 @@ module CLIMarkdown
824
844
  counter -= 1
825
845
  last = find_color(lines[counter])
826
846
  end
827
- "#{match[1]}#{c(%i[u i])}#{match[2]}" + (last ? last : xc)
847
+ "#{match['pre']}#{color('emphasis italic')}#{match[2]}" + (last ? last : xc)
828
848
  end
829
849
 
830
850
  # equations
@@ -1,3 +1,3 @@
1
1
  module CLIMarkdown
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdless
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra