wikitext 1.3.2 → 1.4.0

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.
@@ -1,78 +0,0 @@
1
- # Copyright 2007-2009 Wincent Colaiuta
2
- # This program is free software: you can redistribute it and/or modify
3
- # it under the terms of the GNU General Public License as published by
4
- # the Free Software Foundation, either version 3 of the License, or
5
- # (at your option) any later version.
6
- #
7
- # This program is distributed in the hope that it will be useful,
8
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- # GNU General Public License for more details.
11
- #
12
- # You should have received a copy of the GNU General Public License
13
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
14
-
15
- require 'pathname'
16
- require 'rubygems'
17
- require 'spec'
18
-
19
- # allow indenting of multiline spec data for better readability
20
- # but must dedent it before actually doing the comparison
21
- def dedent spaces, string = nil
22
- if spaces.kind_of? String
23
- if not string.nil?
24
- raise 'When first argument is a String, second argument must be nil'
25
- else
26
- # default use: single String parameter, dedent by 6
27
- string = spaces
28
- spaces = 6
29
- end
30
- elsif spaces.kind_of? Integer
31
- if string.nil? or not string.kind_of?(String)
32
- raise 'When first argument is a number, second must be a String'
33
- end
34
- else
35
- raise 'Invalid argument'
36
- end
37
- string.each do |line|
38
- if not line =~ /\A {#{spaces.to_i}}/
39
- raise "Underlength indent for line: #{line.inspect}"
40
- end
41
- end
42
- string.gsub /^ {#{spaces.to_i}}/, ''
43
- end
44
-
45
- module Wikitext
46
- if not const_defined? 'BASEDIR'
47
- # prepend the local "ext" directory to search path if not already present
48
- BASEDIR = Pathname.new(__FILE__).dirname + '..'
49
- extdir = (BASEDIR + 'ext').realpath
50
- libdir = (BASEDIR + 'lib').realpath
51
- normalized = $:.collect { |path| Pathname.new(path).realpath rescue path }
52
- [libdir, extdir].each { |d| $:.unshift(d) unless normalized.include?(d) }
53
- end
54
- end # module Wikitext
55
-
56
- module UTF8
57
- if not const_defined? 'Invalid'
58
- module Invalid
59
- TWO_BYTES_MISSING_SECOND_BYTE = [0b11011111].pack('C*')
60
- TWO_BYTES_MALFORMED_SECOND_BYTE = [0b11011111, 0b00001111].pack('C*') # should be 10......
61
- OVERLONG = [0b11000000, 0b10000000].pack('C*') # lead byte is 110..... but code point is <= 127
62
- OVERLONG_ALT = [0b11000001, 0b10000000].pack('C*') # lead byte is 110..... but code point is <= 127
63
- THREE_BYTES_MISSING_SECOND_BYTE = [0b11100000].pack('C*')
64
- THREE_BYTES_MISSING_THIRD_BYTE = [0b11100000, 0b10000000].pack('C*')
65
- THREE_BYTES_MALFORMED_SECOND_BYTE = [0b11100000, 0b00001111, 0b10000000].pack('C*') # should be 10......
66
- THREE_BYTES_MALFORMED_THIRD_BYTE = [0b11100000, 0b10000000, 0b00001111].pack('C*') # should be 10......
67
- FOUR_BYTES_MISSING_SECOND_BYTE = [0b11110000].pack('C*')
68
- FOUR_BYTES_MISSING_THIRD_BYTE = [0b11110000, 0x10111111].pack('C*')
69
- FOUR_BYTES_MISSING_FOURTH_BYTE = [0b11110000, 0x10111111, 0x10111111].pack('C*')
70
- FOUR_BYTES_ILLEGAL_FIRST_BYTE = [0b11110101, 0x10111111, 0x10111111, 0x10111111].pack('C*')
71
- FOUR_BYTES_ILLEGAL_FIRST_BYTE_ALT = [0b11110101, 0x10111111, 0x10111111, 0x10111111].pack('C*')
72
- FOUR_BYTES_ILLEGAL_FIRST_BYTE_ALT2 = [0b11110101, 0x10111111, 0x10111111, 0x10111111].pack('C*')
73
- UNEXPECTED_BYTE = [0b11111000].pack('C*')
74
- end # module Invalid
75
- end
76
- end # module UTF8
77
-
78
- require 'wikitext'