serve-markdown 0.0.1 → 0.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/serve-markdown.rb +17 -3
- 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: 2c691699f2e33e8a596ef9116689833a5a4c0c93691729c499f7da428b97118b
|
4
|
+
data.tar.gz: 683a16bde104677e77da09d5b5d74ecf5dd154b7fceaabcd6c2bab33af9f1cb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2569839ff4f92d7149c88885f75c89280600e567635a70db4295a8d9e43fc20860f4b0d443d28c6a117724db63a3ee4e54cb4b81822ff80b6668820db12488ac
|
7
|
+
data.tar.gz: 6868251b6ce37557733cc453c3b5ff71d4258e31bef70ae16fb3c8e8e550b9a60cd9cea49f9e6b8422dab896e506f8f32c61ae25fb54bc91c0f015d68ceac3a6
|
data/lib/serve-markdown.rb
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
require 'erubi'
|
2
2
|
require 'tilt'
|
3
|
-
require 'fileutils'
|
4
3
|
require 'webrick'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
@options = {}
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: markdown-serve [options]"
|
9
|
+
opts.on("-h", "--help", "Prints this help") do
|
10
|
+
puts opts; exit
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on("-o", "--output-templates", "Output templates to local directory") do
|
14
|
+
FileUtils.cp_r File.join(__dir__, 'templates'), '.'; exit
|
15
|
+
end
|
16
|
+
end.parse!
|
5
17
|
|
6
18
|
FileUtils.remove_dir('html', force=true)
|
7
19
|
FileUtils.mkdir('html')
|
8
20
|
|
9
|
-
|
10
|
-
|
21
|
+
layout_path = Pathname.new('templates/layout.html.erb').exist? ? 'templates/layout.html.erb' : File.join(__dir__, 'templates/layout.html.erb')
|
22
|
+
|
23
|
+
layout = Tilt.new(layout_path)
|
24
|
+
filenames = Dir['*.md'].map { |fn| fn[/(.*)\.md/, 1] } # removes the .md suffix from fns
|
11
25
|
|
12
26
|
filenames.map { |fn| ["#{fn}.md", "#{fn}.html"] }.each do |md_fn, html_fn|
|
13
27
|
contents = Tilt.new(md_fn).render
|