hikidoc 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,388 @@
1
+ # Paragraphs
2
+
3
+ Consecutive lines are concatenated into a single paragraph.
4
+
5
+ Blank lines (ones with only a carriage return or with only spaces and tabs) mark the end of a paragraph.
6
+
7
+ * Example statement
8
+
9
+ ```
10
+ For example,
11
+ if I write like this, these lines
12
+ will be formatted as one paragraph.
13
+ ```
14
+
15
+ * Example output
16
+
17
+ <p>For example,
18
+ if I write like this, these lines
19
+ will be formatted as one paragraph.</p>
20
+
21
+ # Links
22
+
23
+ ## [WikiNames](WikiNames)
24
+
25
+ [WikiNames](WikiNames) are comprised of two or more words put together; each word begins with an uppercase letter, and is followed by at least one lowercase letter or number.
26
+
27
+ Words in which this condition is met become a [WikiName](WikiName), and a link is automatically attached.
28
+
29
+ * Example statement
30
+
31
+ ```
32
+ WikiName - WikiName
33
+ HogeRule1 - WikiName
34
+ NOTWIKINAME - All of the letters are uppercase, so this is not a WikiName
35
+ WikiNAME - All of the letters in NAME are uppercase, so this is not a WikiName
36
+ fooWikiName - This begins with "foo", which is in all lowercase, so this is not a WikiName
37
+ ```
38
+
39
+ * Example output
40
+
41
+ <ul>
42
+ <li><ul>
43
+ <li><a href="WikiName">WikiName</a> - <a href="WikiName">WikiName</a></li>
44
+ <li><a href="HogeRule1">HogeRule1</a> - <a href="WikiName">WikiName</a></li>
45
+ <li>NOTWIKINAME - All of the letters are uppercase, so this is not a <a href="WikiName">WikiName</a></li>
46
+ <li>WikiNAME - All of the letters in NAME are uppercase, so this is not a <a href="WikiName">WikiName</a></li>
47
+ <li>fooWikiName - This begins with "foo", which is in all lowercase, so this is not a <a href="WikiName">WikiName</a></li>
48
+ </ul></li>
49
+ </ul>
50
+
51
+ You can disable an auto [WikiName](WikiName) link by putting _^_ to the [WikiName](WikiName).
52
+
53
+ * Example statement
54
+
55
+ ```
56
+ WikiName - WikiName
57
+ ^WikiName - Disable WikiName link
58
+ ```
59
+
60
+ * Example output
61
+
62
+ <ul>
63
+ <li><ul>
64
+ <li><a href="WikiName">WikiName</a> - <a href="WikiName">WikiName</a></li>
65
+ <li>WikiName - Disable <a href="WikiName">WikiName</a> link</li>
66
+ </ul></li>
67
+ </ul>
68
+
69
+ ## Linking to other Wiki pages
70
+
71
+ If a page name is surrounded with two pairs of brackets, it becomes a link to that page.
72
+
73
+ * Example statement
74
+
75
+ ```
76
+ For example, if you write [[TextFormattingRules]], it becomes a link to that page.
77
+ ```
78
+
79
+ * Example output
80
+
81
+ <p>For example, if you write <a href="TextFormattingRules">TextFormattingRules</a>, it becomes a link to that page.</p>
82
+
83
+ ## Linking to an arbitrary URL
84
+
85
+ If a phrase and URL, separated by a vertical line, are surrounded with two pairs of brackets, it becomes a link to an arbitrary URL.
86
+
87
+ * Example statement
88
+
89
+ ```
90
+ Links like [[Yahoo!|http://www.yahoo.com/]] are also possible.
91
+ ```
92
+
93
+ * Example output
94
+
95
+ <p>Links like <a href="http://www.yahoo.com/">Yahoo!</a> are also possible.</p>
96
+
97
+ Text in a paragraph that looks like a URL will automatically become a link.
98
+
99
+ * Example statement
100
+
101
+ ```
102
+ Hiki's home page is http://hikiwiki.org/en/ (English).
103
+ ```
104
+
105
+ * Example output
106
+
107
+ <p>Hiki's home page is <a href="http://hikiwiki.org/en/">http://hikiwiki.org/en/</a> (English).</p>
108
+
109
+ In this case, if the URL ends with jpg., .jpeg, .png, or .gif, the image is displayed on the page.
110
+
111
+ * Example statement
112
+
113
+ ```
114
+ http://jp.rubyist.net/theme/clover/clover_h1.png
115
+ ```
116
+
117
+ * Example output
118
+
119
+ <p><img src="http://jp.rubyist.net/theme/clover/clover_h1.png" alt="clover_h1.png"></p>
120
+
121
+ #Preformatted text
122
+
123
+ Lines beginning with spaces or tabs will be treated as preformatted text.
124
+
125
+ * Example output
126
+
127
+ <pre>require 'cgi'
128
+
129
+ cgi = CGI::new
130
+ cgi.header
131
+
132
+ puts &lt;&lt;EOS
133
+ &lt;html&gt;
134
+ &lt;head&gt;
135
+ &lt;title&gt;Hello!&lt;/title&gt;
136
+ &lt;/head&gt;
137
+ &lt;body&gt;
138
+ &lt;p&gt;Hello!&lt;/p&gt;
139
+ &lt;/body&gt;
140
+ &lt;/html&gt;
141
+ EOS</pre>
142
+
143
+ # Text decoration
144
+
145
+ Text surrounded by sets of two single quotes ('') is emphasised.
146
+
147
+ Text surrounded by sets of three single quotes (''') is strongly emphasised.
148
+
149
+ Text surrounded by sets of double equal signs (===) is struck out.
150
+
151
+ Text surrounded by sets of double backquotes (``) is inline literal.
152
+
153
+ * Example statement
154
+
155
+ ```
156
+ If you write like this, it becomes ''emphasised''.
157
+ And if you write like this, it becomes '''strongly emphasised'''.
158
+ ==This is dull, but== And struck-out text is supported, too!
159
+ If you write like this, it becomes ``monospaced text``.
160
+ ```
161
+
162
+ * Example output
163
+
164
+ <p>If you write like this, it becomes <em>emphasised</em>.
165
+ And if you write like this, it becomes <strong>strongly emphasised</strong>.
166
+ <del>This is dull, but</del> And struck-out text is supported, too!
167
+ If you write like this, it becomes <tt>monospaced text</tt>.</p>
168
+
169
+ # Headings
170
+
171
+ Lines with exclamation marks at the beginning become headings.
172
+
173
+ One can use up to six exclamation marks; they will be converted to \<h1\> to \<h6\> tags.
174
+
175
+ * Example statement
176
+
177
+ ```
178
+ !Heading1
179
+ !!Heading2
180
+ !!!Heading3
181
+ !!!!Heading4
182
+ !!!!!Heading5
183
+ ```
184
+
185
+ * Example output
186
+
187
+ <h1>Heading1</h1>
188
+ <h2>Heading2</h2>
189
+ <h3>Heading3</h3>
190
+ <h4>Heading4</h4>
191
+ <h5>Heading5</h5>
192
+
193
+ # Horizontal lines
194
+
195
+ Four hyphens at the beginning of the line (----) become a horizontal rule.
196
+
197
+ * Example statement
198
+
199
+ ```
200
+ A B C D E
201
+ ----
202
+ F G H I J
203
+ ```
204
+
205
+ * Example output
206
+
207
+ <p>A B C D E</p>
208
+ <hr>
209
+ <p>F G H I J</p>
210
+
211
+ # Lists
212
+
213
+ Lines beginning with asterisks become list items.
214
+
215
+ It is possible to use up to three asterisks; it is also possible to create nested lists.
216
+
217
+ Lines beginning with a # become numbered lists.
218
+
219
+ * Example statement
220
+
221
+ ```
222
+ *Item 1
223
+ **Item 1.1
224
+ **Item 1.2
225
+ ***Item 1.2.1
226
+ ***Item 1.2.2
227
+ ***Item 1.2.3
228
+ **Item 1.3
229
+ **Item 1.4
230
+ *Item 2
231
+ ```
232
+
233
+ ```
234
+ #Item 1
235
+ #Item 2
236
+ ##Item 2.1
237
+ ##Item 2.2
238
+ ##Item 2.3
239
+ #Item 3
240
+ ##Item 3.1
241
+ ###Item 3.1.1
242
+ ###Item 3.1.2
243
+ ```
244
+
245
+ * Example output
246
+
247
+ <ul>
248
+ <li>Item 1<ul>
249
+ <li>Item 1.1</li>
250
+ <li>Item 1.2<ul>
251
+ <li>Item 1.2.1</li>
252
+ <li>Item 1.2.2</li>
253
+ <li>Item 1.2.3</li>
254
+ </ul></li>
255
+ <li>Item 1.3</li>
256
+ <li>Item 1.4</li>
257
+ </ul></li>
258
+ <li>Item 2</li>
259
+ </ul>
260
+ <ol>
261
+ <li>Item 1</li>
262
+ <li>Item 2<ol>
263
+ <li>Item 2.1</li>
264
+ <li>Item 2.2</li>
265
+ <li>Item 2.3</li>
266
+ </ol></li>
267
+ <li>Item 3<ol>
268
+ <li>Item 3.1<ol>
269
+ <li>Item 3.1.1</li>
270
+ <li>Item 3.1.2</li>
271
+ </ol></li>
272
+ </ol></li>
273
+ </ol>
274
+
275
+ # Quotations
276
+
277
+ Lines beginning with two double quotes become quotations.
278
+
279
+ * Example statement
280
+
281
+ ```
282
+ ""This is a quotation.
283
+ ""This is another quote.
284
+ ""This is a continued quote. When there are consecutive quotations,
285
+ ""they are displayed as one quote,
286
+ ""like this.
287
+ ```
288
+
289
+ * Example output
290
+
291
+ <blockquote><p>This is a quotation.
292
+ This is another quote.
293
+ This is a continued quote. When there are consecutive quotations,
294
+ they are displayed as one quote,
295
+ like this.</p>
296
+ </blockquote>
297
+
298
+ # Definitions
299
+
300
+ Lines beginning with a colon and have a phrase and explanation separated by another colon will become a definition.
301
+
302
+ * Example statement
303
+
304
+ ```
305
+ :ringo:apple
306
+ :gorira:gorilla
307
+ :rakuda:camel
308
+ ```
309
+
310
+ * Example output
311
+
312
+ <dl>
313
+ <dt>ringo</dt>
314
+ <dd>apple
315
+ </dd>
316
+ <dt>gorira</dt>
317
+ <dd>gorilla
318
+ </dd>
319
+ <dt>rakuda</dt>
320
+ <dd>camel
321
+ </dd>
322
+ </dl>
323
+
324
+ # Tables
325
+
326
+ Tables begin with two vertical bars.
327
+
328
+ Leading `!' in a cell means that it is a heading cell.
329
+
330
+ To concatenate columns or rows, put `\>'(columns) or `^'(rows) at head of
331
+ the cell.
332
+
333
+ * Example statement
334
+
335
+ ```
336
+ ||!row heading \ column heading||!column A||!column B||!column C||!>column D-E (horizontal concatenation)
337
+ ||!row 1||A1||B1||^C1-C2 (vertical concatenation)||D1||E1
338
+ ||!row 2||A2||B2||^>D2-E2-D3-E3 (vertical and horizontal concatenation)
339
+ ||!row 3||>>A3-C3 (horizontal concatenation)
340
+ ```
341
+
342
+ * Example output
343
+
344
+ <table border="1">
345
+ <tr><th>row heading \ column heading</th><th>column A</th><th>column B</th><th>column C</th><th colspan="2">column D-E (horizontal concatenation)
346
+ </th></tr>
347
+ <tr><th>row 1</th><td>A1</td><td>B1</td><td rowspan="2">C1-C2 (vertical concatenation)</td><td>D1</td><td>E1
348
+ </td></tr>
349
+ <tr><th>row 2</th><td>A2</td><td>B2</td><td rowspan="2" colspan="2">D2-E2-D3-E3 (vertical and horizontal concatenation)
350
+ </td></tr>
351
+ <tr><th>row 3</th><td colspan="3">A3-C3 (horizontal concatenation)
352
+ </td></tr>
353
+ </table>
354
+
355
+ # Comments
356
+
357
+ Lines starting with `//' becomes a comment line.
358
+ Comment lines is not outputted.
359
+
360
+ * Example statement
361
+
362
+ ```
363
+ // This is a comment line.
364
+ ```
365
+
366
+ * Example output (not displayed)
367
+
368
+ #Plugins
369
+
370
+ One can use a plugin by surrounding text with two pairs of brackets.
371
+ Multiple lines parameter is supported.
372
+ When a line contains plugin only, it becomes a block plugin,
373
+ which is not surrounded by \<p\> ... \</p\>.
374
+
375
+ * Example statement
376
+
377
+ ```
378
+ {{recent(3)}}
379
+ ```
380
+
381
+ * Example statement of multiple lines
382
+
383
+ ```
384
+ {{pre('
385
+ ...
386
+ ')}}
387
+ ```
388
+
data/bin/hikidoc CHANGED
@@ -16,10 +16,14 @@ HTML_TEMPLATE = <<EOS
16
16
  </html>
17
17
  EOS
18
18
 
19
+ def usage
20
+ "Usage: #$0 [OPTIONS] FILE"
21
+ end
22
+
19
23
  options = {}
20
24
  format_options = {}
21
25
  ARGV.options do |opts|
22
- opts.banner = "Usage: #$0 [OPTIONS] FILE"
26
+ opts.banner = usage
23
27
 
24
28
  opts.on('-f', '--fragment',
25
29
  'Output HTML fragments only') do
@@ -42,7 +46,7 @@ when 0
42
46
  when 1
43
47
  title, text = ARGV[0], File.read(ARGV[0])
44
48
  else
45
- usage
49
+ abort ARGV.options.help
46
50
  end
47
51
 
48
52
  body = HikiDoc.to_html(text, format_options)
data/hikidoc.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers.}
12
12
  spec.summary = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML (or XHTML).}
13
13
  spec.homepage = "https://github.com/hiki/hikidoc"
14
- spec.license = "MIT"
14
+ spec.license = "BSD-3-clause"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "test-unit"
23
24
  end
data/lib/hikidoc.rb CHANGED
@@ -38,7 +38,7 @@ rescue LoadError
38
38
  end
39
39
 
40
40
  class HikiDoc
41
- VERSION = "0.1.0"
41
+ VERSION = "0.1.1"
42
42
 
43
43
  class Error < StandardError
44
44
  end
@@ -96,7 +96,7 @@ class HikiDoc
96
96
 
97
97
  def escape_plugin_blocks(text)
98
98
  s = StringScanner.new(text)
99
- buf = ""
99
+ buf = +""
100
100
  @plugin_blocks = []
101
101
  while chunk = s.scan_until(/\{\{/)
102
102
  chunk[-2, 2] = ""
@@ -136,7 +136,7 @@ class HikiDoc
136
136
 
137
137
  def extract_plugin_block(s)
138
138
  pos = s.pos
139
- buf = ""
139
+ buf = +""
140
140
  while chunk = s.scan_until(/\}\}/)
141
141
  buf << chunk
142
142
  buf.chomp!("}}")
@@ -400,22 +400,22 @@ class HikiDoc
400
400
  def compile_inline(str, buf = nil)
401
401
  buf ||= @output.container
402
402
  re = inline_syntax_re
403
- pending_str = nil
403
+ pending_str = ""
404
404
  while m = re.match(str)
405
405
  str = m.post_match
406
406
 
407
407
  link, uri, mod, wiki_name = m[1, 4]
408
- if wiki_name and wiki_name[0, 1] == "^"
409
- pending_str = m.pre_match + wiki_name[1..-1] + str
408
+ if wiki_name and wiki_name.start_with? "^"
409
+ pending_str += m.pre_match + wiki_name[1..-1]
410
410
  next
411
411
  end
412
412
 
413
413
  pre_str = "#{pending_str}#{m.pre_match}"
414
- pending_str = nil
414
+ pending_str = ""
415
415
  evaluate_plugin_block(pre_str, buf)
416
416
  compile_inline_markup(buf, link, uri, mod, wiki_name)
417
417
  end
418
- evaluate_plugin_block(pending_str || str, buf)
418
+ evaluate_plugin_block(pending_str + str, buf)
419
419
  buf
420
420
  end
421
421
 
@@ -565,7 +565,7 @@ class HikiDoc
565
565
  when :paragraph
566
566
  []
567
567
  else
568
- ""
568
+ +""
569
569
  end
570
570
  end
571
571
 
@@ -653,7 +653,7 @@ class HikiDoc
653
653
  end
654
654
 
655
655
  def tdattr(rs, cs)
656
- buf = ""
656
+ buf = +""
657
657
  buf << %Q( rowspan="#{rs}") if rs
658
658
  buf << %Q( colspan="#{cs}") if cs
659
659
  buf
data/test/hikidoc_test.rb CHANGED
@@ -301,6 +301,14 @@ TEST}}
301
301
  use_not_wiki_name: false)
302
302
  assert_convert("<p>foo WikiName bar</p>\n",
303
303
  "foo ^WikiName bar")
304
+ assert_convert("<p>WikiName - Disable <a href=\"WikiName\">WikiName</a> link</p>\n",
305
+ "^WikiName - Disable WikiName link")
306
+ assert_convert("<p><a href=\"WikiName\">WikiName</a> - Disable DisabledWikiName link</p>\n",
307
+ "WikiName - Disable ^DisabledWikiName link")
308
+ assert_convert("<p><a href=\"WikiName\">WikiName</a> - Disable <a href=\"WikiName\">WikiName</a> link</p>\n",
309
+ "WikiName - Disable WikiName link")
310
+ assert_convert("<p>DisabledWikiName - Disable DisabledWikiName link</p>\n",
311
+ "^DisabledWikiName - Disable ^DisabledWikiName link")
304
312
  end
305
313
 
306
314
  def test_use_wiki_name_option
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hikidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuhiko
8
8
  - SHIBATA Hiroshi
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
@@ -39,6 +38,20 @@ dependencies:
39
38
  - - ">="
40
39
  - !ruby/object:Gem::Version
41
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
42
55
  description: "'HikiDoc' is a text-to-HTML conversion tool for web writers."
43
56
  email:
44
57
  - kazuhiko@fdiary.net
@@ -48,6 +61,7 @@ executables:
48
61
  extensions: []
49
62
  extra_rdoc_files: []
50
63
  files:
64
+ - ".github/workflows/release.yaml"
51
65
  - ".gitignore"
52
66
  - ".travis.yml"
53
67
  - COPYING
@@ -56,18 +70,21 @@ files:
56
70
  - NEWS.ja
57
71
  - README
58
72
  - README.ja
73
+ - README.ja.md
74
+ - README.md
59
75
  - Rakefile
60
76
  - TextFormattingRules
61
77
  - TextFormattingRules.ja
78
+ - TextFormattingRules.ja.md
79
+ - TextFormattingRules.md
62
80
  - bin/hikidoc
63
81
  - hikidoc.gemspec
64
82
  - lib/hikidoc.rb
65
83
  - test/hikidoc_test.rb
66
84
  homepage: https://github.com/hiki/hikidoc
67
85
  licenses:
68
- - MIT
86
+ - BSD-3-clause
69
87
  metadata: {}
70
- post_install_message:
71
88
  rdoc_options: []
72
89
  require_paths:
73
90
  - lib
@@ -82,13 +99,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
99
  - !ruby/object:Gem::Version
83
100
  version: '0'
84
101
  requirements: []
85
- rubyforge_project:
86
- rubygems_version: 2.2.2
87
- signing_key:
102
+ rubygems_version: 3.6.9
88
103
  specification_version: 4
89
104
  summary: "'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows
90
105
  you to write using an easy-to-read, easy-to-write plain text format, then convert
91
106
  it to structurally valid HTML (or XHTML)."
92
107
  test_files:
93
108
  - test/hikidoc_test.rb
94
- has_rdoc: