literate_md 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/literate_md +5 -1
- data/test/test_literate_md.rb +0 -0
- metadata +5 -4
data/bin/literate_md
CHANGED
@@ -11,6 +11,7 @@ opts = $opts || Trollop::options do
|
|
11
11
|
opt :outputdir, "Directory to write files to", :default => Dir.pwd, :short => 'o'
|
12
12
|
opt :lang, "Default language of code", :default => "ruby", :short => 'l'
|
13
13
|
opt :files, "Files to process", :type => :string, :short => 'f', :required => true
|
14
|
+
opt :standalone, "Weaves in html and body tags", :default => false, :short => 's'
|
14
15
|
end
|
15
16
|
|
16
17
|
$allowed = '(\w| )*|((.*:)?\*)'
|
@@ -27,7 +28,7 @@ $ext_for_lang = {
|
|
27
28
|
}
|
28
29
|
|
29
30
|
class Weave < Redcarpet::Render::XHTML
|
30
|
-
attr_accessor :default_lang, :original_text
|
31
|
+
attr_accessor :default_lang, :original_text, :standalone
|
31
32
|
def block_code(code, lang)
|
32
33
|
l_ang, r_ang, equiv = "__lang__", "__rang__", "__equiv__"
|
33
34
|
line_num = @original_text[0,@original_text.index(code)].count("\n")+1
|
@@ -46,6 +47,8 @@ class Weave < Redcarpet::Render::XHTML
|
|
46
47
|
gsub(/#{l_ang}(#{$allowed})#{r_ang}/,'⟨\\1⟩')
|
47
48
|
end
|
48
49
|
def codespan(code); block_code(code,nil) end
|
50
|
+
def doc_header; "<html><body>" if @standalone end
|
51
|
+
def doc_footer; "</body></html>" if @standalone end
|
49
52
|
end
|
50
53
|
|
51
54
|
def write_to path, data
|
@@ -56,6 +59,7 @@ end
|
|
56
59
|
if opts.weave
|
57
60
|
r = Redcarpet::Markdown.new(Weave, html_opts)
|
58
61
|
r.renderer.default_lang = opts.lang.to_sym
|
62
|
+
r.renderer.standalone = opts.standalone
|
59
63
|
opts.files.split(',').each{|file|
|
60
64
|
code = File.open(file, 'r'){|f|f.read}
|
61
65
|
r.renderer.original_text = code
|
data/test/test_literate_md.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: literate_md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- remis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: redcarpet
|
@@ -68,6 +68,7 @@ description: |
|
|
68
68
|
--outputdir, -o <s>: Directory to write files to (default: /Users/mollysong/Documents/Nicholas/literate_md)
|
69
69
|
--lang, -l <s>: Default language of code (default: ruby)
|
70
70
|
--files, -f <s>: Files to process
|
71
|
+
--standalone, -s: Weaves in html and body tags
|
71
72
|
--help, -h: Show this message
|
72
73
|
|
73
74
|
email:
|