hikidoc 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -46,3 +46,28 @@ project = Hoe.new('hikidoc', HikiDoc::VERSION) do |project|
46
46
  project.test_globs = ['test/test_*.rb']
47
47
  project.rdoc_pattern = /(?:^(?:lib|bin)|\AREADME\z)/
48
48
  end
49
+
50
+ desc 'Tag the repository for release.'
51
+ task :tag do
52
+ version = HikiDoc::VERSION
53
+ message = "Released HikiDoc #{version}!"
54
+ base = "svn+ssh://rubyforge.org/var/svn/hikidoc/"
55
+ sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
56
+ end
57
+
58
+ begin
59
+ require 'rcov/rcovtask'
60
+
61
+ desc "Analyze code coverage of the unit tests."
62
+ Rcov::RcovTask.new(:coverage) do |t|
63
+ t.test_files = FileList[project.test_globs]
64
+ t.verbose = true
65
+ t.rcov_opts << "--text-report"
66
+ begin
67
+ require "rubygems"
68
+ t.rcov_opts << "--exclude=^#{Regexp.escape(Gem.dir)}"
69
+ rescue LoadError
70
+ end
71
+ end
72
+ rescue LoadError
73
+ end
@@ -8,46 +8,59 @@ HTML_TEMPLATE = <<EOS
8
8
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
9
9
  <html>
10
10
  <head>
11
- <title><%=title%></title>
11
+ <title><%= title %></title>
12
12
  </head>
13
13
  <body>
14
- <%=body%>
14
+ <%= body %>
15
15
  </body>
16
16
  </html>
17
17
  EOS
18
18
 
19
- opt = {}
20
- ARGV.options do |o|
21
- o.banner = "Usage: #$0 [OPTIONS] FILE"
19
+ options = {}
20
+ format_options = {}
21
+ ARGV.options do |opts|
22
+ opts.banner = "Usage: #$0 [OPTIONS] FILE"
22
23
 
