mdless 2.1.7 → 2.1.8
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 +4 -0
- data/lib/mdless/console.rb +1 -1
- data/lib/mdless/converter.rb +19 -1
- data/lib/mdless/hash.rb +5 -4
- data/lib/mdless/theme.rb +7 -2
- 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: 0f08302d14bfa27b06fd821e56f46b6a04049009df87ab024c368e7776209810
|
|
4
|
+
data.tar.gz: c14bd96efedeaa61eba790a1f2e2664df39f85839ad914ffccfe323ef3312ee5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 633007f423725e003e3c7154262801738bf22b79485d09b99caf06a83486fdca50a0e8b91f7d9a4118dd43c2bd0404cccc31a55486a8db00500e82a95007edeb
|
|
7
|
+
data.tar.gz: 870af2c74618556db8a6621016f9cc603f424956adda3441f0e8043f661bb2fac22b7c6f0e1aaa655570b0d7234e2d6e12c625d5a8af89599f2061db42e622ec
|
data/CHANGELOG.md
CHANGED
data/lib/mdless/console.rb
CHANGED
data/lib/mdless/converter.rb
CHANGED
|
@@ -146,6 +146,7 @@ module CLIMarkdown
|
|
|
146
146
|
theme = File.expand_path("~/.config/mdless/#{theme}.theme")
|
|
147
147
|
File.open(theme, 'w') { |f| f.puts(YAML.dump(MDLess.theme)) } unless File.exist?(theme)
|
|
148
148
|
`#{ENV['EDITOR']} '#{theme}'`
|
|
149
|
+
Process.exit 0
|
|
149
150
|
end
|
|
150
151
|
|
|
151
152
|
default(:inline_footnotes, false)
|
|
@@ -212,10 +213,15 @@ module CLIMarkdown
|
|
|
212
213
|
end
|
|
213
214
|
|
|
214
215
|
default(:update_config, false)
|
|
215
|
-
opts.on('--update_config', 'Update the configuration file with new keys and current command line options') do
|
|
216
|
+
opts.on('--update-config', '--update_config', 'Update the configuration file with new keys and current command line options') do
|
|
216
217
|
MDLess.options[:update_config] = true
|
|
217
218
|
end
|
|
218
219
|
|
|
220
|
+
default(:update_theme, false)
|
|
221
|
+
opts.on('--update-theme', 'Update the current theme file with all available keys') do
|
|
222
|
+
MDLess.options[:update_theme] = true
|
|
223
|
+
end
|
|
224
|
+
|
|
219
225
|
default(:wiki_links, false)
|
|
220
226
|
opts.on('--[no-]wiki-links', 'Highlight [[wiki links]]') do |opt|
|
|
221
227
|
MDLess.options[:wiki_links] = opt
|
|
@@ -229,6 +235,17 @@ module CLIMarkdown
|
|
|
229
235
|
exit 1
|
|
230
236
|
end
|
|
231
237
|
|
|
238
|
+
if MDLess.options[:update_theme]
|
|
239
|
+
FileUtils.mkdir_p(File.dirname(config))
|
|
240
|
+
|
|
241
|
+
theme = MDLess.options[:theme] =~ /default/ ? 'mdless' : MDLess.options[:theme]
|
|
242
|
+
theme = File.join(File.dirname(config), "#{theme}.theme")
|
|
243
|
+
contents = YAML.dump(MDLess.theme)
|
|
244
|
+
|
|
245
|
+
File.open(theme, 'w') { |f| f.puts contents }
|
|
246
|
+
Process.exit 0
|
|
247
|
+
end
|
|
248
|
+
|
|
232
249
|
if !File.exist?(config) || MDLess.options[:update_config]
|
|
233
250
|
FileUtils.mkdir_p(File.dirname(config))
|
|
234
251
|
File.open(config, 'w') do |f|
|
|
@@ -236,6 +253,7 @@ module CLIMarkdown
|
|
|
236
253
|
opts.delete(:list)
|
|
237
254
|
opts.delete(:section)
|
|
238
255
|
opts.delete(:update_config)
|
|
256
|
+
opts.delete(:update_theme)
|
|
239
257
|
opts = opts.keys.map(&:to_s).sort.map { |k| [k.to_sym, opts[k.to_sym]] }.to_h
|
|
240
258
|
f.puts YAML.dump(opts)
|
|
241
259
|
warn "Config file saved to #{config}"
|
data/lib/mdless/hash.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
module CLIMarkdown
|
|
2
|
+
# Hash helpers
|
|
2
3
|
class ::Hash
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
def deep_merge(second)
|
|
5
|
+
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
|
6
|
+
self.merge(second ? second.to_h : second, &merger)
|
|
7
|
+
end
|
|
7
8
|
end
|
|
8
9
|
end
|
data/lib/mdless/theme.rb
CHANGED
|
@@ -118,16 +118,21 @@ module CLIMarkdown
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
def load_theme_file(theme_file)
|
|
121
|
-
|
|
121
|
+
raise "Theme #{theme_file} doesn't exist" unless File.exist?(theme_file)
|
|
122
|
+
|
|
122
123
|
begin
|
|
124
|
+
theme_contents = IO.read(theme_file)
|
|
125
|
+
new_theme = YAML.load(theme_contents)
|
|
123
126
|
theme = THEME_DEFAULTS.deep_merge(new_theme)
|
|
124
127
|
# # write merged theme back in case there are new keys since
|
|
125
128
|
# # last updated
|
|
126
129
|
# File.open(theme_file,'w') {|f|
|
|
127
130
|
# f.puts theme.to_yaml
|
|
128
131
|
# }
|
|
129
|
-
rescue StandardError
|
|
132
|
+
rescue StandardError => e
|
|
130
133
|
@log.warn('Error merging user theme')
|
|
134
|
+
warn e
|
|
135
|
+
warn e.backtrace
|
|
131
136
|
theme = THEME_DEFAULTS
|
|
132
137
|
if File.basename(theme_file) =~ /mdless\.theme/
|
|
133
138
|
FileUtils.rm(theme_file)
|
data/lib/mdless/version.rb
CHANGED