literate_md 1.0.3 → 1.0.4
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.
- data/bin/literate_md +5 -4
- data/test/expected_test.rb +15 -0
- data/test/test.md +27 -0
- data/test/test_literate_md.rb +35 -0
- metadata +11 -6
data/bin/literate_md
CHANGED
@@ -4,8 +4,8 @@ require 'coderay'
|
|
4
4
|
require 'redcarpet'
|
5
5
|
require 'trollop'
|
6
6
|
require 'fileutils'
|
7
|
-
|
8
|
-
opts = Trollop::options do
|
7
|
+
|
8
|
+
opts = $opts || Trollop::options do
|
9
9
|
opt :weave, "Produce documentation", :short => 'w'
|
10
10
|
opt :tangle, "Produce code", :short => 't'
|
11
11
|
opt :outputdir, "Directory to write files to", :default => Dir.pwd, :short => 'o'
|
@@ -76,8 +76,9 @@ class Tangle < Redcarpet::Render::Base
|
|
76
76
|
(1..chunks.length-1).each{|index|
|
77
77
|
last, this = chunks[index-1], chunks[index]
|
78
78
|
new_snippet = code[
|
79
|
-
|
80
|
-
|
79
|
+
last[:start] + last[:anchor_len], # start index
|
80
|
+
this[:start] - (last[:start] + last[:anchor_len]) # length of substr
|
81
|
+
]
|
81
82
|
@links[normalise(last[:anchor],lang)] << new_snippet if not new_snippet.strip.empty?
|
82
83
|
}
|
83
84
|
nil
|
data/test/test.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
### my file ###
|
2
|
+
add some *text*:
|
3
|
+
|
4
|
+
~~~~~
|
5
|
+
@*@ +=
|
6
|
+
int main() {
|
7
|
+
@Do Stuff@
|
8
|
+
@Do More Stuff@
|
9
|
+
return 0;
|
10
|
+
}
|
11
|
+
~~~~~
|
12
|
+
|
13
|
+
and some more text. we should probably say what dostuff is; it's:
|
14
|
+
|
15
|
+
~~~~~
|
16
|
+
@Do Stuff@ +=
|
17
|
+
int* me = &1;
|
18
|
+
*me++;
|
19
|
+
@Do More Stuff@ +=
|
20
|
+
/* MORE! MORE! */
|
21
|
+
~~~~~
|
22
|
+
|
23
|
+
was that clearer? More stuff is the same as the first:
|
24
|
+
|
25
|
+
~~~~
|
26
|
+
@Do More Stuff@ += @Do Stuff@
|
27
|
+
~~~~
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
class TestLiterateMD < Test::Unit::TestCase
|
5
|
+
def test_tangle
|
6
|
+
tidy_up(actual_file = 'test/test.rb')
|
7
|
+
$opts = OpenStruct.new(
|
8
|
+
:tangle => true,
|
9
|
+
:weave => false,
|
10
|
+
:outputdir => '.',
|
11
|
+
:files => 'test/test.md',
|
12
|
+
:lang => 'ruby')
|
13
|
+
run_it
|
14
|
+
expected = File.open('test/expected_test.rb', 'r'){|f|f.read}
|
15
|
+
actual = File.open(actual_file, 'r'){|f|f.read}
|
16
|
+
assert_equal expected, actual
|
17
|
+
tidy_up actual_file
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_weave
|
21
|
+
# TODO!
|
22
|
+
end
|
23
|
+
|
24
|
+
def tidy_up file
|
25
|
+
File.delete file if File.exists? file
|
26
|
+
end
|
27
|
+
|
28
|
+
def run_it
|
29
|
+
begin
|
30
|
+
load 'bin/literate_md'
|
31
|
+
rescue SystemExit => e
|
32
|
+
assert_equal e.status, 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
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-03-
|
18
|
+
date: 2012-03-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: redcarpet
|
@@ -78,6 +78,9 @@ extensions: []
|
|
78
78
|
extra_rdoc_files: []
|
79
79
|
|
80
80
|
files:
|
81
|
+
- test/expected_test.rb
|
82
|
+
- test/test.md
|
83
|
+
- test/test_literate_md.rb
|
81
84
|
- bin/literate_md
|
82
85
|
homepage: http://remis-thoughts.blogspot.com
|
83
86
|
licenses: []
|
@@ -112,5 +115,7 @@ rubygems_version: 1.8.5
|
|
112
115
|
signing_key:
|
113
116
|
specification_version: 3
|
114
117
|
summary: Convert markdown documents into code or html
|
115
|
-
test_files:
|
116
|
-
|
118
|
+
test_files:
|
119
|
+
- test/expected_test.rb
|
120
|
+
- test/test.md
|
121
|
+
- test/test_literate_md.rb
|