23
- # fragment mode
24
- o.on('--fragment', '-f',
24
+ opts.on('-f', '--fragment',
25
25
  'Output HTML fragments only') do
26
- opt[:fragment] = true
26
+ options[:fragment] = true
27
27
  end
28
- o.on('--template=VAL', '-t',
29
- 'Specify a HTML template file') do |v|
30
- opt[:template] = File.read(v)
28
+ opts.on('-t', '--template=TEMPLATE',
29
+ 'Specify a HTML template file') do |template|
30
+ options[:template] = template
31
+ end
32
+ opts.on('--no-wikiname', 'Disable WikiName link') do
33
+ format_options[:use_wiki_name] = false
31
34
  end
32
35
 
33
- o.parse!
36
+ opts.parse!
34
37
  end
35
38
 
36
- opt[:template] ||= HTML_TEMPLATE
37
-
38
39
  case ARGV.size
39
40
  when 0
40
- title, txt = '-', $stdin.read
41
+ title, text = '-', $stdin.read
41
42
  when 1
42
- title, txt = ARGV[0], File.read(ARGV[0])
43
+ title, text = ARGV[0], File.read(ARGV[0])
43
44
  else
44
45
  usage
45
46
  end
46
47
 
47
- body = HikiDoc.to_html(txt)
48
+ body = HikiDoc.to_html(text, format_options)
48
49
 
49
- if opt[:fragment]
50
- puts body
50
+ def result(erb, title, body, text)
51
+ erb.result(binding)
52
+ end
53
+
54
+ if options[:fragment]
55
+ puts(body)
51
56
  else
52
- puts ERB.new(opt[:template]).result(binding)
57
+ template = options[:template]
58
+ if template
59
+ source = File.read(template)
60
+ else
61
+ source = HTML_TEMPLATE
62
+ end
63
+ erb = ERB.new(source)
64
+ erb.filename = template
65
+ puts(result(erb, title, body, text))
53
66
  end
@@ -0,0 +1,100 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>
5
+ C0 code coverage information
6
+ </title>
7
+ <style type='text/css'>
8
+ body { background-color: rgb(240, 240, 245); }
9
+ </style>
10
+ <style type='text/css'>
11
+ span.cross-ref-title { font-size: 140%; } span.cross-ref a {
12
+ text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
13
+ border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
14
+ a.crossref-toggle { text-decoration: none; } span.marked0 {
15
+ background-color: rgb(185, 210, 200); display: block; } span.marked1 {
16
+ background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
17
+ background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
18
+ background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
19
+ background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
20
+ background-color: rgb(235, 120, 120); display: block; } span.overview {
21
+ border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
22
+ black; } body { font-family: verdana, arial, helvetica; } div.footer {
23
+ font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
24
+ margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
25
+ } div.separator { height: 10px; } /* Commented out for better readability,
26
+ esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
27
+ table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
28
+ border: #808080 1px solid; empty-cells: show; } table.percent_graph
29
+ td.covered { height: 10px; background: #00f000; } table.percent_graph
30
+ td.uncovered { height: 10px; background: #e00000; } table.percent_graph
31
+ td.NA { height: 10px; background: #eaeaea; } table.report {
32
+ border-collapse: collapse; width: 100%; } table.report td.heading {
33
+ background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
34
+ text-align: center; } table.report td.heading:hover { background: #c0ffc0;
35
+ } table.report td.text { border: #d0d0d0 1px solid; } table.report
36
+ td.value, table.report td.lines_total, table.report td.lines_code {
37
+ text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
38
+ background-color: rgb(240, 240, 245); } table.report tr.dark {
39
+ background-color: rgb(230, 230, 235); }
40
+ </style>
41
+ <script type='text/javascript'>
42
+ // <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
43
+ elem = document.getElementById( id ); else if ( document.all ) elem =
44
+ eval( "document.all." + id ); else return false; elemStyle = elem.style;
45
+ if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
46
+ elemStyle.display = "none" } return true; } // Make cross-references
47
+ hidden by default document.writeln( "<style
48
+ type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
49
+ </script>
50
+ </head>
51
+ <body>
52
+ <h3>
53
+ C0 code coverage information
54
+ </h3>
55
+ <p>
56
+ Generated on Tue Aug 12 00:32:09 +0900 2008 with
57
+ <a href='http://eigenclass.org/hiki/rcov'>
58
+ rcov 0.8.1.2
59
+ </a>
60
+ </p>
61
+ <hr />
62
+ <table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
63
+ class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
64
+ <td class='heading'> Total coverage </td> <td class='heading'> Code coverage
65
+ </td> </tr> </thead> <tbody> <tr class='light'> <td> TOTAL </td> <td
66
+ class='lines_total'> <tt> 902 </tt> </td> <td class='lines_code'> <tt> 721
67
+ </tt> </td> <td> <table cellspacing='0' align='right' cellpadding='0'> <tr>
68
+ <td> <tt class='coverage_total'> 90.2% </tt> &nbsp; </td> <td> <table
69
+ class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
70
+ class='covered' width='90' /> <td class='uncovered' width='10' /> </tr>
71
+ </table> </td> </tr> </table> </td> <td> <table cellspacing='0'
72
+ align='right' cellpadding='0'> <tr> <td> <tt class='coverage_code'> 87.8%
73
+ </tt> &nbsp; </td> <td> <table class='percent_graph' cellspacing='0'
74
+ width='100' cellpadding='0'> <tr> <td class='covered' width='88' /> <td
75
+ class='uncovered' width='12' /> </tr> </table> </td> </tr> </table> </td>
76
+ </tr> <tr class='dark'> <td> <a href='lib-hikidoc_rb.html'> lib/hikidoc.rb
77
+ </a> </td> <td class='lines_total'> <tt> 902 </tt> </td> <td
78
+ class='lines_code'> <tt> 721 </tt> </td> <td> <table cellspacing='0'
79
+ align='right' cellpadding='0'> <tr> <td> <tt class='coverage_total'> 90.2%
80
+ </tt> &nbsp; </td> <td> <table class='percent_graph' cellspacing='0'
81
+ width='100' cellpadding='0'> <tr> <td class='covered' width='90' /> <td
82
+ class='uncovered' width='10' /> </tr> </table> </td> </tr> </table> </td>
83
+ <td> <table cellspacing='0' align='right' cellpadding='0'> <tr> <td> <tt
84
+ class='coverage_code'> 87.8% </tt> &nbsp; </td> <td> <table
85
+ class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
86
+ class='covered' width='88' /> <td class='uncovered' width='12' /> </tr>
87
+ </table> </td> </tr> </table> </td> </tr> </tbody> </table>
88
+ <hr />
89
+ <p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
90
+ code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
91
+ <p>
92
+ <a href='http://validator.w3.org/check/referer'>
93
+ <img src='http://www.w3.org/Icons/valid-xhtml11' height='31' alt='Valid XHTML 1.1!' width='88' />
94
+ </a>
95
+ <a href='http://jigsaw.w3.org/css-validator/check/referer'>
96
+ <img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
97
+ </a>
98
+ </p>
99
+ </body>
100
+ </html>
@@ -0,0 +1,1195 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>
5
+ lib/hikidoc.rb - C0 code coverage information
6
+ </title>
7
+ <style type='text/css'>
8
+ body { background-color: rgb(240, 240, 245); }
9
+ </style>
10
+ <style type='text/css'>
11
+ span.cross-ref-title { font-size: 140%; } span.cross-ref a {
12
+ text-decoration: none; } span.cross-ref { background-color:#f3f7fa;
13
+ border: 1px dashed #333; margin: 1em; padding: 0.5em; overflow: hidden; }
14
+ a.crossref-toggle { text-decoration: none; } span.marked0 {
15
+ background-color: rgb(185, 210, 200); display: block; } span.marked1 {
16
+ background-color: rgb(190, 215, 205); display: block; } span.inferred0 {
17
+ background-color: rgb(175, 200, 200); display: block; } span.inferred1 {
18
+ background-color: rgb(180, 205, 205); display: block; } span.uncovered0 {
19
+ background-color: rgb(225, 110, 110); display: block; } span.uncovered1 {
20
+ background-color: rgb(235, 120, 120); display: block; } span.overview {
21
+ border-bottom: 8px solid black; } div.overview { border-bottom: 8px solid
22
+ black; } body { font-family: verdana, arial, helvetica; } div.footer {
23
+ font-size: 68%; margin-top: 1.5em; } h1, h2, h3, h4, h5, h6 {
24
+ margin-bottom: 0.5em; } h5 { margin-top: 0.5em; } .hidden { display: none;
25
+ } div.separator { height: 10px; } /* Commented out for better readability,
26
+ esp. on IE */ /* table tr td, table tr th { font-size: 68%; } td.value
27
+ table tr td { font-size: 11px; } */ table.percent_graph { height: 12px;
28
+ border: #808080 1px solid; empty-cells: show; } table.percent_graph
29
+ td.covered { height: 10px; background: #00f000; } table.percent_graph
30
+ td.uncovered { height: 10px; background: #e00000; } table.percent_graph
31
+ td.NA { height: 10px; background: #eaeaea; } table.report {
32
+ border-collapse: collapse; width: 100%; } table.report td.heading {
33
+ background: #dcecff; border: #d0d0d0 1px solid; font-weight: bold;
34
+ text-align: center; } table.report td.heading:hover { background: #c0ffc0;
35
+ } table.report td.text { border: #d0d0d0 1px solid; } table.report
36
+ td.value, table.report td.lines_total, table.report td.lines_code {
37
+ text-align: right; border: #d0d0d0 1px solid; } table.report tr.light {
38
+ background-color: rgb(240, 240, 245); } table.report tr.dark {
39
+ background-color: rgb(230, 230, 235); }
40
+ </style>
41
+ <script type='text/javascript'>
42
+ // <![CDATA[ function toggleCode( id ) { if ( document.getElementById )
43
+ elem = document.getElementById( id ); else if ( document.all ) elem =
44
+ eval( "document.all." + id ); else return false; elemStyle = elem.style;
45
+ if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else {
46
+ elemStyle.display = "none" } return true; } // Make cross-references
47
+ hidden by default document.writeln( "<style
48
+ type=\"text/css\">span.cross-ref { display: none }</style>" ) // ]]>
49
+ </script>
50
+ <style type='text/css'>
51
+ span.run0 { background-color: rgb(178, 204, 255); display: block; }
52
+ span.run1 { background-color: rgb(178, 206, 255); display: block; }
53
+ span.run2 { background-color: rgb(178, 209, 255); display: block; }
54
+ span.run3 { background-color: rgb(178, 211, 255); display: block; }
55
+ span.run4 { background-color: rgb(178, 214, 255); display: block; }
56
+ span.run5 { background-color: rgb(178, 218, 255); display: block; }
57
+ span.run6 { background-color: rgb(178, 220, 255); display: block; }
58
+ span.run7 { background-color: rgb(178, 223, 255); display: block; }
59
+ span.run8 { background-color: rgb(178, 225, 255); display: block; }
60
+ span.run9 { background-color: rgb(178, 228, 255); display: block; }
61
+ span.run10 { background-color: rgb(178, 232, 255); display: block; }
62
+ span.run11 { background-color: rgb(178, 234, 255); display: block; }
63
+ span.run12 { background-color: rgb(178, 237, 255); display: block; }
64
+ span.run13 { background-color: rgb(178, 239, 255); display: block; }
65
+ span.run14 { background-color: rgb(178, 242, 255); display: block; }
66
+ span.run15 { background-color: rgb(178, 246, 255); display: block; }
67
+ span.run16 { background-color: rgb(178, 248, 255); display: block; }
68
+ span.run17 { background-color: rgb(178, 251, 255); display: block; }
69
+ span.run18 { background-color: rgb(178, 253, 255); display: block; }
70
+ span.run19 { background-color: rgb(178, 255, 253); display: block; }
71
+ span.run20 { background-color: rgb(178, 255, 249); display: block; }
72
+ span.run21 { background-color: rgb(178, 255, 247); display: block; }
73
+ span.run22 { background-color: rgb(178, 255, 244); display: block; }
74
+ span.run23 { background-color: rgb(178, 255, 242); display: block; }
75
+ span.run24 { background-color: rgb(178, 255, 239); display: block; }
76
+ span.run25 { background-color: rgb(178, 255, 235); display: block; }
77
+ span.run26 { background-color: rgb(178, 255, 233); display: block; }
78
+ span.run27 { background-color: rgb(178, 255, 230); display: block; }
79
+ span.run28 { background-color: rgb(178, 255, 228); display: block; }
80
+ span.run29 { background-color: rgb(178, 255, 225); display: block; }
81
+ span.run30 { background-color: rgb(178, 255, 221); display: block; }
82
+ span.run31 { background-color: rgb(178, 255, 219); display: block; }
83
+ span.run32 { background-color: rgb(178, 255, 216); display: block; }
84
+ span.run33 { background-color: rgb(178, 255, 214); display: block; }
85
+ span.run34 { background-color: rgb(178, 255, 211); display: block; }
86
+ span.run35 { background-color: rgb(178, 255, 207); display: block; }
87
+ span.run36 { background-color: rgb(178, 255, 205); display: block; }
88
+ span.run37 { background-color: rgb(178, 255, 202); display: block; }
89
+ span.run38 { background-color: rgb(178, 255, 200); display: block; }
90
+ span.run39 { background-color: rgb(178, 255, 197); display: block; }
91
+ span.run40 { background-color: rgb(178, 255, 193); display: block; }
92
+ span.run41 { background-color: rgb(178, 255, 191); display: block; }
93
+ span.run42 { background-color: rgb(178, 255, 188); display: block; }
94
+ span.run43 { background-color: rgb(178, 255, 186); display: block; }
95
+ span.run44 { background-color: rgb(178, 255, 183); display: block; }
96
+ span.run45 { background-color: rgb(178, 255, 179); display: block; }
97
+ span.run46 { background-color: rgb(179, 255, 178); display: block; }
98
+ span.run47 { background-color: rgb(182, 255, 178); display: block; }
99
+ span.run48 { background-color: rgb(184, 255, 178); display: block; }
100
+ span.run49 { background-color: rgb(187, 255, 178); display: block; }
101
+ span.run50 { background-color: rgb(191, 255, 178); display: block; }
102
+ span.run51 { background-color: rgb(193, 255, 178); display: block; }
103
+ span.run52 { background-color: rgb(196, 255, 178); display: block; }
104
+ span.run53 { background-color: rgb(198, 255, 178); display: block; }
105
+ span.run54 { background-color: rgb(201, 255, 178); display: block; }
106
+ span.run55 { background-color: rgb(205, 255, 178); display: block; }
107
+ span.run56 { background-color: rgb(207, 255, 178); display: block; }
108
+ span.run57 { background-color: rgb(210, 255, 178); display: block; }
109
+ span.run58 { background-color: rgb(212, 255, 178); display: block; }
110
+ span.run59 { background-color: rgb(215, 255, 178); display: block; }
111
+ span.run60 { background-color: rgb(219, 255, 178); display: block; }
112
+ span.run61 { background-color: rgb(221, 255, 178); display: block; }
113
+ span.run62 { background-color: rgb(224, 255, 178); display: block; }
114
+ span.run63 { background-color: rgb(226, 255, 178); display: block; }
115
+ span.run64 { background-color: rgb(229, 255, 178); display: block; }
116
+ span.run65 { background-color: rgb(233, 255, 178); display: block; }
117
+ span.run66 { background-color: rgb(235, 255, 178); display: block; }
118
+ span.run67 { background-color: rgb(238, 255, 178); display: block; }
119
+ span.run68 { background-color: rgb(240, 255, 178); display: block; }
120
+ span.run69 { background-color: rgb(243, 255, 178); display: block; }
121
+ span.run70 { background-color: rgb(247, 255, 178); display: block; }
122
+ span.run71 { background-color: rgb(249, 255, 178); display: block; }
123
+ span.run72 { background-color: rgb(252, 255, 178); display: block; }
124
+ span.run73 { background-color: rgb(255, 255, 178); display: block; }
125
+ span.run74 { background-color: rgb(255, 252, 178); display: block; }
126
+ span.run75 { background-color: rgb(255, 248, 178); display: block; }
127
+ span.run76 { background-color: rgb(255, 246, 178); display: block; }
128
+ span.run77 { background-color: rgb(255, 243, 178); display: block; }
129
+ span.run78 { background-color: rgb(255, 240, 178); display: block; }
130
+ span.run79 { background-color: rgb(255, 238, 178); display: block; }
131
+ span.run80 { background-color: rgb(255, 234, 178); display: block; }
132
+ span.run81 { background-color: rgb(255, 232, 178); display: block; }
133
+ span.run82 { background-color: rgb(255, 229, 178); display: block; }
134
+ span.run83 { background-color: rgb(255, 226, 178); display: block; }
135
+ span.run84 { background-color: rgb(255, 224, 178); display: block; }
136
+ span.run85 { background-color: rgb(255, 220, 178); display: block; }
137
+ span.run86 { background-color: rgb(255, 218, 178); display: block; }
138
+ span.run87 { background-color: rgb(255, 215, 178); display: block; }
139
+ span.run88 { background-color: rgb(255, 212, 178); display: block; }
140
+ span.run89 { background-color: rgb(255, 210, 178); display: block; }
141
+ span.run90 { background-color: rgb(255, 206, 178); display: block; }
142
+ span.run91 { background-color: rgb(255, 204, 178); display: block; }
143
+ span.run92 { background-color: rgb(255, 201, 178); display: block; }
144
+ span.run93 { background-color: rgb(255, 198, 178); display: block; }
145
+ span.run94 { background-color: rgb(255, 196, 178); display: block; }
146
+ span.run95 { background-color: rgb(255, 192, 178); display: block; }
147
+ span.run96 { background-color: rgb(255, 189, 178); display: block; }
148
+ span.run97 { background-color: rgb(255, 187, 178); display: block; }
149
+ span.run98 { background-color: rgb(255, 184, 178); display: block; }
150
+ span.run99 { background-color: rgb(255, 182, 178); display: block; }
151
+ span.run100 { background-color: rgb(255, 178, 178); display: block; }
152
+ </style>
153
+ </head>
154
+ <body>
155
+ <h3>
156
+ C0 code coverage information
157
+ </h3>
158
+ <p>
159
+ Generated on Tue Aug 12 00:32:09 +0900 2008 with
160
+ <a href='http://eigenclass.org/hiki/rcov'>
161
+ rcov 0.8.1.2
162
+ </a>
163
+ </p>
164
+ <hr />
165
+ <pre><span class='marked0'>Code reported as executed by Ruby looks like
166
+ this... </span><span class='marked1'>and this: this line is also marked as
167
+ covered. </span><span class='inferred0'>Lines considered as run by rcov, but
168
+ not reported by Ruby, look like this, </span><span class='inferred1'>and
169
+ this: these lines were inferred by rcov (using simple heuristics).
170
+ </span><span class='uncovered0'>Finally, here&apos;s a line marked as not
171
+ executed. </span></pre>
172
+ <table class='report'> <thead> <tr> <td class='heading'> Name </td> <td
173
+ class='heading'> Total lines </td> <td class='heading'> Lines of code </td>
174
+ <td class='heading'> Total coverage </td> <td class='heading'> Code coverage
175
+ </td> </tr> </thead> <tbody> <tr class='light'> <td> <a
176
+ href='lib-hikidoc_rb.html'> lib/hikidoc.rb </a> </td> <td
177
+ class='lines_total'> <tt> 902 </tt> </td> <td class='lines_code'> <tt> 721
178
+ </tt> </td> <td> <table cellspacing='0' align='right' cellpadding='0'> <tr>
179
+ <td> <tt class='coverage_total'> 90.2% </tt> &nbsp; </td> <td> <table
180
+ class='percent_graph' cellspacing='0' width='100' cellpadding='0'> <tr> <td
181
+ class='covered' width='90' /> <td class='uncovered' width='10' /> </tr>
182
+ </table> </td> </tr> </table> </td> <td> <table cellspacing='0'
183
+ align='right' cellpadding='0'> <tr> <td> <tt class='coverage_code'> 87.8%
184
+ </tt> &nbsp; </td> <td> <table class='percent_graph' cellspacing='0'
185
+ width='100' cellpadding='0'> <tr> <td class='covered' width='88' /> <td
186
+ class='uncovered' width='12' /> </tr> </table> </td> </tr> </table> </td>
187
+ </tr> </tbody> </table><pre><span class="inferred1"><a name="line1"></a> 1 #
188
+ Copyright (c) 2005, Kazuhiko &lt;kazuhiko@fdiary.net&gt; </span><span
189
+ class="inferred0"><a name="line2"></a> 2 # Copyright (c) 2007 Minero Aoki
190
+ </span><span class="inferred1"><a name="line3"></a> 3 # All rights reserved.
191
+ </span><span class="inferred0"><a name="line4"></a> 4 # </span><span
192
+ class="inferred1"><a name="line5"></a> 5 # Redistribution and use in source
193
+ and binary forms, with or without </span><span class="inferred0"><a
194
+ name="line6"></a> 6 # modification, are permitted provided that the
195
+ following conditions are </span><span class="inferred1"><a name="line7"></a>
196
+ 7 # met: </span><span class="inferred0"><a name="line8"></a> 8 #
197
+ </span><span class="inferred1"><a name="line9"></a> 9 # * Redistributions of
198
+ source code must retain the above copyright </span><span
199
+ class="inferred0"><a name="line10"></a> 10 # notice, this list of conditions
200
+ and the following disclaimer. </span><span class="inferred1"><a
201
+ name="line11"></a> 11 # * Redistributions in binary form must reproduce the
202
+ above </span><span class="inferred0"><a name="line12"></a> 12 # copyright
203
+ notice, this list of conditions and the following </span><span
204
+ class="inferred1"><a name="line13"></a> 13 # disclaimer in the documentation
205
+ and/or other materials provided </span><span class="inferred0"><a
206
+ name="line14"></a> 14 # with the distribution. </span><span
207
+ class="inferred1"><a name="line15"></a> 15 # * Neither the name of the
208
+ HikiDoc nor the names of its </span><span class="inferred0"><a
209
+ name="line16"></a> 16 # contributors may be used to endorse or promote
210
+ products derived </span><span class="inferred1"><a name="line17"></a> 17 #
211
+ from this software without specific prior written permission. </span><span
212
+ class="inferred0"><a name="line18"></a> 18 # </span><span
213
+ class="inferred1"><a name="line19"></a> 19 # THIS SOFTWARE IS PROVIDED BY
214
+ THE COPYRIGHT HOLDERS AND CONTRIBUTORS </span><span class="inferred0"><a
215
+ name="line20"></a> 20 # &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED
216
+ WARRANTIES, INCLUDING, BUT NOT </span><span class="inferred1"><a
217
+ name="line21"></a> 21 # LIMITED TO, THE IMPLIED WARRANTIES OF
218
+ MERCHANTABILITY AND FITNESS FOR </span><span class="inferred0"><a
219
+ name="line22"></a> 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
220
+ SHALL THE COPYRIGHT </span><span class="inferred1"><a name="line23"></a> 23
221
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222
+ </span><span class="inferred0"><a name="line24"></a> 24 # SPECIAL,
223
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT </span><span
224
+ class="inferred1"><a name="line25"></a> 25 # LIMITED TO, PROCUREMENT OF
225
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, </span><span class="inferred0"><a
226
+ name="line26"></a> 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
227
+ CAUSED AND ON ANY </span><span class="inferred1"><a name="line27"></a> 27 #
228
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
229
+ </span><span class="inferred0"><a name="line28"></a> 28 # (INCLUDING
230
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </span><span
231
+ class="inferred1"><a name="line29"></a> 29 # OF THIS SOFTWARE, EVEN IF
232
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. </span><span class="inferred0"><a
233
+ name="line30"></a> 30 </span><span class="marked1"><a name="line31"></a> 31
234
+ require &quot;stringio&quot; </span><span class="marked0"><a
235
+ name="line32"></a> 32 require &quot;strscan&quot; </span><span
236
+ class="marked1"><a name="line33"></a> 33 require &quot;uri&quot;
237
+ </span><span class="marked0"><a name="line34"></a> 34 begin </span><span
238
+ class="marked1"><a name="line35"></a> 35 require
239
+ &quot;syntax/convertors/html&quot; </span><span class="uncovered0"><a
240
+ name="line36"></a> 36 rescue LoadError </span><span class="uncovered1"><a
241
+ name="line37"></a> 37 end </span><span class="inferred0"><a
242
+ name="line38"></a> 38 </span><span class="marked1"><a name="line39"></a> 39
243
+ class HikiDoc </span><span class="marked0"><a name="line40"></a> 40 VERSION
244
+ = &quot;0.0.2&quot; # FIXME </span><span class="inferred1"><a
245
+ name="line41"></a> 41 </span><span class="marked0"><a name="line42"></a> 42
246
+ class Error &lt; StandardError </span><span class="inferred1"><a
247
+ name="line43"></a> 43 end </span><span class="inferred0"><a
248
+ name="line44"></a> 44 </span><span class="marked1"><a name="line45"></a> 45
249
+ class UnexpectedError &lt; Error </span><span class="inferred0"><a
250
+ name="line46"></a> 46 end </span><span class="inferred1"><a
251
+ name="line47"></a> 47 </span><span class="marked0"><a name="line48"></a> 48
252
+ def HikiDoc.to_html(src, options = {}) </span><span class="uncovered1"><a
253
+ name="line49"></a> 49 new(HTMLOutput.new(&quot;&gt;&quot;),
254
+ options).compile(src) </span><span class="uncovered0"><a name="line50"></a>
255
+ 50 end </span><span class="inferred1"><a name="line51"></a> 51 </span><span
256
+ class="marked0"><a name="line52"></a> 52 def HikiDoc.to_xhtml(src, options =
257
+ {}) </span><span class="marked1"><a name="line53"></a> 53
258
+ new(HTMLOutput.new(&quot; /&gt;&quot;), options).compile(src) </span><span
259
+ class="inferred0"><a name="line54"></a> 54 end </span><span
260
+ class="inferred1"><a name="line55"></a> 55 </span><span class="marked0"><a
261
+ name="line56"></a> 56 def initialize(output, options = {}) </span><span
262
+ class="marked1"><a name="line57"></a> 57 @output = output </span><span
263
+ class="marked0"><a name="line58"></a> 58 @options =
264
+ default_options.merge(options) </span><span class="marked1"><a
265
+ name="line59"></a> 59 @header_re = nil </span><span class="marked0"><a
266
+ name="line60"></a> 60 @level = options[:level] || 1 </span><span
267
+ class="marked1"><a name="line61"></a> 61 @plugin_syntax =
268
+ options[:plugin_syntax] || method(:valid_plugin_syntax?) </span><span
269
+ class="inferred0"><a name="line62"></a> 62 end </span><span
270
+ class="inferred1"><a name="line63"></a> 63 </span><span class="marked0"><a
271
+ name="line64"></a> 64 def compile(src) </span><span class="marked1"><a
272
+ name="line65"></a> 65 @output.reset </span><span class="marked0"><a
273
+ name="line66"></a> 66 escape_plugin_blocks(src) {|escaped| </span><span
274
+ class="marked1"><a name="line67"></a> 67 compile_blocks escaped </span><span
275
+ class="marked0"><a name="line68"></a> 68 @output.finish </span><span
276
+ class="inferred1"><a name="line69"></a> 69 } </span><span
277
+ class="inferred0"><a name="line70"></a> 70 end </span><span
278
+ class="inferred1"><a name="line71"></a> 71 </span><span class="inferred0"><a
279
+ name="line72"></a> 72 # for backward compatibility </span><span
280
+ class="marked1"><a name="line73"></a> 73 def to_html </span><span
281
+ class="uncovered0"><a name="line74"></a> 74 $stderr.puts(&quot;warning:
282
+ HikiDoc#to_html is deprecated. Please use HikiDoc.to_html or
283
+ HikiDoc.to_xhtml instead.&quot;) </span><span class="uncovered1"><a
284
+ name="line75"></a> 75 self.class.to_html(@output, @options) </span><span
285
+ class="uncovered0"><a name="line76"></a> 76 end </span><span
286
+ class="inferred1"><a name="line77"></a> 77 </span><span class="marked0"><a
287
+ name="line78"></a> 78 private </span><span class="inferred1"><a
288
+ name="line79"></a> 79 </span><span class="marked0"><a name="line80"></a> 80
289
+ def default_options </span><span class="inferred1"><a name="line81"></a> 81
290
+ { </span><span class="inferred0"><a name="line82"></a> 82
291
+ :allow_bracket_inline_image =&gt; true, </span><span class="inferred1"><a
292
+ name="line83"></a> 83 :use_wiki_name =&gt; true, </span><span
293
+ class="marked0"><a name="line84"></a> 84 :use_not_wiki_name =&gt; true,
294
+ </span><span class="marked1"><a name="line85"></a> 85 } </span><span
295
+ class="inferred0"><a name="line86"></a> 86 end </span><span
296
+ class="inferred1"><a name="line87"></a> 87 </span><span class="inferred0"><a
297
+ name="line88"></a> 88 # </span><span class="inferred1"><a name="line89"></a>
298
+ 89 # Plugin </span><span class="inferred0"><a name="line90"></a> 90 #
299
+ </span><span class="inferred1"><a name="line91"></a> 91 </span><span
300
+ class="marked0"><a name="line92"></a> 92 def valid_plugin_syntax?(code)
301
+ </span><span class="marked1"><a name="line93"></a> 93 /['&quot;]/ !~
302
+ code.gsub(/'(?:[^\\']+|\\.)*'|&quot;(?:[^\\&quot;]+|\\.)*&quot;/m,
303
+ &quot;&quot;) </span><span class="inferred0"><a name="line94"></a> 94 end
304
+ </span><span class="inferred1"><a name="line95"></a> 95 </span><span
305
+ class="marked0"><a name="line96"></a> 96 def escape_plugin_blocks(text)
306
+ </span><span class="marked1"><a name="line97"></a> 97 s =
307
+ StringScanner.new(text) </span><span class="marked0"><a name="line98"></a>
308
+ 98 buf = &quot;&quot; </span><span class="marked1"><a name="line99"></a> 99
309
+ @plugin_blocks = [] </span><span class="marked0"><a name="line100"></a>100
310
+ while chunk = s.scan_until(/\{\{/) </span><span class="marked1"><a
311
+ name="line101"></a>101 tail = chunk[-2, 2] </span><span class="marked0"><a
312
+ name="line102"></a>102 chunk[-2, 2] = &quot;&quot; </span><span
313
+ class="marked1"><a name="line103"></a>103 buf &lt;&lt; chunk </span><span
314
+ class="inferred0"><a name="line104"></a>104 # plugin </span><span
315
+ class="marked1"><a name="line105"></a>105 if block = extract_plugin_block(s)
316
+ </span><span class="marked0"><a name="line106"></a>106 @plugin_blocks.push
317
+ block </span><span class="marked1"><a name="line107"></a>107 buf &lt;&lt;
318
+ &quot;\0#{@plugin_blocks.size - 1}\0&quot; </span><span class="inferred0"><a
319
+ name="line108"></a>108 else </span><span class="marked1"><a
320
+ name="line109"></a>109 buf &lt;&lt; &quot;{{&quot; </span><span
321
+ class="inferred0"><a name="line110"></a>110 end </span><span
322
+ class="inferred1"><a name="line111"></a>111 end </span><span
323
+ class="marked0"><a name="line112"></a>112 buf &lt;&lt; s.rest </span><span
324
+ class="marked1"><a name="line113"></a>113 yield(buf) </span><span
325
+ class="inferred0"><a name="line114"></a>114 end </span><span
326
+ class="inferred1"><a name="line115"></a>115 </span><span class="marked0"><a
327
+ name="line116"></a>116 def restore_plugin_block(str) </span><span
328
+ class="marked1"><a name="line117"></a>117 str.gsub(/\0(\d+)\0/) {
329
+ </span><span class="marked0"><a name="line118"></a>118 &quot;{{&quot; +
330
+ plugin_block($1.to_i) + &quot;}}&quot; </span><span class="inferred1"><a
331
+ name="line119"></a>119 } </span><span class="inferred0"><a
332
+ name="line120"></a>120 end </span><span class="inferred1"><a
333
+ name="line121"></a>121 </span><span class="marked0"><a
334
+ name="line122"></a>122 def evaluate_plugin_block(str, buf = nil)
335
+ </span><span class="marked1"><a name="line123"></a>123 buf ||=
336
+ @output.container </span><span class="marked0"><a name="line124"></a>124
337
+ str.split(/(\0\d+\0)/).each do |s| </span><span class="marked1"><a
338
+ name="line125"></a>125 if s[0, 1] == &quot;\0&quot; and s[-1, 1] ==
339
+ &quot;\0&quot; </span><span class="marked0"><a name="line126"></a>126 buf
340
+ &lt;&lt; @output.inline_plugin(plugin_block(s[1..-2].to_i)) </span><span
341
+ class="inferred1"><a name="line127"></a>127 else </span><span
342
+ class="marked0"><a name="line128"></a>128 buf &lt;&lt; @output.text(s)
343
+ </span><span class="inferred1"><a name="line129"></a>129 end </span><span
344
+ class="inferred0"><a name="line130"></a>130 end </span><span
345
+ class="marked1"><a name="line131"></a>131 buf </span><span
346
+ class="inferred0"><a name="line132"></a>132 end </span><span
347
+ class="inferred1"><a name="line133"></a>133 </span><span class="marked0"><a
348
+ name="line134"></a>134 def plugin_block(id) </span><span class="marked1"><a
349
+ name="line135"></a>135 @plugin_blocks[id] or raise UnexpectedError,
350
+ &quot;must not happen: #{id.inspect}&quot; </span><span class="inferred0"><a
351
+ name="line136"></a>136 end </span><span class="inferred1"><a
352
+ name="line137"></a>137 </span><span class="marked0"><a
353
+ name="line138"></a>138 def extract_plugin_block(s) </span><span
354
+ class="marked1"><a name="line139"></a>139 pos = s.pos </span><span
355
+ class="marked0"><a name="line140"></a>140 buf = &quot;&quot; </span><span
356
+ class="marked1"><a name="line141"></a>141 while chunk = s.scan_until(/\}\}/)
357
+ </span><span class="marked0"><a name="line142"></a>142 buf &lt;&lt; chunk
358
+ </span><span class="marked1"><a name="line143"></a>143
359
+ buf.chomp!(&quot;}}&quot;) </span><span class="marked0"><a
360
+ name="line144"></a>144 if @plugin_syntax.call(buf) </span><span
361
+ class="marked1"><a name="line145"></a>145 return buf </span><span
362
+ class="inferred0"><a name="line146"></a>146 end </span><span
363
+ class="marked1"><a name="line147"></a>147 buf &lt;&lt; &quot;}}&quot;
364
+ </span><span class="inferred0"><a name="line148"></a>148 end </span><span
365
+ class="marked1"><a name="line149"></a>149 s.pos = pos </span><span
366
+ class="marked0"><a name="line150"></a>150 nil </span><span
367
+ class="inferred1"><a name="line151"></a>151 end </span><span
368
+ class="inferred0"><a name="line152"></a>152 </span><span
369
+ class="inferred1"><a name="line153"></a>153 # </span><span
370
+ class="inferred0"><a name="line154"></a>154 # Block Level </span><span
371
+ class="inferred1"><a name="line155"></a>155 # </span><span
372
+ class="inferred0"><a name="line156"></a>156 </span><span class="marked1"><a
373
+ name="line157"></a>157 def compile_blocks(src) </span><span
374
+ class="marked0"><a name="line158"></a>158 f =
375
+ LineInput.new(StringIO.new(src)) </span><span class="marked1"><a
376
+ name="line159"></a>159 while line = f.peek </span><span class="marked0"><a
377
+ name="line160"></a>160 case line </span><span class="marked1"><a
378
+ name="line161"></a>161 when COMMENT_RE </span><span class="marked0"><a
379
+ name="line162"></a>162 f.gets </span><span class="marked1"><a
380
+ name="line163"></a>163 when HEADER_RE </span><span class="marked0"><a
381
+ name="line164"></a>164 compile_header f.gets </span><span class="marked1"><a
382
+ name="line165"></a>165 when HRULE_RE </span><span class="marked0"><a
383
+ name="line166"></a>166 f.gets </span><span class="marked1"><a
384
+ name="line167"></a>167 compile_hrule </span><span class="marked0"><a
385
+ name="line168"></a>168 when LIST_RE </span><span class="marked1"><a
386
+ name="line169"></a>169 compile_list f </span><span class="marked0"><a
387
+ name="line170"></a>170 when DLIST_RE </span><span class="marked1"><a
388
+ name="line171"></a>171 compile_dlist f </span><span class="marked0"><a
389
+ name="line172"></a>172 when TABLE_RE </span><span class="marked1"><a
390
+ name="line173"></a>173 compile_table f </span><span class="marked0"><a
391
+ name="line174"></a>174 when BLOCKQUOTE_RE </span><span class="marked1"><a
392
+ name="line175"></a>175 compile_blockquote f </span><span class="marked0"><a
393
+ name="line176"></a>176 when INDENTED_PRE_RE </span><span class="marked1"><a
394
+ name="line177"></a>177 compile_indented_pre f </span><span
395
+ class="marked0"><a name="line178"></a>178 when BLOCK_PRE_OPEN_RE
396
+ </span><span class="marked1"><a name="line179"></a>179 compile_block_pre f
397
+ </span><span class="inferred0"><a name="line180"></a>180 else </span><span
398
+ class="marked1"><a name="line181"></a>181 if /^$/ =~ line </span><span
399
+ class="marked0"><a name="line182"></a>182 f.gets </span><span
400
+ class="marked1"><a name="line183"></a>183 next </span><span
401
+ class="inferred0"><a name="line184"></a>184 end </span><span
402
+ class="marked1"><a name="line185"></a>185 compile_paragraph f </span><span
403
+ class="inferred0"><a name="line186"></a>186 end </span><span
404
+ class="inferred1"><a name="line187"></a>187 end </span><span
405
+ class="inferred0"><a name="line188"></a>188 end </span><span
406
+ class="inferred1"><a name="line189"></a>189 </span><span class="marked0"><a
407
+ name="line190"></a>190 COMMENT_RE = %r&lt;\A//&gt; </span><span
408
+ class="inferred1"><a name="line191"></a>191 </span><span class="marked0"><a
409
+ name="line192"></a>192 def skip_comments(f) </span><span class="marked1"><a
410
+ name="line193"></a>193 f.while_match(COMMENT_RE) do |line| </span><span
411
+ class="inferred0"><a name="line194"></a>194 end </span><span
412
+ class="inferred1"><a name="line195"></a>195 end </span><span
413
+ class="inferred0"><a name="line196"></a>196 </span><span class="marked1"><a
414
+ name="line197"></a>197 HEADER_RE = /\A!+/ </span><span class="inferred0"><a
415
+ name="line198"></a>198 </span><span class="marked1"><a
416
+ name="line199"></a>199 def compile_header(line) </span><span
417
+ class="marked0"><a name="line200"></a>200 @header_re ||= /\A!{1,#{7 -
418
+ @level}}/ </span><span class="marked1"><a name="line201"></a>201 level =
419
+ @level + (line.slice!(@header_re).size - 1) </span><span class="marked0"><a
420
+ name="line202"></a>202 title = strip(line) </span><span class="marked1"><a
421
+ name="line203"></a>203 @output.headline level, compile_inline(title)
422
+ </span><span class="inferred0"><a name="line204"></a>204 end </span><span
423
+ class="inferred1"><a name="line205"></a>205 </span><span class="marked0"><a
424
+ name="line206"></a>206 HRULE_RE = /\A----$/ </span><span
425
+ class="inferred1"><a name="line207"></a>207 </span><span class="marked0"><a
426
+ name="line208"></a>208 def compile_hrule </span><span class="marked1"><a
427
+ name="line209"></a>209 @output.hrule </span><span class="inferred0"><a
428
+ name="line210"></a>210 end </span><span class="inferred1"><a
429
+ name="line211"></a>211 </span><span class="marked0"><a
430
+ name="line212"></a>212 ULIST = &quot;*&quot; </span><span class="marked1"><a
431
+ name="line213"></a>213 OLIST = &quot;#&quot; </span><span class="marked0"><a
432
+ name="line214"></a>214 LIST_RE = /\A#{Regexp.union(ULIST, OLIST)}+/
433
+ </span><span class="inferred1"><a name="line215"></a>215 </span><span
434
+ class="marked0"><a name="line216"></a>216 def compile_list(f) </span><span
435
+ class="marked1"><a name="line217"></a>217 typestack = [] </span><span
436
+ class="marked0"><a name="line218"></a>218 level = 0 </span><span
437
+ class="marked1"><a name="line219"></a>219 @output.list_begin </span><span
438
+ class="marked0"><a name="line220"></a>220 f.while_match(LIST_RE) do |line|
439
+ </span><span class="marked1"><a name="line221"></a>221 list_type =
440
+ (line[0,1] == ULIST ? &quot;ul&quot; : &quot;ol&quot;) </span><span
441
+ class="marked0"><a name="line222"></a>222 new_level =
442
+ line.slice(LIST_RE).size </span><span class="marked1"><a
443
+ name="line223"></a>223 item = strip(line.sub(LIST_RE, &quot;&quot;))
444
+ </span><span class="marked0"><a name="line224"></a>224 if new_level &gt;
445
+ level </span><span class="marked1"><a name="line225"></a>225 (new_level -
446
+ level).times do </span><span class="marked0"><a name="line226"></a>226
447
+ typestack.push list_type </span><span class="marked1"><a
448
+ name="line227"></a>227 @output.list_open list_type </span><span
449
+ class="marked0"><a name="line228"></a>228 @output.listitem_open </span><span
450
+ class="inferred1"><a name="line229"></a>229 end </span><span
451
+ class="marked0"><a name="line230"></a>230 @output.listitem
452
+ compile_inline(item) </span><span class="marked1"><a name="line231"></a>231
453
+ elsif new_level &lt; level </span><span class="marked0"><a
454
+ name="line232"></a>232 (level - new_level).times do </span><span
455
+ class="marked1"><a name="line233"></a>233 @output.listitem_close
456
+ </span><span class="marked0"><a name="line234"></a>234 @output.list_close
457
+ typestack.pop </span><span class="inferred1"><a name="line235"></a>235 end
458
+ </span><span class="marked0"><a name="line236"></a>236
459
+ @output.listitem_close </span><span class="marked1"><a
460
+ name="line237"></a>237 @output.listitem_open </span><span class="marked0"><a
461
+ name="line238"></a>238 @output.listitem compile_inline(item) </span><span
462
+ class="marked1"><a name="line239"></a>239 elsif list_type == typestack.last
463
+ </span><span class="marked0"><a name="line240"></a>240
464
+ @output.listitem_close </span><span class="marked1"><a
465
+ name="line241"></a>241 @output.listitem_open </span><span class="marked0"><a
466
+ name="line242"></a>242 @output.listitem compile_inline(item) </span><span
467
+ class="inferred1"><a name="line243"></a>243 else </span><span
468
+ class="marked0"><a name="line244"></a>244 @output.listitem_close
469
+ </span><span class="marked1"><a name="line245"></a>245 @output.list_close
470
+ typestack.pop </span><span class="marked0"><a name="line246"></a>246
471
+ @output.list_open list_type </span><span class="marked1"><a
472
+ name="line247"></a>247 @output.listitem_open </span><span class="marked0"><a
473
+ name="line248"></a>248 @output.listitem compile_inline(item) </span><span
474
+ class="marked1"><a name="line249"></a>249 typestack.push list_type
475
+ </span><span class="inferred0"><a name="line250"></a>250 end </span><span
476
+ class="marked1"><a name="line251"></a>251 level = new_level </span><span
477
+ class="marked0"><a name="line252"></a>252 skip_comments f </span><span
478
+ class="inferred1"><a name="line253"></a>253 end </span><span
479
+ class="marked0"><a name="line254"></a>254 level.times do </span><span
480
+ class="marked1"><a name="line255"></a>255 @output.listitem_close
481
+ </span><span class="marked0"><a name="line256"></a>256 @output.list_close
482
+ typestack.pop </span><span class="inferred1"><a name="line257"></a>257 end
483
+ </span><span class="marked0"><a name="line258"></a>258 @output.list_end
484
+ </span><span class="inferred1"><a name="line259"></a>259 end </span><span
485
+ class="inferred0"><a name="line260"></a>260 </span><span class="marked1"><a
486
+ name="line261"></a>261 DLIST_RE = /\A:/ </span><span class="inferred0"><a
487
+ name="line262"></a>262 </span><span class="marked1"><a
488
+ name="line263"></a>263 def compile_dlist(f) </span><span class="marked0"><a
489
+ name="line264"></a>264 @output.dlist_open </span><span class="marked1"><a
490
+ name="line265"></a>265 f.while_match(DLIST_RE) do |line| </span><span
491
+ class="marked0"><a name="line266"></a>266 dt, dd =
492
+ split_dlitem(line.sub(DLIST_RE, &quot;&quot;)) </span><span
493
+ class="marked1"><a name="line267"></a>267 @output.dlist_item
494
+ compile_inline(dt), compile_inline(dd) </span><span class="marked0"><a
495
+ name="line268"></a>268 skip_comments f </span><span class="inferred1"><a
496
+ name="line269"></a>269 end </span><span class="marked0"><a
497
+ name="line270"></a>270 @output.dlist_close </span><span class="inferred1"><a
498
+ name="line271"></a>271 end </span><span class="inferred0"><a
499
+ name="line272"></a>272 </span><span class="marked1"><a
500
+ name="line273"></a>273 def split_dlitem(line) </span><span
501
+ class="marked0"><a name="line274"></a>274 re =
502
+ /\A((?:#{BRACKET_LINK_RE}|.)*?):/o </span><span class="marked1"><a
503
+ name="line275"></a>275 if m = re.match(line) </span><span class="marked0"><a
504
+ name="line276"></a>276 return m[1], m.post_match </span><span
505
+ class="uncovered1"><a name="line277"></a>277 else </span><span
506
+ class="uncovered0"><a name="line278"></a>278 return line, &quot;&quot;
507
+ </span><span class="uncovered1"><a name="line279"></a>279 end </span><span
508
+ class="uncovered0"><a name="line280"></a>280 end </span><span
509
+ class="inferred1"><a name="line281"></a>281 </span><span class="marked0"><a
510
+ name="line282"></a>282 TABLE_RE = /\A\|\|/ </span><span class="inferred1"><a
511
+ name="line283"></a>283 </span><span class="marked0"><a
512
+ name="line284"></a>284 def compile_table(f) </span><span class="marked1"><a
513
+ name="line285"></a>285 lines = [] </span><span class="marked0"><a
514
+ name="line286"></a>286 f.while_match(TABLE_RE) do |line| </span><span
515
+ class="marked1"><a name="line287"></a>287 lines.push line </span><span
516
+ class="marked0"><a name="line288"></a>288 skip_comments f </span><span
517
+ class="inferred1"><a name="line289"></a>289 end </span><span
518
+ class="marked0"><a name="line290"></a>290 @output.table_open </span><span
519
+ class="marked1"><a name="line291"></a>291 lines.each do |line| </span><span
520
+ class="marked0"><a name="line292"></a>292 @output.table_record_open
521
+ </span><span class="marked1"><a name="line293"></a>293
522
+ split_columns(line.sub(TABLE_RE, &quot;&quot;)).each do |col| </span><span
523
+ class="marked0"><a name="line294"></a>294 mid = col.sub!(/\A!/,
524
+ &quot;&quot;) ? &quot;table_head&quot; : &quot;table_data&quot; </span><span
525
+ class="marked1"><a name="line295"></a>295 span = col.slice!(/\A[\^&gt;]*/)
526
+ </span><span class="marked0"><a name="line296"></a>296 rs = span_count(span,
527
+ &quot;^&quot;) </span><span class="marked1"><a name="line297"></a>297 cs =
528
+ span_count(span, &quot;&gt;&quot;) </span><span class="marked0"><a
529
+ name="line298"></a>298 @output.__send__(mid, compile_inline(col), rs, cs)
530
+ </span><span class="inferred1"><a name="line299"></a>299 end </span><span
531
+ class="marked0"><a name="line300"></a>300 @output.table_record_close
532
+ </span><span class="inferred1"><a name="line301"></a>301 end </span><span
533
+ class="marked0"><a name="line302"></a>302 @output.table_close </span><span
534
+ class="inferred1"><a name="line303"></a>303 end </span><span
535
+ class="inferred0"><a name="line304"></a>304 </span><span class="marked1"><a
536
+ name="line305"></a>305 def split_columns(str) </span><span
537
+ class="marked0"><a name="line306"></a>306 cols = str.split(/\|\|/)
538
+ </span><span class="marked1"><a name="line307"></a>307 cols.pop if
539
+ cols.last.chomp.empty? </span><span class="marked0"><a
540
+ name="line308"></a>308 cols </span><span class="inferred1"><a
541
+ name="line309"></a>309 end </span><span class="inferred0"><a
542
+ name="line310"></a>310 </span><span class="marked1"><a
543
+ name="line311"></a>311 def span_count(str, ch) </span><span
544
+ class="marked0"><a name="line312"></a>312 c = str.count(ch) </span><span
545
+ class="marked1"><a name="line313"></a>313 c == 0 ? nil : c + 1 </span><span
546
+ class="inferred0"><a name="line314"></a>314 end </span><span
547
+ class="inferred1"><a name="line315"></a>315 </span><span class="marked0"><a
548
+ name="line316"></a>316 BLOCKQUOTE_RE = /\A&quot;&quot;[ \t]?/ </span><span
549
+ class="inferred1"><a name="line317"></a>317 </span><span class="marked0"><a
550
+ name="line318"></a>318 def compile_blockquote(f) </span><span
551
+ class="marked1"><a name="line319"></a>319 @output.blockquote_open
552
+ </span><span class="marked0"><a name="line320"></a>320 lines = []
553
+ </span><span class="marked1"><a name="line321"></a>321
554
+ f.while_match(BLOCKQUOTE_RE) do |line| </span><span class="marked0"><a
555
+ name="line322"></a>322 lines.push line.sub(BLOCKQUOTE_RE, &quot;&quot;)
556
+ </span><span class="marked1"><a name="line323"></a>323 skip_comments f
557
+ </span><span class="inferred0"><a name="line324"></a>324 end </span><span
558
+ class="marked1"><a name="line325"></a>325 compile_blocks
559
+ lines.join(&quot;&quot;) </span><span class="marked0"><a
560
+ name="line326"></a>326 @output.blockquote_close </span><span
561
+ class="inferred1"><a name="line327"></a>327 end </span><span
562
+ class="inferred0"><a name="line328"></a>328 </span><span class="marked1"><a
563
+ name="line329"></a>329 INDENTED_PRE_RE = /\A[ \t]/ </span><span
564
+ class="inferred0"><a name="line330"></a>330 </span><span class="marked1"><a
565
+ name="line331"></a>331 def compile_indented_pre(f) </span><span
566
+ class="marked0"><a name="line332"></a>332 lines = f.span(INDENTED_PRE_RE)\
567
+ </span><span class="marked1"><a name="line333"></a>333 .map {|line|
568
+ rstrip(line.sub(INDENTED_PRE_RE, &quot;&quot;)) } </span><span
569
+ class="marked0"><a name="line334"></a>334 text =
570
+ restore_plugin_block(lines.join(&quot;\n&quot;)) </span><span
571
+ class="marked1"><a name="line335"></a>335
572
+ @output.preformatted(@output.text(text)) </span><span class="inferred0"><a
573
+ name="line336"></a>336 end </span><span class="inferred1"><a
574
+ name="line337"></a>337 </span><span class="marked0"><a
575
+ name="line338"></a>338 BLOCK_PRE_OPEN_RE = /\A&lt;&lt;&lt;\s*(\w+)?/
576
+ </span><span class="marked1"><a name="line339"></a>339 BLOCK_PRE_CLOSE_RE =
577
+ /\A&gt;&gt;&gt;/ </span><span class="inferred0"><a name="line340"></a>340
578
+ </span><span class="marked1"><a name="line341"></a>341 def
579
+ compile_block_pre(f) </span><span class="marked0"><a name="line342"></a>342
580
+ m = BLOCK_PRE_OPEN_RE.match(f.gets) or raise UnexpectedError, &quot;must not
581
+ happen&quot; </span><span class="marked1"><a name="line343"></a>343 str =
582
+ restore_plugin_block(f.break(BLOCK_PRE_CLOSE_RE).join.chomp) </span><span
583
+ class="marked0"><a name="line344"></a>344 f.gets </span><span
584
+ class="marked1"><a name="line345"></a>345 @output.block_preformatted(str,
585
+ m[1]) </span><span class="inferred0"><a name="line346"></a>346 end
586
+ </span><span class="inferred1"><a name="line347"></a>347 </span><span
587
+ class="marked0"><a name="line348"></a>348 BLANK = /\A$/ </span><span
588
+ class="marked1"><a name="line349"></a>349 PARAGRAPH_END_RE =
589
+ Regexp.union(BLANK, </span><span class="inferred0"><a name="line350"></a>350
590
+ HEADER_RE, HRULE_RE, LIST_RE, DLIST_RE, </span><span class="inferred1"><a
591
+ name="line351"></a>351 BLOCKQUOTE_RE, TABLE_RE, </span><span
592
+ class="inferred0"><a name="line352"></a>352 INDENTED_PRE_RE,
593
+ BLOCK_PRE_OPEN_RE) </span><span class="inferred1"><a name="line353"></a>353
594
+ </span><span class="marked0"><a name="line354"></a>354 def
595
+ compile_paragraph(f) </span><span class="marked1"><a name="line355"></a>355
596
+ lines = f.break(PARAGRAPH_END_RE)\ </span><span class="marked0"><a
597
+ name="line356"></a>356 .reject {|line| COMMENT_RE =~ line } </span><span
598
+ class="marked1"><a name="line357"></a>357 if lines.size == 1 and
599
+ /\A\0(\d+)\0\z/ =~ strip(lines[0]) </span><span class="marked0"><a
600
+ name="line358"></a>358 @output.block_plugin plugin_block($1.to_i)
601
+ </span><span class="inferred1"><a name="line359"></a>359 else </span><span
602
+ class="marked0"><a name="line360"></a>360 line_buffer =
603
+ @output.container(:paragraph) </span><span class="marked1"><a
604
+ name="line361"></a>361 lines.each_with_index do |line, i| </span><span
605
+ class="marked0"><a name="line362"></a>362 buffer = @output.container
606
+ </span><span class="marked1"><a name="line363"></a>363 line_buffer &lt;&lt;
607
+ buffer </span><span class="marked0"><a name="line364"></a>364
608
+ compile_inline(lstrip(line).chomp, buffer) </span><span class="inferred1"><a
609
+ name="line365"></a>365 end </span><span class="marked0"><a
610
+ name="line366"></a>366 @output.paragraph(line_buffer) </span><span
611
+ class="inferred1"><a name="line367"></a>367 end </span><span
612
+ class="inferred0"><a name="line368"></a>368 end </span><span
613
+ class="inferred1"><a name="line369"></a>369 </span><span
614
+ class="inferred0"><a name="line370"></a>370 # </span><span
615
+ class="inferred1"><a name="line371"></a>371 # Inline Level </span><span
616
+ class="inferred0"><a name="line372"></a>372 # </span><span
617
+ class="inferred1"><a name="line373"></a>373 </span><span class="marked0"><a
618
+ name="line374"></a>374 BRACKET_LINK_RE = /\[\[.+?\]\]/ </span><span
619
+ class="marked1"><a name="line375"></a>375 URI_RE =
620
+ /(?:https?|ftp|file|mailto):[A-Za-z0-9;\/?:@&amp;=+$,\-_.!~*\'()#%]+/
621
+ </span><span class="marked0"><a name="line376"></a>376 WIKI_NAME_RE =
622
+ /\b(?:[A-Z]+[a-z\d]+){2,}\b/ </span><span class="inferred1"><a
623
+ name="line377"></a>377 </span><span class="marked0"><a
624
+ name="line378"></a>378 def inline_syntax_re </span><span class="marked1"><a
625
+ name="line379"></a>379 if @options[:use_wiki_name] </span><span
626
+ class="marked0"><a name="line380"></a>380 if @options[:use_not_wiki_name]
627
+ </span><span class="marked1"><a name="line381"></a>381 /
628
+ (#{BRACKET_LINK_RE}) </span><span class="uncovered0"><a
629
+ name="line382"></a>382 | (#{URI_RE}) </span><span class="uncovered1"><a
630
+ name="line383"></a>383 | (#{MODIFIER_RE}) </span><span class="marked0"><a
631
+ name="line384"></a>384 | (\^?#{WIKI_NAME_RE}) </span><span
632
+ class="uncovered1"><a name="line385"></a>385 /xo </span><span
633
+ class="inferred0"><a name="line386"></a>386 else </span><span
634
+ class="marked1"><a name="line387"></a>387 / (#{BRACKET_LINK_RE})
635
+ </span><span class="uncovered0"><a name="line388"></a>388 | (#{URI_RE})
636
+ </span><span class="uncovered1"><a name="line389"></a>389 | (#{MODIFIER_RE})
637
+ </span><span class="marked0"><a name="line390"></a>390 | (#{WIKI_NAME_RE})
638
+ </span><span class="uncovered1"><a name="line391"></a>391 /xo </span><span
639
+ class="uncovered0"><a name="line392"></a>392 end </span><span
640
+ class="inferred1"><a name="line393"></a>393 else </span><span
641
+ class="marked0"><a name="line394"></a>394 / (#{BRACKET_LINK_RE})
642
+ </span><span class="uncovered1"><a name="line395"></a>395 | (#{URI_RE})
643
+ </span><span class="marked0"><a name="line396"></a>396 | (#{MODIFIER_RE})
644
+ </span><span class="uncovered1"><a name="line397"></a>397 /xo </span><span
645
+ class="uncovered0"><a name="line398"></a>398 end </span><span
646
+ class="uncovered1"><a name="line399"></a>399 end </span><span
647
+ class="inferred0"><a name="line400"></a>400 </span><span class="marked1"><a
648
+ name="line401"></a>401 def compile_inline(str, buf = nil) </span><span
649
+ class="marked0"><a name="line402"></a>402 buf ||= @output.container
650
+ </span><span class="marked1"><a name="line403"></a>403 re = inline_syntax_re
651
+ </span><span class="marked0"><a name="line404"></a>404 pending_str = nil
652
+ </span><span class="marked1"><a name="line405"></a>405 while m =
653
+ re.match(str) </span><span class="marked0"><a name="line406"></a>406 str =
654
+ m.post_match </span><span class="inferred1"><a name="line407"></a>407
655
+ </span><span class="marked0"><a name="line408"></a>408 link, uri, mod,
656
+ wiki_name = m[1, 4] </span><span class="marked1"><a name="line409"></a>409
657
+ if wiki_name and wiki_name[0, 1] == &quot;^&quot; </span><span
658
+ class="marked0"><a name="line410"></a>410 pending_str = m.pre_match +
659
+ wiki_name[1..-1] </span><span class="marked1"><a name="line411"></a>411 next
660
+ </span><span class="inferred0"><a name="line412"></a>412 end </span><span
661
+ class="inferred1"><a name="line413"></a>413 </span><span class="marked0"><a
662
+ name="line414"></a>414 pre_str = &quot;#{pending_str}#{m.pre_match}&quot;
663
+ </span><span class="marked1"><a name="line415"></a>415 pending_str = nil
664
+ </span><span class="marked0"><a name="line416"></a>416
665
+ evaluate_plugin_block(pre_str, buf) </span><span class="marked1"><a
666
+ name="line417"></a>417 compile_inline_markup(buf, link, uri, mod, wiki_name)
667
+ </span><span class="inferred0"><a name="line418"></a>418 end </span><span
668
+ class="marked1"><a name="line419"></a>419 evaluate_plugin_block(pending_str
669
+ || str, buf) </span><span class="marked0"><a name="line420"></a>420 buf
670
+ </span><span class="inferred1"><a name="line421"></a>421 end </span><span
671
+ class="inferred0"><a name="line422"></a>422 </span><span class="marked1"><a
672
+ name="line423"></a>423 def compile_inline_markup(buf, link, uri, mod,
673
+ wiki_name) </span><span class="inferred0"><a name="line424"></a>424 case
674
+ </span><span class="marked1"><a name="line425"></a>425 when link
675
+ </span><span class="marked0"><a name="line426"></a>426 buf &lt;&lt;
676
+ compile_bracket_link(link[2...-2]) </span><span class="marked1"><a
677
+ name="line427"></a>427 when uri </span><span class="marked0"><a
678
+ name="line428"></a>428 buf &lt;&lt; compile_uri_autolink(uri) </span><span
679
+ class="marked1"><a name="line429"></a>429 when mod </span><span
680
+ class="marked0"><a name="line430"></a>430 buf &lt;&lt; compile_modifier(mod)
681
+ </span><span class="marked1"><a name="line431"></a>431 when wiki_name
682
+ </span><span class="marked0"><a name="line432"></a>432 buf &lt;&lt;
683
+ @output.wiki_name(wiki_name) </span><span class="uncovered1"><a
684
+ name="line433"></a>433 else </span><span class="uncovered0"><a
685
+ name="line434"></a>434 raise UnexpectedError, &quot;must not happen&quot;
686
+ </span><span class="marked1"><a name="line435"></a>435 end </span><span
687
+ class="inferred0"><a name="line436"></a>436 end </span><span
688
+ class="inferred1"><a name="line437"></a>437 </span><span class="marked0"><a
689
+ name="line438"></a>438 def compile_bracket_link(link) </span><span
690
+ class="marked1"><a name="line439"></a>439 if m =
691
+ /\A(?&gt;[^|\\]+|\\.)*\|/.match(link) </span><span class="marked0"><a
692
+ name="line440"></a>440 title = m[0].chop </span><span class="marked1"><a
693
+ name="line441"></a>441 uri = m.post_match </span><span class="marked0"><a
694
+ name="line442"></a>442 fixed_uri = fix_uri(uri) </span><span
695
+ class="marked1"><a name="line443"></a>443 if can_image_link?(uri)
696
+ </span><span class="marked0"><a name="line444"></a>444
697
+ @output.image_hyperlink(fixed_uri, title) </span><span class="inferred1"><a
698
+ name="line445"></a>445 else </span><span class="marked0"><a
699
+ name="line446"></a>446 @output.hyperlink(fixed_uri, compile_modifier(title))
700
+ </span><span class="inferred1"><a name="line447"></a>447 end </span><span
701
+ class="inferred0"><a name="line448"></a>448 else </span><span
702
+ class="marked1"><a name="line449"></a>449 fixed_link = fix_uri(link)
703
+ </span><span class="marked0"><a name="line450"></a>450 if
704
+ can_image_link?(link) </span><span class="marked1"><a name="line451"></a>451
705
+ @output.image_hyperlink(fixed_link) </span><span class="inferred0"><a
706
+ name="line452"></a>452 else </span><span class="marked1"><a
707
+ name="line453"></a>453 @output.hyperlink(fixed_link, @output.text(link))
708
+ </span><span class="inferred0"><a name="line454"></a>454 end </span><span
709
+ class="inferred1"><a name="line455"></a>455 end </span><span
710
+ class="inferred0"><a name="line456"></a>456 end </span><span
711
+ class="inferred1"><a name="line457"></a>457 </span><span class="marked0"><a
712
+ name="line458"></a>458 def can_image_link?(uri) </span><span
713
+ class="marked1"><a name="line459"></a>459 image?(uri) and
714
+ @options[:allow_bracket_inline_image] </span><span class="inferred0"><a
715
+ name="line460"></a>460 end </span><span class="inferred1"><a
716
+ name="line461"></a>461 </span><span class="marked0"><a
717
+ name="line462"></a>462 def compile_uri_autolink(uri) </span><span
718
+ class="marked1"><a name="line463"></a>463 if image?(uri) </span><span
719
+ class="marked0"><a name="line464"></a>464
720
+ @output.image_hyperlink(fix_uri(uri)) </span><span class="inferred1"><a
721
+ name="line465"></a>465 else </span><span class="marked0"><a
722
+ name="line466"></a>466 @output.hyperlink(fix_uri(uri), @output.text(uri))
723
+ </span><span class="inferred1"><a name="line467"></a>467 end </span><span
724
+ class="inferred0"><a name="line468"></a>468 end </span><span
725
+ class="inferred1"><a name="line469"></a>469 </span><span class="marked0"><a
726
+ name="line470"></a>470 def fix_uri(uri) </span><span class="marked1"><a
727
+ name="line471"></a>471 if /\A(?:https?|ftp|file):(?!\/\/)/ =~ uri
728
+ </span><span class="marked0"><a name="line472"></a>472 uri.sub(/\A\w+:/,
729
+ &quot;&quot;) </span><span class="inferred1"><a name="line473"></a>473 else
730
+ </span><span class="marked0"><a name="line474"></a>474 uri </span><span
731
+ class="inferred1"><a name="line475"></a>475 end </span><span
732
+ class="inferred0"><a name="line476"></a>476 end </span><span
733
+ class="inferred1"><a name="line477"></a>477 </span><span class="marked0"><a
734
+ name="line478"></a>478 IMAGE_EXTS = %w(.jpg .jpeg .gif .png) </span><span
735
+ class="inferred1"><a name="line479"></a>479 </span><span class="marked0"><a
736
+ name="line480"></a>480 def image?(uri) </span><span class="marked1"><a
737
+ name="line481"></a>481 IMAGE_EXTS.include?(File.extname(uri).downcase)
738
+ </span><span class="inferred0"><a name="line482"></a>482 end </span><span
739
+ class="inferred1"><a name="line483"></a>483 </span><span class="marked0"><a
740
+ name="line484"></a>484 STRONG = &quot;'''&quot; </span><span
741
+ class="marked1"><a name="line485"></a>485 EM = &quot;''&quot; </span><span
742
+ class="marked0"><a name="line486"></a>486 DEL = &quot;==&quot; </span><span
743
+ class="inferred1"><a name="line487"></a>487 </span><span class="marked0"><a
744
+ name="line488"></a>488 STRONG_RE = /'''.+?'''/ </span><span
745
+ class="marked1"><a name="line489"></a>489 EM_RE = /''.+?''/ </span><span
746
+ class="marked0"><a name="line490"></a>490 DEL_RE = /==.+?==/ </span><span
747
+ class="inferred1"><a name="line491"></a>491 </span><span class="marked0"><a
748
+ name="line492"></a>492 MODIFIER_RE = Regexp.union(STRONG_RE, EM_RE, DEL_RE)
749
+ </span><span class="inferred1"><a name="line493"></a>493 </span><span
750
+ class="marked0"><a name="line494"></a>494 MODTAG = { </span><span
751
+ class="inferred1"><a name="line495"></a>495 STRONG =&gt; &quot;strong&quot;,
752
+ </span><span class="inferred0"><a name="line496"></a>496 EM =&gt;
753
+ &quot;em&quot;, </span><span class="inferred1"><a name="line497"></a>497 DEL
754
+ =&gt; &quot;del&quot; </span><span class="inferred0"><a
755
+ name="line498"></a>498 } </span><span class="inferred1"><a
756
+ name="line499"></a>499 </span><span class="marked0"><a
757
+ name="line500"></a>500 def compile_modifier(str) </span><span
758
+ class="marked1"><a name="line501"></a>501 buf = @output.container
759
+ </span><span class="marked0"><a name="line502"></a>502 while m = /
760
+ (#{MODIFIER_RE}) </span><span class="uncovered1"><a name="line503"></a>503
761
+ /xo.match(str) </span><span class="marked0"><a name="line504"></a>504
762
+ evaluate_plugin_block(m.pre_match, buf) </span><span class="inferred1"><a
763
+ name="line505"></a>505 case </span><span class="marked0"><a
764
+ name="line506"></a>506 when chunk = m[1] </span><span class="marked1"><a
765
+ name="line507"></a>507 mod, s = split_mod(chunk) </span><span
766
+ class="marked0"><a name="line508"></a>508 mid = MODTAG[mod] </span><span
767
+ class="marked1"><a name="line509"></a>509 buf &lt;&lt; @output.__send__(mid,
768
+ compile_inline(s)) </span><span class="uncovered0"><a name="line510"></a>510
769
+ else </span><span class="uncovered1"><a name="line511"></a>511 raise
770
+ UnexpectedError, &quot;must not happen&quot; </span><span class="marked0"><a
771
+ name="line512"></a>512 end </span><span class="marked1"><a
772
+ name="line513"></a>513 str = m.post_match </span><span class="inferred0"><a
773
+ name="line514"></a>514 end </span><span class="marked1"><a
774
+ name="line515"></a>515 evaluate_plugin_block(str, buf) </span><span
775
+ class="marked0"><a name="line516"></a>516 buf </span><span
776
+ class="inferred1"><a name="line517"></a>517 end </span><span
777
+ class="inferred0"><a name="line518"></a>518 </span><span class="marked1"><a
778
+ name="line519"></a>519 def split_mod(str) </span><span class="marked0"><a
779
+ name="line520"></a>520 case str </span><span class="marked1"><a
780
+ name="line521"></a>521 when /\A'''/ </span><span class="marked0"><a
781
+ name="line522"></a>522 return str[0, 3], str[3...-3] </span><span
782
+ class="marked1"><a name="line523"></a>523 when /\A''/ </span><span
783
+ class="marked0"><a name="line524"></a>524 return str[0, 2], str[2...-2]
784
+ </span><span class="marked1"><a name="line525"></a>525 when /\A==/
785
+ </span><span class="marked0"><a name="line526"></a>526 return str[0, 2],
786
+ str[2...-2] </span><span class="uncovered1"><a name="line527"></a>527 else
787
+ </span><span class="uncovered0"><a name="line528"></a>528 raise
788
+ UnexpectedError, &quot;must not happen: #{str.inspect}&quot; </span><span
789
+ class="uncovered1"><a name="line529"></a>529 end </span><span
790
+ class="uncovered0"><a name="line530"></a>530 end </span><span
791
+ class="inferred1"><a name="line531"></a>531 </span><span class="marked0"><a
792
+ name="line532"></a>532 def strip(str) </span><span class="marked1"><a
793
+ name="line533"></a>533 rstrip(lstrip(str)) </span><span class="inferred0"><a
794
+ name="line534"></a>534 end </span><span class="inferred1"><a
795
+ name="line535"></a>535 </span><span class="marked0"><a
796
+ name="line536"></a>536 def rstrip(str) </span><span class="marked1"><a
797
+ name="line537"></a>537 str.sub(/[ \t\r\n\v\f]+\z/, &quot;&quot;)
798
+ </span><span class="inferred0"><a name="line538"></a>538 end </span><span
799
+ class="inferred1"><a name="line539"></a>539 </span><span class="marked0"><a
800
+ name="line540"></a>540 def lstrip(str) </span><span class="marked1"><a
801
+ name="line541"></a>541 str.sub(/\A[ \t\r\n\v\f]+/, &quot;&quot;)
802
+ </span><span class="inferred0"><a name="line542"></a>542 end </span><span
803
+ class="inferred1"><a name="line543"></a>543 </span><span
804
+ class="inferred0"><a name="line544"></a>544 </span><span class="marked1"><a
805
+ name="line545"></a>545 class HTMLOutput </span><span class="marked0"><a
806
+ name="line546"></a>546 def initialize(suffix = &quot; /&gt;&quot;)
807
+ </span><span class="marked1"><a name="line547"></a>547 @suffix = suffix
808
+ </span><span class="marked0"><a name="line548"></a>548 @f = nil </span><span
809
+ class="inferred1"><a name="line549"></a>549 end </span><span
810
+ class="inferred0"><a name="line550"></a>550 </span><span class="marked1"><a
811
+ name="line551"></a>551 def reset </span><span class="marked0"><a
812
+ name="line552"></a>552 @f = StringIO.new </span><span class="inferred1"><a
813
+ name="line553"></a>553 end </span><span class="inferred0"><a
814
+ name="line554"></a>554 </span><span class="marked1"><a
815
+ name="line555"></a>555 def finish </span><span class="marked0"><a
816
+ name="line556"></a>556 @f.string </span><span class="inferred1"><a
817
+ name="line557"></a>557 end </span><span class="inferred0"><a
818
+ name="line558"></a>558 </span><span class="marked1"><a
819
+ name="line559"></a>559 def container(_for=nil) </span><span
820
+ class="marked0"><a name="line560"></a>560 case _for </span><span
821
+ class="marked1"><a name="line561"></a>561 when :paragraph </span><span
822
+ class="marked0"><a name="line562"></a>562 [] </span><span
823
+ class="inferred1"><a name="line563"></a>563 else </span><span
824
+ class="marked0"><a name="line564"></a>564 &quot;&quot; </span><span
825
+ class="inferred1"><a name="line565"></a>565 end </span><span
826
+ class="inferred0"><a name="line566"></a>566 end </span><span
827
+ class="inferred1"><a name="line567"></a>567 </span><span
828
+ class="inferred0"><a name="line568"></a>568 # </span><span
829
+ class="inferred1"><a name="line569"></a>569 # Procedures </span><span
830
+ class="inferred0"><a name="line570"></a>570 # </span><span
831
+ class="inferred1"><a name="line571"></a>571 </span><span class="marked0"><a
832
+ name="line572"></a>572 def headline(level, title) </span><span
833
+ class="marked1"><a name="line573"></a>573 @f.puts
834
+ &quot;&lt;h#{level}&gt;#{title}&lt;/h#{level}&gt;&quot; </span><span
835
+ class="inferred0"><a name="line574"></a>574 end </span><span
836
+ class="inferred1"><a name="line575"></a>575 </span><span class="marked0"><a
837
+ name="line576"></a>576 def hrule </span><span class="marked1"><a
838
+ name="line577"></a>577 @f.puts &quot;&lt;hr#{@suffix}&quot; </span><span
839
+ class="inferred0"><a name="line578"></a>578 end </span><span
840
+ class="inferred1"><a name="line579"></a>579 </span><span class="marked0"><a
841
+ name="line580"></a>580 def list_begin </span><span class="marked1"><a
842
+ name="line581"></a>581 end </span><span class="inferred0"><a
843
+ name="line582"></a>582 </span><span class="marked1"><a
844
+ name="line583"></a>583 def list_end </span><span class="marked0"><a
845
+ name="line584"></a>584 @f.puts </span><span class="inferred1"><a
846
+ name="line585"></a>585 end </span><span class="inferred0"><a
847
+ name="line586"></a>586 </span><span class="marked1"><a
848
+ name="line587"></a>587 def list_open(type) </span><span class="marked0"><a
849
+ name="line588"></a>588 @f.puts &quot;&lt;#{type}&gt;&quot; </span><span
850
+ class="inferred1"><a name="line589"></a>589 end </span><span
851
+ class="inferred0"><a name="line590"></a>590 </span><span class="marked1"><a
852
+ name="line591"></a>591 def list_close(type) </span><span class="marked0"><a
853
+ name="line592"></a>592 @f.print &quot;&lt;/#{type}&gt;&quot; </span><span
854
+ class="inferred1"><a name="line593"></a>593 end </span><span
855
+ class="inferred0"><a name="line594"></a>594 </span><span class="marked1"><a
856
+ name="line595"></a>595 def listitem_open </span><span class="marked0"><a
857
+ name="line596"></a>596 @f.print &quot;&lt;li&gt;&quot; </span><span
858
+ class="inferred1"><a name="line597"></a>597 end </span><span
859
+ class="inferred0"><a name="line598"></a>598 </span><span class="marked1"><a
860
+ name="line599"></a>599 def listitem_close </span><span class="marked0"><a
861
+ name="line600"></a>600 @f.puts &quot;&lt;/li&gt;&quot; </span><span
862
+ class="inferred1"><a name="line601"></a>601 end </span><span
863
+ class="inferred0"><a name="line602"></a>602 </span><span class="marked1"><a
864
+ name="line603"></a>603 def listitem(item) </span><span class="marked0"><a
865
+ name="line604"></a>604 @f.print item </span><span class="inferred1"><a
866
+ name="line605"></a>605 end </span><span class="inferred0"><a
867
+ name="line606"></a>606 </span><span class="marked1"><a
868
+ name="line607"></a>607 def dlist_open </span><span class="marked0"><a
869
+ name="line608"></a>608 @f.puts &quot;&lt;dl&gt;&quot; </span><span
870
+ class="inferred1"><a name="line609"></a>609 end </span><span
871
+ class="inferred0"><a name="line610"></a>610 </span><span class="marked1"><a
872
+ name="line611"></a>611 def dlist_close </span><span class="marked0"><a
873
+ name="line612"></a>612 @f.puts &quot;&lt;/dl&gt;&quot; </span><span
874
+ class="inferred1"><a name="line613"></a>613 end </span><span
875
+ class="inferred0"><a name="line614"></a>614 </span><span class="marked1"><a
876
+ name="line615"></a>615 def dlist_item(dt, dd) </span><span
877
+ class="inferred0"><a name="line616"></a>616 case </span><span
878
+ class="marked1"><a name="line617"></a>617 when dd.empty? </span><span
879
+ class="marked0"><a name="line618"></a>618 @f.puts
880
+ &quot;&lt;dt&gt;#{dt}&lt;/dt&gt;&quot; </span><span class="marked1"><a
881
+ name="line619"></a>619 when dt.empty? </span><span class="marked0"><a
882
+ name="line620"></a>620 @f.puts &quot;&lt;dd&gt;#{dd}&lt;/dd&gt;&quot;
883
+ </span><span class="inferred1"><a name="line621"></a>621 else </span><span
884
+ class="marked0"><a name="line622"></a>622 @f.puts
885
+ &quot;&lt;dt&gt;#{dt}&lt;/dt&gt;&quot; </span><span class="marked1"><a
886
+ name="line623"></a>623 @f.puts &quot;&lt;dd&gt;#{dd}&lt;/dd&gt;&quot;
887
+ </span><span class="marked0"><a name="line624"></a>624 end </span><span
888
+ class="inferred1"><a name="line625"></a>625 end </span><span
889
+ class="inferred0"><a name="line626"></a>626 </span><span class="marked1"><a
890
+ name="line627"></a>627 def table_open </span><span class="marked0"><a
891
+ name="line628"></a>628 @f.puts %Q(&lt;table border=&quot;1&quot;&gt;)
892
+ </span><span class="inferred1"><a name="line629"></a>629 end </span><span
893
+ class="inferred0"><a name="line630"></a>630 </span><span class="marked1"><a
894
+ name="line631"></a>631 def table_close </span><span class="marked0"><a
895
+ name="line632"></a>632 @f.puts &quot;&lt;/table&gt;&quot; </span><span
896
+ class="inferred1"><a name="line633"></a>633 end </span><span
897
+ class="inferred0"><a name="line634"></a>634 </span><span class="marked1"><a
898
+ name="line635"></a>635 def table_record_open </span><span class="marked0"><a
899
+ name="line636"></a>636 @f.print &quot;&lt;tr&gt;&quot; </span><span
900
+ class="inferred1"><a name="line637"></a>637 end </span><span
901
+ class="inferred0"><a name="line638"></a>638 </span><span class="marked1"><a
902
+ name="line639"></a>639 def table_record_close </span><span
903
+ class="marked0"><a name="line640"></a>640 @f.puts &quot;&lt;/tr&gt;&quot;
904
+ </span><span class="inferred1"><a name="line641"></a>641 end </span><span
905
+ class="inferred0"><a name="line642"></a>642 </span><span class="marked1"><a
906
+ name="line643"></a>643 def table_head(item, rs, cs) </span><span
907
+ class="marked0"><a name="line644"></a>644 @f.print &quot;&lt;th#{tdattr(rs,
908
+ cs)}&gt;#{item}&lt;/th&gt;&quot; </span><span class="inferred1"><a
909
+ name="line645"></a>645 end </span><span class="inferred0"><a
910
+ name="line646"></a>646 </span><span class="marked1"><a
911
+ name="line647"></a>647 def table_data(item, rs, cs) </span><span
912
+ class="marked0"><a name="line648"></a>648 @f.print &quot;&lt;td#{tdattr(rs,
913
+ cs)}&gt;#{item}&lt;/td&gt;&quot; </span><span class="inferred1"><a
914
+ name="line649"></a>649 end </span><span class="inferred0"><a
915
+ name="line650"></a>650 </span><span class="marked1"><a
916
+ name="line651"></a>651 def tdattr(rs, cs) </span><span class="marked0"><a
917
+ name="line652"></a>652 buf = &quot;&quot; </span><span class="marked1"><a
918
+ name="line653"></a>653 buf &lt;&lt; %Q( rowspan=&quot;#{rs}&quot;) if rs
919
+ </span><span class="marked0"><a name="line654"></a>654 buf &lt;&lt; %Q(
920
+ colspan=&quot;#{cs}&quot;) if cs </span><span class="marked1"><a
921
+ name="line655"></a>655 buf </span><span class="inferred0"><a
922
+ name="line656"></a>656 end </span><span class="marked1"><a
923
+ name="line657"></a>657 private :tdattr </span><span class="inferred0"><a
924
+ name="line658"></a>658 </span><span class="marked1"><a
925
+ name="line659"></a>659 def blockquote_open </span><span class="marked0"><a
926
+ name="line660"></a>660 @f.print &quot;&lt;blockquote&gt;&quot; </span><span
927
+ class="inferred1"><a name="line661"></a>661 end </span><span
928
+ class="inferred0"><a name="line662"></a>662 </span><span class="marked1"><a
929
+ name="line663"></a>663 def blockquote_close </span><span class="marked0"><a
930
+ name="line664"></a>664 @f.puts &quot;&lt;/blockquote&gt;&quot; </span><span
931
+ class="inferred1"><a name="line665"></a>665 end </span><span
932
+ class="inferred0"><a name="line666"></a>666 </span><span class="marked1"><a
933
+ name="line667"></a>667 def block_preformatted(str, info) </span><span
934
+ class="marked0"><a name="line668"></a>668 syntax = info ? info.downcase :
935
+ nil </span><span class="marked1"><a name="line669"></a>669 if syntax
936
+ </span><span class="marked0"><a name="line670"></a>670 begin </span><span
937
+ class="marked1"><a name="line671"></a>671 convertor =
938
+ Syntax::Convertors::HTML.for_syntax(syntax) </span><span class="marked0"><a
939
+ name="line672"></a>672 @f.puts convertor.convert(str) </span><span
940
+ class="marked1"><a name="line673"></a>673 return </span><span
941
+ class="uncovered0"><a name="line674"></a>674 rescue NameError, RuntimeError
942
+ </span><span class="uncovered1"><a name="line675"></a>675 end </span><span
943
+ class="uncovered0"><a name="line676"></a>676 end </span><span
944
+ class="marked1"><a name="line677"></a>677 preformatted(text(str))
945
+ </span><span class="inferred0"><a name="line678"></a>678 end </span><span
946
+ class="inferred1"><a name="line679"></a>679 </span><span class="marked0"><a
947
+ name="line680"></a>680 def preformatted(str) </span><span class="marked1"><a
948
+ name="line681"></a>681 @f.print &quot;&lt;pre&gt;&quot; </span><span
949
+ class="marked0"><a name="line682"></a>682 @f.print str </span><span
950
+ class="marked1"><a name="line683"></a>683 @f.puts &quot;&lt;/pre&gt;&quot;
951
+ </span><span class="inferred0"><a name="line684"></a>684 end </span><span
952
+ class="inferred1"><a name="line685"></a>685 </span><span class="marked0"><a
953
+ name="line686"></a>686 def paragraph(lines) </span><span class="marked1"><a
954
+ name="line687"></a>687 @f.puts
955
+ &quot;&lt;p&gt;#{lines.join(&quot;\n&quot;)}&lt;/p&gt;&quot; </span><span
956
+ class="inferred0"><a name="line688"></a>688 end </span><span
957
+ class="inferred1"><a name="line689"></a>689 </span><span class="marked0"><a
958
+ name="line690"></a>690 def block_plugin(str) </span><span class="marked1"><a
959
+ name="line691"></a>691 @f.puts %Q(&lt;div
960
+ class=&quot;plugin&quot;&gt;{{#{escape_html(str)}}}&lt;/div&gt;)
961
+ </span><span class="inferred0"><a name="line692"></a>692 end </span><span
962
+ class="inferred1"><a name="line693"></a>693 </span><span
963
+ class="inferred0"><a name="line694"></a>694 # </span><span
964
+ class="inferred1"><a name="line695"></a>695 # Functions </span><span
965
+ class="inferred0"><a name="line696"></a>696 # </span><span
966
+ class="inferred1"><a name="line697"></a>697 </span><span class="marked0"><a
967
+ name="line698"></a>698 def hyperlink(uri, title) </span><span
968
+ class="marked1"><a name="line699"></a>699 %Q(&lt;a
969
+ href=&quot;#{escape_html_param(uri)}&quot;&gt;#{title}&lt;/a&gt;)
970
+ </span><span class="inferred0"><a name="line700"></a>700 end </span><span
971
+ class="inferred1"><a name="line701"></a>701 </span><span class="marked0"><a
972
+ name="line702"></a>702 def wiki_name(name) </span><span class="marked1"><a
973
+ name="line703"></a>703 hyperlink(name, text(name)) </span><span
974
+ class="inferred0"><a name="line704"></a>704 end </span><span
975
+ class="inferred1"><a name="line705"></a>705 </span><span class="marked0"><a
976
+ name="line706"></a>706 def image_hyperlink(uri, alt = nil) </span><span
977
+ class="marked1"><a name="line707"></a>707 alt ||= uri.split(/\//).last
978
+ </span><span class="marked0"><a name="line708"></a>708 alt =
979
+ escape_html(alt) </span><span class="marked1"><a name="line709"></a>709
980
+ %Q(&lt;img src=&quot;#{escape_html_param(uri)}&quot;
981
+ alt=&quot;#{alt}&quot;#{@suffix}) </span><span class="inferred0"><a
982
+ name="line710"></a>710 end </span><span class="inferred1"><a
983
+ name="line711"></a>711 </span><span class="marked0"><a
984
+ name="line712"></a>712 def strong(item) </span><span class="marked1"><a
985
+ name="line713"></a>713 &quot;&lt;strong&gt;#{item}&lt;/strong&gt;&quot;
986
+ </span><span class="inferred0"><a name="line714"></a>714 end </span><span
987
+ class="inferred1"><a name="line715"></a>715 </span><span class="marked0"><a
988
+ name="line716"></a>716 def em(item) </span><span class="marked1"><a
989
+ name="line717"></a>717 &quot;&lt;em&gt;#{item}&lt;/em&gt;&quot; </span><span
990
+ class="inferred0"><a name="line718"></a>718 end </span><span
991
+ class="inferred1"><a name="line719"></a>719 </span><span class="marked0"><a
992
+ name="line720"></a>720 def del(item) </span><span class="marked1"><a
993
+ name="line721"></a>721 &quot;&lt;del&gt;#{item}&lt;/del&gt;&quot;
994
+ </span><span class="inferred0"><a name="line722"></a>722 end </span><span
995
+ class="inferred1"><a name="line723"></a>723 </span><span class="marked0"><a
996
+ name="line724"></a>724 def text(str) </span><span class="marked1"><a
997
+ name="line725"></a>725 escape_html(str) </span><span class="inferred0"><a
998
+ name="line726"></a>726 end </span><span class="inferred1"><a
999
+ name="line727"></a>727 </span><span class="marked0"><a
1000
+ name="line728"></a>728 def inline_plugin(src) </span><span
1001
+ class="marked1"><a name="line729"></a>729 %Q(&lt;span
1002
+ class=&quot;plugin&quot;&gt;{{#{src}}}&lt;/span&gt;) </span><span
1003
+ class="inferred0"><a name="line730"></a>730 end </span><span
1004
+ class="inferred1"><a name="line731"></a>731 </span><span
1005
+ class="inferred0"><a name="line732"></a>732 # </span><span
1006
+ class="inferred1"><a name="line733"></a>733 # Utilities </span><span
1007
+ class="inferred0"><a name="line734"></a>734 # </span><span
1008
+ class="inferred1"><a name="line735"></a>735 </span><span class="marked0"><a
1009
+ name="line736"></a>736 def escape_html_param(str) </span><span
1010
+ class="marked1"><a name="line737"></a>737 escape_quote(escape_html(str))
1011
+ </span><span class="inferred0"><a name="line738"></a>738 end </span><span
1012
+ class="inferred1"><a name="line739"></a>739 </span><span class="marked0"><a
1013
+ name="line740"></a>740 def escape_html(text) </span><span class="marked1"><a
1014
+ name="line741"></a>741 text.gsub(/&amp;/,
1015
+ &quot;&amp;amp;&quot;).gsub(/&lt;/, &quot;&amp;lt;&quot;).gsub(/&gt;/,
1016
+ &quot;&amp;gt;&quot;) </span><span class="inferred0"><a
1017
+ name="line742"></a>742 end </span><span class="inferred1"><a
1018
+ name="line743"></a>743 </span><span class="marked0"><a
1019
+ name="line744"></a>744 def unescape_html(text) </span><span
1020
+ class="uncovered1"><a name="line745"></a>745 text.gsub(/&amp;gt;/,
1021
+ &quot;&gt;&quot;).gsub(/&amp;lt;/, &quot;&lt;&quot;).gsub(/&amp;amp;/,
1022
+ &quot;&amp;&quot;) </span><span class="uncovered0"><a name="line746"></a>746
1023
+ end </span><span class="inferred1"><a name="line747"></a>747 </span><span
1024
+ class="marked0"><a name="line748"></a>748 def escape_quote(text)
1025
+ </span><span class="marked1"><a name="line749"></a>749 text.gsub(/&quot;/,
1026
+ &quot;&amp;quot;&quot;) </span><span class="inferred0"><a
1027
+ name="line750"></a>750 end </span><span class="inferred1"><a
1028
+ name="line751"></a>751 end </span><span class="inferred0"><a
1029
+ name="line752"></a>752 </span><span class="inferred1"><a
1030
+ name="line753"></a>753 </span><span class="marked0"><a
1031
+ name="line754"></a>754 class LineInput </span><span class="marked1"><a
1032
+ name="line755"></a>755 def initialize(f) </span><span class="marked0"><a
1033
+ name="line756"></a>756 @input = f </span><span class="marked1"><a
1034
+ name="line757"></a>757 @buf = [] </span><span class="marked0"><a
1035
+ name="line758"></a>758 @lineno = 0 </span><span class="marked1"><a
1036
+ name="line759"></a>759 @eof_p = false </span><span class="inferred0"><a
1037
+ name="line760"></a>760 end </span><span class="inferred1"><a
1038
+ name="line761"></a>761 </span><span class="marked0"><a
1039
+ name="line762"></a>762 def inspect </span><span class="uncovered1"><a
1040
+ name="line763"></a>763 &quot;\#&lt;#{self.class} file=#{@input.inspect}
1041
+ line=#{lineno()}&gt;&quot; </span><span class="uncovered0"><a
1042
+ name="line764"></a>764 end </span><span class="inferred1"><a
1043
+ name="line765"></a>765 </span><span class="marked0"><a
1044
+ name="line766"></a>766 def eof? </span><span class="uncovered1"><a
1045
+ name="line767"></a>767 @eof_p </span><span class="uncovered0"><a
1046
+ name="line768"></a>768 end </span><span class="inferred1"><a
1047
+ name="line769"></a>769 </span><span class="marked0"><a
1048
+ name="line770"></a>770 def lineno </span><span class="uncovered1"><a
1049
+ name="line771"></a>771 @lineno </span><span class="uncovered0"><a
1050
+ name="line772"></a>772 end </span><span class="inferred1"><a
1051
+ name="line773"></a>773 </span><span class="marked0"><a
1052
+ name="line774"></a>774 def gets </span><span class="marked1"><a
1053
+ name="line775"></a>775 unless @buf.empty? </span><span class="marked0"><a
1054
+ name="line776"></a>776 @lineno += 1 </span><span class="marked1"><a
1055
+ name="line777"></a>777 return @buf.pop </span><span class="inferred0"><a
1056
+ name="line778"></a>778 end </span><span class="marked1"><a
1057
+ name="line779"></a>779 return nil if @eof_p # to avoid ARGF blocking.
1058
+ </span><span class="marked0"><a name="line780"></a>780 line = @input.gets
1059
+ </span><span class="marked1"><a name="line781"></a>781 line =
1060
+ line.sub(/\r\n/, &quot;\n&quot;) if line </span><span class="marked0"><a
1061
+ name="line782"></a>782 @eof_p = line.nil? </span><span class="marked1"><a
1062
+ name="line783"></a>783 @lineno += 1 </span><span class="marked0"><a
1063
+ name="line784"></a>784 line </span><span class="inferred1"><a
1064
+ name="line785"></a>785 end </span><span class="inferred0"><a
1065
+ name="line786"></a>786 </span><span class="marked1"><a
1066
+ name="line787"></a>787 def ungets(line) </span><span class="marked0"><a
1067
+ name="line788"></a>788 return unless line </span><span class="marked1"><a
1068
+ name="line789"></a>789 @lineno -= 1 </span><span class="marked0"><a
1069
+ name="line790"></a>790 @buf.push line </span><span class="marked1"><a
1070
+ name="line791"></a>791 line </span><span class="inferred0"><a
1071
+ name="line792"></a>792 end </span><span class="inferred1"><a
1072
+ name="line793"></a>793 </span><span class="marked0"><a
1073
+ name="line794"></a>794 def peek </span><span class="marked1"><a
1074
+ name="line795"></a>795 line = gets() </span><span class="marked0"><a
1075
+ name="line796"></a>796 ungets line if line </span><span class="marked1"><a
1076
+ name="line797"></a>797 line </span><span class="inferred0"><a
1077
+ name="line798"></a>798 end </span><span class="inferred1"><a
1078
+ name="line799"></a>799 </span><span class="marked0"><a
1079
+ name="line800"></a>800 def next? </span><span class="uncovered1"><a
1080
+ name="line801"></a>801 peek() ? true : false </span><span
1081
+ class="uncovered0"><a name="line802"></a>802 end </span><span
1082
+ class="inferred1"><a name="line803"></a>803 </span><span class="marked0"><a
1083
+ name="line804"></a>804 def skip_blank_lines </span><span
1084
+ class="uncovered1"><a name="line805"></a>805 n = 0 </span><span
1085
+ class="uncovered0"><a name="line806"></a>806 while line = gets()
1086
+ </span><span class="uncovered1"><a name="line807"></a>807 unless
1087
+ line.strip.empty? </span><span class="uncovered0"><a name="line808"></a>808
1088
+ ungets line </span><span class="uncovered1"><a name="line809"></a>809 return
1089
+ n </span><span class="uncovered0"><a name="line810"></a>810 end </span><span
1090
+ class="uncovered1"><a name="line811"></a>811 n += 1 </span><span
1091
+ class="uncovered0"><a name="line812"></a>812 end </span><span
1092
+ class="uncovered1"><a name="line813"></a>813 n </span><span
1093
+ class="uncovered0"><a name="line814"></a>814 end </span><span
1094
+ class="inferred1"><a name="line815"></a>815 </span><span class="marked0"><a
1095
+ name="line816"></a>816 def gets_if(re) </span><span class="uncovered1"><a
1096
+ name="line817"></a>817 line = gets() </span><span class="uncovered0"><a
1097
+ name="line818"></a>818 if not line or not (re =~ line) </span><span
1098
+ class="uncovered1"><a name="line819"></a>819 ungets line </span><span
1099
+ class="uncovered0"><a name="line820"></a>820 return nil </span><span
1100
+ class="uncovered1"><a name="line821"></a>821 end </span><span
1101
+ class="uncovered0"><a name="line822"></a>822 line </span><span
1102
+ class="uncovered1"><a name="line823"></a>823 end </span><span
1103
+ class="inferred0"><a name="line824"></a>824 </span><span class="marked1"><a
1104
+ name="line825"></a>825 def gets_unless(re) </span><span
1105
+ class="uncovered0"><a name="line826"></a>826 line = gets() </span><span
1106
+ class="uncovered1"><a name="line827"></a>827 if not line or re =~ line
1107
+ </span><span class="uncovered0"><a name="line828"></a>828 ungets line
1108
+ </span><span class="uncovered1"><a name="line829"></a>829 return nil
1109
+ </span><span class="uncovered0"><a name="line830"></a>830 end </span><span
1110
+ class="uncovered1"><a name="line831"></a>831 line </span><span
1111
+ class="uncovered0"><a name="line832"></a>832 end </span><span
1112
+ class="inferred1"><a name="line833"></a>833 </span><span class="marked0"><a
1113
+ name="line834"></a>834 def each </span><span class="uncovered1"><a
1114
+ name="line835"></a>835 while line = gets() </span><span
1115
+ class="uncovered0"><a name="line836"></a>836 yield line </span><span
1116
+ class="uncovered1"><a name="line837"></a>837 end </span><span
1117
+ class="uncovered0"><a name="line838"></a>838 end </span><span
1118
+ class="inferred1"><a name="line839"></a>839 </span><span class="marked0"><a
1119
+ name="line840"></a>840 def while_match(re) </span><span class="marked1"><a
1120
+ name="line841"></a>841 while line = gets() </span><span class="marked0"><a
1121
+ name="line842"></a>842 unless re =~ line </span><span class="marked1"><a
1122
+ name="line843"></a>843 ungets line </span><span class="marked0"><a
1123
+ name="line844"></a>844 return </span><span class="inferred1"><a
1124
+ name="line845"></a>845 end </span><span class="marked0"><a
1125
+ name="line846"></a>846 yield line </span><span class="inferred1"><a
1126
+ name="line847"></a>847 end </span><span class="marked0"><a
1127
+ name="line848"></a>848 nil </span><span class="inferred1"><a
1128
+ name="line849"></a>849 end </span><span class="inferred0"><a
1129
+ name="line850"></a>850 </span><span class="marked1"><a
1130
+ name="line851"></a>851 def getlines_while(re) </span><span
1131
+ class="marked0"><a name="line852"></a>852 buf = [] </span><span
1132
+ class="marked1"><a name="line853"></a>853 while_match(re) do |line|
1133
+ </span><span class="marked0"><a name="line854"></a>854 buf.push line
1134
+ </span><span class="inferred1"><a name="line855"></a>855 end </span><span
1135
+ class="marked0"><a name="line856"></a>856 buf </span><span
1136
+ class="inferred1"><a name="line857"></a>857 end </span><span
1137
+ class="inferred0"><a name="line858"></a>858 </span><span class="marked1"><a
1138
+ name="line859"></a>859 alias span getlines_while # from Haskell </span><span
1139
+ class="inferred0"><a name="line860"></a>860 </span><span class="marked1"><a
1140
+ name="line861"></a>861 def until_match(re) </span><span class="marked0"><a
1141
+ name="line862"></a>862 while line = gets() </span><span class="marked1"><a
1142
+ name="line863"></a>863 if re =~ line </span><span class="marked0"><a
1143
+ name="line864"></a>864 ungets line </span><span class="marked1"><a
1144
+ name="line865"></a>865 return </span><span class="inferred0"><a
1145
+ name="line866"></a>866 end </span><span class="marked1"><a
1146
+ name="line867"></a>867 yield line </span><span class="inferred0"><a
1147
+ name="line868"></a>868 end </span><span class="marked1"><a
1148
+ name="line869"></a>869 nil </span><span class="inferred0"><a
1149
+ name="line870"></a>870 end </span><span class="inferred1"><a
1150
+ name="line871"></a>871 </span><span class="marked0"><a
1151
+ name="line872"></a>872 def getlines_until(re) </span><span
1152
+ class="marked1"><a name="line873"></a>873 buf = [] </span><span
1153
+ class="marked0"><a name="line874"></a>874 until_match(re) do |line|
1154
+ </span><span class="marked1"><a name="line875"></a>875 buf.push line
1155
+ </span><span class="inferred0"><a name="line876"></a>876 end </span><span
1156
+ class="marked1"><a name="line877"></a>877 buf </span><span
1157
+ class="inferred0"><a name="line878"></a>878 end </span><span
1158
+ class="inferred1"><a name="line879"></a>879 </span><span class="marked0"><a
1159
+ name="line880"></a>880 alias break getlines_until # from Haskell
1160
+ </span><span class="inferred1"><a name="line881"></a>881 </span><span
1161
+ class="marked0"><a name="line882"></a>882 def until_terminator(re)
1162
+ </span><span class="uncovered1"><a name="line883"></a>883 while line =
1163
+ gets() </span><span class="uncovered0"><a name="line884"></a>884 return if
1164
+ re =~ line # discard terminal line </span><span class="uncovered1"><a
1165
+ name="line885"></a>885 yield line </span><span class="uncovered0"><a
1166
+ name="line886"></a>886 end </span><span class="uncovered1"><a
1167
+ name="line887"></a>887 nil </span><span class="uncovered0"><a
1168
+ name="line888"></a>888 end </span><span class="inferred1"><a
1169
+ name="line889"></a>889 </span><span class="marked0"><a
1170
+ name="line890"></a>890 def getblock(term_re) </span><span
1171
+ class="uncovered1"><a name="line891"></a>891 buf = [] </span><span
1172
+ class="uncovered0"><a name="line892"></a>892 until_terminator(term_re) do
1173
+ |line| </span><span class="uncovered1"><a name="line893"></a>893 buf.push
1174
+ line </span><span class="uncovered0"><a name="line894"></a>894 end
1175
+ </span><span class="uncovered1"><a name="line895"></a>895 buf </span><span
1176
+ class="uncovered0"><a name="line896"></a>896 end </span><span
1177
+ class="uncovered1"><a name="line897"></a>897 end </span><span
1178
+ class="uncovered0"><a name="line898"></a>898 end </span><span
1179
+ class="inferred1"><a name="line899"></a>899 </span><span class="marked0"><a
1180
+ name="line900"></a>900 if __FILE__ == $0 </span><span class="uncovered1"><a
1181
+ name="line901"></a>901 puts HikiDoc.to_html(ARGF.read(nil)) </span><span
1182
+ class="uncovered0"><a name="line902"></a>902 end </span></pre>
1183
+ <hr />
1184
+ <p> Generated using the <a href='http://eigenclass.org/hiki.rb?rcov'> rcov
1185
+ code coverage analysis tool for Ruby </a> version 0.8.1.2. </p>
1186
+ <p>
1187
+ <a href='http://validator.w3.org/check/referer'>
1188
+ <img src='http://www.w3.org/Icons/valid-xhtml10' height='31' alt='Valid XHTML 1.0!' width='88' />
1189
+ </a>
1190
+ <a href='http://jigsaw.w3.org/css-validator/check/referer'>
1191
+ <img src='http://jigsaw.w3.org/css-validator/images/vcss' alt='Valid CSS!' style='border:0;width:88px;height:31px' />
1192
+ </a>
1193
+ </p>
1194
+ </body>
1195
+ </html>