owlscribble 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,108 @@
1
+ <html><head><title>Welcome to the Jungle</title>
2
+ <style type="text/css">
3
+ body { margin:1em 2em; font-size:90%; font-family:'Trebuchet MS', serif; margin-bottom:30em }
4
+
5
+ a:link, a:visited { color:#009 }
6
+ a.newwikilink { color:#900 }
7
+
8
+ h1,h2,h3,h4,h5,h6 { margin-bottom:0.2em; margin-top:2em; border-bottom:1px solid #999; font-family:sans-serif }
9
+ h1 { font-size:120% }
10
+ h2 { font-size:110% }
11
+ h3,h4 { font-size:100% }
12
+ h5,h6 { font-size:90% }
13
+ h4,h5,h6 { font-style:italic }
14
+
15
+ ul, ol { margin:0; padding:0; margin-left:1.5em; margin-bottom:0.8em }
16
+ ul ol, ol ul, ul ul, ol ol { margin-left:1.5em }
17
+ li { margin-bottom:0 }
18
+ p { margin:0; margin-bottom:0.7em }
19
+ pre { background:#ffd; padding:0.5em; border:1px solid #993 }
20
+ .todo { font-weight:bold; color:#900 }
21
+ .section { margin-left:1em }
22
+ table { border-collapse:collapse; margin-bottom:1em }
23
+ td { border:1px solid #ccc; padding:0.1em 0.5em; font-size:85% }
24
+ pre, code, tt { color:#060 }
25
+
26
+ dt { font-weight:bold }
27
+
28
+ .indent1 { margin-left:2em }
29
+ .indent2 { margin-left:4em }
30
+ .indent3 { margin-left:6em }
31
+ .indent4 { margin-left:8em }
32
+ .indent5 { margin-left:10em }
33
+ .indent6 { margin-left:12em }
34
+ </style>
35
+ </head><body>
36
+ <h1 id="SimpleBullets">Simple Bullets:</h1>
37
+ <div class="section">
38
+ <ul>
39
+ <li>Bullet 1<ul>
40
+ <li>Bullet 1.1<ul>
41
+ <li>Bullet 1.1.1</li>
42
+ <li>Bullet 1.1.2</li>
43
+ </ul></li>
44
+ <li>Bullet 1.2<ul>
45
+ <li>Bullet 1.2.1</li>
46
+ </ul></li>
47
+ </ul></li>
48
+ <li>Bullet 2<ul>
49
+ <li>Bullet 2.1</li>
50
+ </ul></li>
51
+ </ul>
52
+ </div>
53
+ <h1 id="PathologicalBullets">Pathological Bullets:</h1>
54
+ <div class="section">
55
+ <ul>
56
+ <li>Bullet 1<ul>
57
+ <li>Bullet 1.1<ul>
58
+ <li>Bullet 1.1.1</li>
59
+ </ul></li>
60
+ </ul></li>
61
+ <li>Bullet 2<ul>
62
+ <li>Bullet 2.0.1</li>
63
+ <li>Bullet 2.1 <span class="todo">TODO - Handle this malformed case more elegantly?</span></li>
64
+ </ul></li>
65
+ </ul>
66
+ <ul>
67
+ <li>Bullet 0</li>
68
+ </ul>
69
+ </div>
70
+ <h1 id="MixedNumbers">Mixed Numbers:</h1>
71
+ <div class="section">
72
+ <ol>
73
+ <li>Number 1</li>
74
+ <li>Number 2</li>
75
+ <li>Number 3</li>
76
+ <li type="a">alpha 4</li>
77
+ <li type="a">alpha 5</li>
78
+ <li type="A">ALPHA 6</li>
79
+ <li type="A">ALPHA 7</li>
80
+ <li>Number 8</li>
81
+ <li type="i">roman 9</li>
82
+ <li type="i">roman 10<ol>
83
+ <li type="a">alpha 10.1</li>
84
+ <li type="a">alpha 10.2</li>
85
+ </ol></li>
86
+ <li type="I">ROMAN 11</li>
87
+ <li type="I">ROMAN 12</li>
88
+ </ol>
89
+ </div>
90
+ <h1 id="CrazyMixing">Crazy Mixing:</h1>
91
+ <div class="section">
92
+ <ul>
93
+ <li>Bullet 1</li>
94
+ <li>Bullet 2 <i>(shouldn't/can't be a number)</i><ol>
95
+ <li type="i">roman 2.1</li>
96
+ <li>Number 2.2<ol>
97
+ <li>Number 2.2.1</li>
98
+ </ol></li>
99
+ </ol></li>
100
+ </ul>
101
+ <pre>x. Nothing
102
+ # Re-Number 1
103
+
104
+ </pre>
105
+ <p><span class="todo">TODO - What should I do about the Nothing line? And why is Re-Number not jumping back into the game?</span></p>
106
+ </div>
107
+
108
+ </body></html>
@@ -0,0 +1,46 @@
1
+ = Simple Bullets: =
2
+ * Bullet 1
3
+ * Bullet 1.1
4
+ * Bullet 1.1.1
5
+ * Bullet 1.1.2
6
+ * Bullet 1.2
7
+ * Bullet 1.2.1
8
+ * Bullet 2
9
+ * Bullet 2.1
10
+
11
+ = Pathological Bullets: =
12
+ * Bullet 1
13
+ * Bullet 1.1
14
+ * Bullet 1.1.1
15
+ * Bullet 2
16
+ * Bullet 2.0.1
17
+ * Bullet 2.1 !!Handle this malformed case more elegantly?!!
18
+ * Bullet 0
19
+
20
+
21
+ = Mixed Numbers: =
22
+ # Number 1
23
+ 1. Number 2
24
+ 1. Number 3
25
+ a. alpha 4
26
+ a. alpha 5
27
+ A. ALPHA 6
28
+ A. ALPHA 7
29
+ 201. Number 8
30
+ i. roman 9
31
+ i. roman 10
32
+ a. alpha 10.1
33
+ a. alpha 10.2
34
+ I. ROMAN 11
35
+ I. ROMAN 12
36
+
37
+ = Crazy Mixing: =
38
+ * Bullet 1
39
+ # Bullet 2 //(shouldn't/can't be a number)//
40
+ i. roman 2.1
41
+ 1. Number 2.2
42
+ # Number 2.2.1
43
+ x. Nothing
44
+ # Re-Number 1
45
+
46
+ !!What should I do about the Nothing line? And why is Re-Number not jumping back into the game?!!
@@ -0,0 +1,125 @@
1
+ require "test/unit"
2
+ require "../lib/owlscribble"
3
+
4
+ class OWLScribble_Test < Test::Unit::TestCase
5
+ def setup
6
+ end
7
+
8
+ def test1_basic_paragraphs
9
+ unstyled_line = "Hello World!"
10
+ two_lines = "Hello\nWorld!"
11
+ two_para = [
12
+ "Hello World\n\nHow are you?!",
13
+ "Hello World\n\nHow are you?!\n",
14
+ "Hello World\n\nHow are you?!\n\n",
15
+ "Hello World\n\n\nHow are you?!",
16
+ "Hello World\n\n\n\nHow are you?!",
17
+ "\nHello World\n\n\nHow are you?!",
18
+ ]
19
+
20
+ owl = OWLScribble.new( unstyled_line )
21
+ assert_equal( 1, owl.tags.length )
22
+ assert_equal( :p, owl.tags.first.name )
23
+
24
+ owl = OWLScribble.new( two_lines )
25
+ assert_equal( 1, owl.tags.length )
26
+ assert_equal( :p, owl.tags.first.name )
27
+
28
+ two_para.each{ |input|
29
+ owl = OWLScribble.new( input )
30
+ assert_equal( 2, owl.tags.length )
31
+ owl.tags.each{ |tag|
32
+ assert_equal( :p, tag.name, "foo" )
33
+ }
34
+ }
35
+ end
36
+
37
+ def test2_inline_bold
38
+ input = "Hello **World**"
39
+ output = %r{<p>Hello <b>World</b></p>\s*}
40
+ owl = OWLScribble.new( input )
41
+ assert( output =~ owl.to_xml )
42
+
43
+ input = "The answer is **5 * 9**!"
44
+ output = %r{<p>The answer is <b>5 \* 9</b>!</p>\s*}
45
+ owl = OWLScribble.new( input )
46
+ assert( output =~ owl.to_xml )
47
+
48
+ input = "This is **bold1 with **bold2** illegally inside**."
49
+ output = %r{<p>This is <b>bold1 with </b>bold2<b> illegally inside</b>.</p>\s*}
50
+ owl = OWLScribble.new( input )
51
+ assert( output =~ owl.to_xml )
52
+ end
53
+
54
+ def test3_links
55
+ input = "GavinKistner is testing OWLScribble's WikiLinkCreation"
56
+ input<< " such as HandleXML or [[27 [FrEaK]s?!]] or [LinkMe Hot Stuff!] or HoundOfTheBaskerville or [[[Z!B]] so cool]"
57
+ input<< " and even [[[Myhomepage]] this wiki link]"
58
+ input<< " but not A2B or ~FooBar or ~[[This]]"
59
+ owl = OWLScribble.new( input )
60
+ assert_equal( 9, owl.wiki_links.length )
61
+ page_names = [ 'GavinKistner', 'OWLScribble', 'WikiLinkCreation', 'HandleXML', '27 [FrEaK]s?!', 'LinkMe', 'HoundOfTheBaskerville', 'Z!B', 'Myhomepage' ]
62
+ display_names = [ 'Gavin Kistner', 'OWL Scribble', 'Wiki Link Creation', 'Handle XML', '27 [FrEaK]s?!', 'Hot Stuff!', 'Hound of the Baskerville', 'so cool', 'this wiki link' ]
63
+ owl.wiki_links.each_with_index{ |tag,i|
64
+ assert_equal( page_names[ i ], tag.attributes[ :page ] )
65
+ assert_equal( display_names[ i ], tag.inner_text )
66
+ }
67
+ end
68
+
69
+ def test4_commands
70
+ input = "##Go##"
71
+ html = OWLScribble.new( input ).to_html
72
+ expected = %Q{<wiki_command do="Go">##Go##</wiki_command>\n}
73
+ assert_equal( expected, html )
74
+
75
+ input = "##Go(here)##"
76
+ html = OWLScribble.new( input ).to_html
77
+ expected1 = %Q{<wiki_command do="Go" params="here">##Go( here )##</wiki_command>\n}
78
+ expected2 = %Q{<wiki_command params="here" do="Go">##Go( here )##</wiki_command>\n}
79
+ assert( html==expected1 || html==expected2 )
80
+
81
+ input = "##Go( here)##"
82
+ html = OWLScribble.new( input ).to_html
83
+ assert( html==expected1 || html==expected2 )
84
+
85
+ input = "##Go(here )##"
86
+ html = OWLScribble.new( input ).to_html
87
+ assert( html==expected1 || html==expected2 )
88
+
89
+ input = "##Go( here )##"
90
+ html = OWLScribble.new( input ).to_html
91
+ assert( html==expected1 || html==expected2 )
92
+
93
+ input = "##Go(param1,param2)##"
94
+ html = OWLScribble.new( input ).to_html
95
+ expected1 = %Q{<wiki_command do="Go" params="param1,param2">##Go( param1, param2 )##</wiki_command>\n}
96
+ expected2 = %Q{<wiki_command params="param1,param2" do="Go">##Go( param1, param2 )##</wiki_command>\n}
97
+ assert( html==expected1 || html==expected2 )
98
+
99
+ input = "##Go( param1,param2)##"
100
+ html = OWLScribble.new( input ).to_html
101
+ assert( html==expected1 || html==expected2 )
102
+
103
+ input = "##Go(param1,param2 )##"
104
+ html = OWLScribble.new( input ).to_html
105
+ assert( html==expected1 || html==expected2 )
106
+
107
+ input = "##Go( param1,param2 )##"
108
+ html = OWLScribble.new( input ).to_html
109
+ assert( html==expected1 || html==expected2 )
110
+
111
+ input = "##Go( param1, param2 )##"
112
+ html = OWLScribble.new( input ).to_html
113
+ assert( html==expected1 || html==expected2 )
114
+ end
115
+
116
+ def test5_docs
117
+ input = "== Engineering ==\nHere's the home page from engineering:\n\n##Include(EngineeringHome)##\n##ShowCats( p1,p2, p3 )##"
118
+ owl = OWLScribble.new( input )
119
+ html = owl.to_html
120
+ expected1 = %Q{<h2 id="Engineering">Engineering</h2>\n<div class="section">\n<p>Here's the home page from engineering:</p>\n<wiki_command do="Include" params="EngineeringHome">##Include( EngineeringHome )##</wiki_command>\n<wiki_command do="ShowCats" params="p1,p2,p3">##ShowCats( p1, p2, p3 )##</wiki_command>\n</div>\n}
121
+ expected2 = %Q{<h2 id="Engineering">Engineering</h2>\n<div class="section">\n<p>Here's the home page from engineering:</p>\n<wiki_command params="EngineeringHome" do="Include">##Include( EngineeringHome )##</wiki_command>\n<wiki_command params="p1,p2,p3" do="ShowCats">##ShowCats( p1, p2, p3 )##</wiki_command>\n</div>\n}
122
+ assert( html==expected1 || html==expected2 )
123
+ end
124
+
125
+ end
@@ -0,0 +1,123 @@
1
+ <html><head><title>Welcome to the Jungle</title>
2
+ <style type="text/css">
3
+ body { margin:1em 2em; font-size:90%; font-family:'Trebuchet MS', serif; margin-bottom:30em }
4
+
5
+ a:link, a:visited { color:#009 }
6
+ a.newwikilink { color:#900 }
7
+
8
+ h1,h2,h3,h4,h5,h6 { margin-bottom:0.2em; margin-top:2em; border-bottom:1px solid #999; font-family:sans-serif }
9
+ h1 { font-size:120% }
10
+ h2 { font-size:110% }
11
+ h3,h4 { font-size:100% }
12
+ h5,h6 { font-size:90% }
13
+ h4,h5,h6 { font-style:italic }
14
+
15
+ ul, ol { margin:0; padding:0; margin-left:1.5em; margin-bottom:0.8em }
16
+ ul ol, ol ul, ul ul, ol ol { margin-left:1.5em }
17
+ li { margin-bottom:0 }
18
+ p { margin:0; margin-bottom:0.7em }
19
+ pre { background:#ffd; padding:0.5em; border:1px solid #993 }
20
+ .todo { font-weight:bold; color:#900 }
21
+ .section { margin-left:1em }
22
+ table { border-collapse:collapse; margin-bottom:1em }
23
+ td { border:1px solid #ccc; padding:0.1em 0.5em; font-size:85% }
24
+ pre, code, tt { color:#060 }
25
+
26
+ dt { font-weight:bold }
27
+
28
+ .indent1 { margin-left:2em }
29
+ .indent2 { margin-left:4em }
30
+ .indent3 { margin-left:6em }
31
+ .indent4 { margin-left:8em }
32
+ .indent5 { margin-left:10em }
33
+ .indent6 { margin-left:12em }
34
+ </style>
35
+ </head><body>
36
+ <p>Content before any header.</p>
37
+ <h1 id="TableofContents">Table of Contents</h1>
38
+ <div class="section">
39
+ <div class="toc"><ul><li><a href="#TableofContents">Table of Contents</a></li><li><a href="#Heading1">Heading 1</a><ul><li><a href="#Heading11">Heading 1.1</a><ul><li><a href="#Heading111">Heading 1.1.1</a></li><li><a href="#Heading112">Heading 1.1.2</a></li></ul></li><li><a href="#Heading12">Heading 1.2</a></li></ul></li><li><a href="#Heading2">Heading 2</a><ul><li><a href="#Heading21">Heading 2.1</a><ul><li><a href="#Heading2101">Heading 2.1.0.1</a></li><li><a href="#Heading211">Heading 2.1.1</a><ul><li><a href="#Heading2111">Heading 2.1.1.1</a></li></ul></li></ul></li></ul></li><li><a href="#Heading3">Heading 3</a></li><li><a href="#REPEAT">REPEAT</a><ul><li><a href="#TableofContents2">Table of Contents</a></li><li><a href="#Heading12">Heading 1</a><ul><li><a href="#Heading112">Heading 1.1</a><ul><li><a href="#Heading1112">Heading 1.1.1</a></li><li><a href="#Heading1122">Heading 1.1.2</a></li></ul></li><li><a href="#Heading122">Heading 1.2</a></li></ul></li><li><a href="#Heading22">Heading 2</a><ul><li><a href="#Heading212">Heading 2.1</a><ul><li><a href="#Heading21012">Heading 2.1.0.1</a></li><li><a href="#Heading2112">Heading 2.1.1</a><ul><li><a href="#Heading21112">Heading 2.1.1.1</a></li></ul></li></ul></li></ul></li><li><a href="#Heading32">Heading 3</a></li></ul></li></ul></div>
40
+ </div>
41
+ <h1 id="Heading1">Heading 1</h1>
42
+ <div class="section">
43
+ <p><i>Welcome to Heading 1</i></p>
44
+ <h2 id="Heading11">Heading 1.1</h2>
45
+ <div class="section">
46
+ <p>Heading 1.1 content</p>
47
+ <h3 id="Heading111">Heading 1.1.1</h3>
48
+ <div class="section">
49
+ <p>Heading 1.1.1 content</p>
50
+ <p>Heading 1.1.1 content continued</p>
51
+ </div>
52
+ <h3 id="Heading112">Heading 1.1.2</h3>
53
+ <div class="section">
54
+ <p>Heading 1.1.2</p>
55
+ </div>
56
+ </div>
57
+ <h2 id="Heading12">Heading 1.2</h2>
58
+ <div class="section">
59
+ <p>Heading 1.2 content</p>
60
+ </div>
61
+ </div>
62
+ <h1 id="Heading2">Heading 2</h1>
63
+ <div class="section">
64
+ <p><i>Heading 2 here</i></p>
65
+ <h2 id="Heading21">Heading 2.1</h2>
66
+ <div class="section">
67
+ <p>Heading 2.1 content</p>
68
+ <h4 id="Heading2101">Heading 2.1.0.1</h4>
69
+ <div class="section">
70
+ <p>Ooops, I went right from 2.1 to 2.1.0.1, skipping 2.1.1!</p>
71
+ </div>
72
+ <h3 id="Heading211">Heading 2.1.1</h3>
73
+ <div class="section">
74
+ <p>Heading 2.1.1 content should appear AFTER 2.1.0.1 because it came later in the source, despite the fact that it's malnested. But it should appear as a child of 2.1, not any higher.</p>
75
+ <h4 id="Heading2111">Heading 2.1.1.1</h4>
76
+ <div class="section">
77
+ <p>Heading 2.1.1.1 content should appear as a child of 2.1.1, not as a sibling of 2.1.0.1</p>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ <h1 id="Heading3">Heading 3</h1>
83
+ <div class="section">
84
+ <p>Jumping back to the main level with heading 3!</p>
85
+ </div>
86
+ <h1 id="REPEAT">REPEAT</h1>
87
+ <div class="section">
88
+ <p>The same hierarchy, minus the content</p>
89
+ <hr></hr>
90
+ <hr></hr>
91
+ <hr></hr>
92
+ <h2 id="TableofContents2">Table of Contents</h2>
93
+ <div class="section"></div>
94
+ <h2 id="Heading12">Heading 1</h2>
95
+ <div class="section">
96
+ <h3 id="Heading112">Heading 1.1</h3>
97
+ <div class="section">
98
+ <h4 id="Heading1112">Heading 1.1.1</h4>
99
+ <div class="section"></div>
100
+ <h4 id="Heading1122">Heading 1.1.2</h4>
101
+ <div class="section"></div>
102
+ </div>
103
+ <h3 id="Heading122">Heading 1.2</h3>
104
+ <div class="section"></div>
105
+ </div>
106
+ <h2 id="Heading22">Heading 2</h2>
107
+ <div class="section">
108
+ <h3 id="Heading212">Heading 2.1</h3>
109
+ <div class="section">
110
+ <h5 id="Heading21012">Heading 2.1.0.1</h5>
111
+ <div class="section"></div>
112
+ <h4 id="Heading2112">Heading 2.1.1</h4>
113
+ <div class="section">
114
+ <h5 id="Heading21112">Heading 2.1.1.1</h5>
115
+ <div class="section"></div>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <h2 id="Heading32">Heading 3</h2>
120
+ <div class="section"></div>
121
+ </div>
122
+
123
+ </body></html>
data/test/test_toc.owl ADDED
@@ -0,0 +1,59 @@
1
+ Content before any header.
2
+
3
+ = Table of Contents =
4
+ ##TableOfContents##
5
+
6
+ = Heading 1 =
7
+ //Welcome to Heading 1//
8
+
9
+ == Heading 1.1 ==
10
+ Heading 1.1 content
11
+
12
+ === Heading 1.1.1 ===
13
+ Heading 1.1.1 content
14
+
15
+ Heading 1.1.1 content continued
16
+
17
+ === Heading 1.1.2 ===
18
+ Heading 1.1.2
19
+
20
+ == Heading 1.2 ==
21
+ Heading 1.2 content
22
+
23
+ = Heading 2 =
24
+ //Heading 2 here//
25
+
26
+ == Heading 2.1 ==
27
+ Heading 2.1 content
28
+
29
+ ==== Heading 2.1.0.1 ====
30
+ Ooops, I went right from 2.1 to 2.1.0.1, skipping 2.1.1!
31
+
32
+ === Heading 2.1.1 ===
33
+ Heading 2.1.1 content should appear AFTER 2.1.0.1 because it came later in the source, despite the fact that it's malnested. But it should appear as a child of 2.1, not any higher.
34
+
35
+ ==== Heading 2.1.1.1 ====
36
+ Heading 2.1.1.1 content should appear as a child of 2.1.1, not as a sibling of 2.1.0.1
37
+
38
+ = Heading 3 =
39
+ Jumping back to the main level with heading 3!
40
+
41
+ = REPEAT =
42
+ The same hierarchy, minus the content
43
+
44
+ ----
45
+ ----
46
+ ----
47
+
48
+ == Table of Contents ==
49
+ == Heading 1 ==
50
+ === Heading 1.1 ===
51
+ ==== Heading 1.1.1 ====
52
+ ==== Heading 1.1.2 ====
53
+ === Heading 1.2 ===
54
+ == Heading 2 ==
55
+ === Heading 2.1 ===
56
+ ===== Heading 2.1.0.1 =====
57
+ ==== Heading 2.1.1 ====
58
+ ===== Heading 2.1.1.1 =====
59
+ == Heading 3 ==