mdless 1.0.1 → 1.0.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/lib/mdless/converter.rb +27 -7
- data/lib/mdless/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60b3541746585a41e0cdd5ef8d078b7c64c3afa7024710f5a0af7d22b33e8722
|
4
|
+
data.tar.gz: 5e877c78b1924f7d34b1b13225702d6c236c75c0055cd7c3c2aea78c1dc802d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60bffe2be11c62398ccba8e29c95f786b6eb9cdc0e86cf79dca7b3d29554426e75bf7221d01f6c52270075e8732fe26a554da2948e6a47598d7507dcfb928177
|
7
|
+
data.tar.gz: 44cde0fea6749c4d71a29c044dcece8385663c65e2540a2cbbb24d758895e371917f6e710dd0f599b416412b709b22dd15dfad7a8866b119eb40599eefaa5dfe
|
data/lib/mdless/converter.rb
CHANGED
@@ -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
|
-
|
176
|
-
|
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
|
-
|
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
|
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 ?
|
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!(/(
|
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[
|
847
|
+
"#{match['pre']}#{color('emphasis italic')}#{match[2]}" + (last ? last : xc)
|
828
848
|
end
|
829
849
|
|
830
850
|
# equations
|
data/lib/mdless/version.rb
CHANGED