wikitext 1.9 → 1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/wikitext +102 -0
- data/lib/wikitext/version.rb +1 -1
- metadata +31 -29
data/bin/wikitext
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright 2008-2009 Wincent Colaiuta. All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
11
|
+
# and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
14
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
15
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
16
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
17
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
18
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
19
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
20
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
21
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
22
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
23
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
24
|
+
|
25
|
+
require File.join(File.dirname(__FILE__), '..', 'ext', 'wikitext')
|
26
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'wikitext', 'version')
|
27
|
+
|
28
|
+
module Wikitext
|
29
|
+
module Tool
|
30
|
+
INPUT_FILES = []
|
31
|
+
|
32
|
+
def self.interactive?
|
33
|
+
STDOUT.tty? && STDIN.tty? && INPUT_FILES.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.pretty_print tokens
|
37
|
+
tokens.each do |token|
|
38
|
+
puts <<-END
|
39
|
+
Token: type: #{token.token_type}
|
40
|
+
line: #{token.line_start}..#{token.line_stop} column: #{token.column_start}..#{token.column_stop}
|
41
|
+
pointer: #{token.start}..#{token.stop}
|
42
|
+
code_point: #{token.code_point}
|
43
|
+
string_value: #{token.string_value.inspect}
|
44
|
+
|
45
|
+
END
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
method = :parse
|
50
|
+
ARGV.each do |arg|
|
51
|
+
if arg =~ /\A--tok/
|
52
|
+
method = :tokenize
|
53
|
+
else
|
54
|
+
INPUT_FILES << arg
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if interactive?
|
59
|
+
begin
|
60
|
+
require 'highline'
|
61
|
+
rescue LoadError
|
62
|
+
require 'rubygems'
|
63
|
+
require 'highline'
|
64
|
+
end
|
65
|
+
puts "wikitext #{Wikitext::VERSION}"
|
66
|
+
highline = HighLine.new
|
67
|
+
end
|
68
|
+
|
69
|
+
parser = Parser.new
|
70
|
+
if INPUT_FILES.empty?
|
71
|
+
begin
|
72
|
+
while true
|
73
|
+
puts highline.color('(Ctrl+D to process, Ctrl+C to exit)>>', :bold) if interactive?
|
74
|
+
input = STDIN.read
|
75
|
+
puts '-' * highline.output_cols if interactive?
|
76
|
+
if method == :tokenize
|
77
|
+
pretty_print parser.tokenize(input)
|
78
|
+
else
|
79
|
+
puts parser.parse(input)
|
80
|
+
end
|
81
|
+
puts '-' * highline.output_cols if interactive?
|
82
|
+
exit unless interactive?
|
83
|
+
end
|
84
|
+
rescue Interrupt
|
85
|
+
end
|
86
|
+
else # we have INPUT_FILES
|
87
|
+
exit_status = 0
|
88
|
+
INPUT_FILES.each do |file|
|
89
|
+
begin
|
90
|
+
puts parser.parse(File.new(file).read)
|
91
|
+
rescue Errno::ENOENT
|
92
|
+
STDERR.puts "error: no such file or directory: #{file}"
|
93
|
+
exit_status |= 1
|
94
|
+
rescue Errno::EACCES
|
95
|
+
STDERR.puts "error: permission denied: #{file}"
|
96
|
+
exit_status |= 2
|
97
|
+
end
|
98
|
+
end
|
99
|
+
exit exit_status
|
100
|
+
end
|
101
|
+
end # module Tool
|
102
|
+
end # module Wikitext
|
data/lib/wikitext/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikitext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.10"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wincent Colaiuta
|
@@ -9,19 +9,41 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-01 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: Wikitext is a fast wikitext-to-HTML translator written in C
|
16
|
+
description: " Wikitext is a fast wikitext-to-HTML translator written in C.\n"
|
17
17
|
email: win@wincent.com
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- wikitext
|
20
20
|
extensions:
|
21
21
|
- ext/extconf.rb
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
+
- bin/wikitext
|
26
|
+
- ext/wikitext_ragel.c
|
27
|
+
- ext/extconf.rb
|
28
|
+
- ext/ary.c
|
29
|
+
- ext/parser.c
|
30
|
+
- ext/str.c
|
31
|
+
- ext/token.c
|
32
|
+
- ext/wikitext.c
|
33
|
+
- ext/ary.h
|
34
|
+
- ext/parser.h
|
35
|
+
- ext/ruby_compat.h
|
36
|
+
- ext/str.h
|
37
|
+
- ext/token.h
|
38
|
+
- ext/wikitext.h
|
39
|
+
- ext/wikitext_ragel.h
|
40
|
+
- ext/depend
|
41
|
+
- lib/wikitext/nil_class.rb
|
42
|
+
- lib/wikitext/parser.rb
|
43
|
+
- lib/wikitext/rails.rb
|
44
|
+
- lib/wikitext/string.rb
|
45
|
+
- lib/wikitext/version.rb
|
46
|
+
- rails/init.rb
|
25
47
|
- spec/autolinking_spec.rb
|
26
48
|
- spec/base_heading_level_spec.rb
|
27
49
|
- spec/blockquote_spec.rb
|
@@ -55,35 +77,15 @@ files:
|
|
55
77
|
- spec/strong_em_spec.rb
|
56
78
|
- spec/strong_spec.rb
|
57
79
|
- spec/tokenizing_spec.rb
|
58
|
-
- spec/trash
|
59
80
|
- spec/tt_spec.rb
|
60
81
|
- spec/ul_spec.rb
|
61
82
|
- spec/version_spec.rb
|
62
83
|
- spec/vim_formatter.rb
|
63
84
|
- spec/wikitext_spec.rb
|
64
|
-
- ext/wikitext_ragel.c
|
65
|
-
- ext/extconf.rb
|
66
|
-
- ext/ary.c
|
67
|
-
- ext/parser.c
|
68
|
-
- ext/str.c
|
69
|
-
- ext/token.c
|
70
|
-
- ext/wikitext.c
|
71
|
-
- ext/ary.h
|
72
|
-
- ext/parser.h
|
73
|
-
- ext/ruby_compat.h
|
74
|
-
- ext/str.h
|
75
|
-
- ext/token.h
|
76
|
-
- ext/wikitext.h
|
77
|
-
- ext/wikitext_ragel.h
|
78
|
-
- ext/depend
|
79
|
-
- lib/wikitext/nil_class.rb
|
80
|
-
- lib/wikitext/parser.rb
|
81
|
-
- lib/wikitext/rails.rb
|
82
|
-
- lib/wikitext/string.rb
|
83
|
-
- lib/wikitext/version.rb
|
84
|
-
- rails/init.rb
|
85
85
|
has_rdoc: true
|
86
86
|
homepage: http://wikitext.rubyforge.org/
|
87
|
+
licenses: []
|
88
|
+
|
87
89
|
post_install_message:
|
88
90
|
rdoc_options: []
|
89
91
|
|
@@ -105,9 +107,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
107
|
requirements: []
|
106
108
|
|
107
109
|
rubyforge_project: wikitext
|
108
|
-
rubygems_version: 1.3.
|
110
|
+
rubygems_version: 1.3.5
|
109
111
|
signing_key:
|
110
|
-
specification_version:
|
112
|
+
specification_version: 3
|
111
113
|
summary: Wikitext-to-HTML translator
|
112
114
|
test_files: []
|
113
115
|
|