mediacloth 0.0.3 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -0
- data/lib/mediacloth/mediawikiast.rb +58 -1
- data/lib/mediacloth/mediawikihtmlgenerator.rb +229 -73
- data/lib/mediacloth/mediawikilexer.rb +1030 -656
- data/lib/mediacloth/mediawikilinkhandler.rb +89 -0
- data/lib/mediacloth/mediawikiparams.rb +1 -10
- data/lib/mediacloth/mediawikiparser.rb +939 -409
- data/lib/mediacloth/mediawikiparser.tab.rb +1357 -0
- data/lib/mediacloth/mediawikiparser.y +256 -52
- data/lib/mediacloth/mediawikisignedwikigenerator.rb +42 -0
- data/lib/mediacloth/mediawikitemplatehandler.rb +8 -0
- data/lib/mediacloth/mediawikiwalker.rb +72 -1
- data/lib/mediacloth.rb +33 -10
- data/test/data/ast1 +68 -0
- data/test/data/ast10 +196 -0
- data/test/data/ast11 +34 -0
- data/test/data/ast12 +39 -0
- data/test/data/ast13 +25 -0
- data/test/data/ast14 +13 -0
- data/test/data/ast15 +25 -0
- data/test/data/ast16 +17 -0
- data/test/data/ast17 +9 -0
- data/test/data/ast18 +21 -0
- data/test/data/ast19 +32 -0
- data/test/data/ast2 +4 -0
- data/test/data/ast20 +10 -0
- data/test/data/ast21 +27 -0
- data/test/data/ast22 +22 -0
- data/test/data/ast23 +5 -0
- data/test/data/ast3 +6 -0
- data/test/data/ast4 +122 -0
- data/test/data/ast5 +122 -0
- data/test/data/ast6 +22 -0
- data/test/data/ast7 +143 -0
- data/test/data/ast8 +3 -0
- data/test/data/ast9 +11 -0
- data/test/data/html1 +33 -5
- data/test/data/html10 +31 -27
- data/test/data/html11 +19 -0
- data/test/data/html12 +32 -0
- data/test/data/html13 +29 -0
- data/test/data/html14 +4 -0
- data/test/data/html15 +29 -0
- data/test/data/html16 +28 -0
- data/test/data/html17 +10 -0
- data/test/data/html18 +8 -0
- data/test/data/html19 +27 -0
- data/test/data/html2 +1 -1
- data/test/data/html20 +7 -0
- data/test/data/html21 +5 -0
- data/test/data/html22 +24 -0
- data/test/data/html23 +7 -0
- data/test/data/html3 +1 -1
- data/test/data/html4 +60 -11
- data/test/data/html5 +45 -6
- data/test/data/html6 +5 -5
- data/test/data/html7 +59 -1
- data/test/data/html8 +1 -1
- data/test/data/html9 +10 -2
- data/test/data/input1 +4 -0
- data/test/data/input11 +19 -0
- data/test/data/input12 +32 -0
- data/test/data/input13 +10 -0
- data/test/data/input14 +8 -0
- data/test/data/input15 +10 -0
- data/test/data/input16 +28 -0
- data/test/data/input17 +10 -0
- data/test/data/input18 +16 -0
- data/test/data/input19 +29 -0
- data/test/data/input20 +8 -0
- data/test/data/input21 +18 -0
- data/test/data/input22 +20 -0
- data/test/data/input23 +8 -0
- data/test/data/input4 +13 -1
- data/test/data/input5 +45 -4
- data/test/data/input7 +25 -1
- data/test/data/lex1 +17 -18
- data/test/data/lex10 +57 -87
- data/test/data/lex11 +18 -0
- data/test/data/lex12 +32 -0
- data/test/data/lex13 +3 -0
- data/test/data/lex14 +1 -0
- data/test/data/lex15 +3 -0
- data/test/data/lex16 +27 -0
- data/test/data/lex17 +9 -0
- data/test/data/lex18 +4 -0
- data/test/data/lex19 +27 -0
- data/test/data/lex2 +2 -2
- data/test/data/lex20 +7 -0
- data/test/data/lex21 +4 -0
- data/test/data/lex22 +3 -0
- data/test/data/lex23 +7 -0
- data/test/data/lex3 +1 -1
- data/test/data/lex4 +35 -29
- data/test/data/lex5 +57 -18
- data/test/data/lex6 +7 -7
- data/test/data/lex7 +42 -18
- data/test/data/lex8 +1 -1
- data/test/data/lex9 +6 -6
- data/test/dataproducers/ast.rb +24 -0
- data/test/dataproducers/html.rb +11 -12
- data/test/dataproducers/lex.rb +9 -4
- data/test/debugwalker.rb +25 -11
- data/test/htmlgenerator.rb +170 -13
- data/test/lexer.rb +626 -83
- data/test/linkhandler.rb +39 -0
- data/test/parser.rb +176 -9
- data/test/signedwikigenerator.rb +113 -0
- metadata +158 -79
- data/README +0 -37
- data/lib/mediacloth/mediawikilexer.rb~ +0 -491
- data/lib/mediacloth/mediawikiparser.y~ +0 -210
- data/test/data/result1 +0 -48
- data/test/dataproducers/html.rb~ +0 -24
- data/test/dataproducers/lex.rb~ +0 -15
data/test/data/result1
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
<p>This is a simple text with <b>Bold text</b> and <i>Italic text</i> inside.
|
2
|
-
One paragraph can be written in several lines.
|
3
|
-
|
4
|
-
</p><p>Another paragraph starts after a blank line.
|
5
|
-
</p><p><br>
|
6
|
-
Another one.
|
7
|
-
</p><p>This is text with <a href="/wiki/index.php?title=Internal_Link&action=edit" class="new" title="Internal Link">Internal Link</a> and <a href="http://www.example.com" class="external text" title="http://www.example.com" rel="nofollow">external link</a>.
|
8
|
-
</p><p>We can have headlines:
|
9
|
-
</p><p><br>
|
10
|
-
</p>
|
11
|
-
<table id="toc" class="toc" summary="Contents"><tbody><tr><td><div id="toctitle"><h2>Contents</h2> <span class="toctoggle">[<a href="javascript:toggleToc()" class="internal" id="togglelink">hide</a>]</span></div>
|
12
|
-
|
13
|
-
<ul style="display: block;">
|
14
|
-
<li class="toclevel-1"><a href="#Headline1"><span class="tocnumber">1</span> <span class="toctext">Headline1</span></a>
|
15
|
-
<ul>
|
16
|
-
<li class="toclevel-2"><a href="#Headline2"><span class="tocnumber">1.1</span> <span class="toctext">Headline2</span></a>
|
17
|
-
<ul>
|
18
|
-
<li class="toclevel-3"><a href="#Headline3"><span class="tocnumber">1.1.1</span> <span class="toctext">Headline3</span></a>
|
19
|
-
<ul>
|
20
|
-
<li class="toclevel-4"><a href="#Headline4"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Headline4</span></a></li>
|
21
|
-
|
22
|
-
</ul>
|
23
|
-
</li>
|
24
|
-
</ul>
|
25
|
-
</li>
|
26
|
-
</ul>
|
27
|
-
</li>
|
28
|
-
</ul>
|
29
|
-
</td></tr></tbody></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
|
30
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=1" title="Edit section: Headline1">edit</a>]</div><a name="Headline1"></a><h1> Headline1 </h1>
|
31
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=2" title="Edit section: Headline2">edit</a>]</div><a name="Headline2"></a><h2> Headline2 </h2>
|
32
|
-
|
33
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=3" title="Edit section: Headline3">edit</a>]</div><a name="Headline3"></a><h3> Headline3 </h3>
|
34
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=4" title="Edit section: Headline4">edit</a>]</div><a name="Headline4"></a><h4> Headline4 </h4>
|
35
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=5" title="Edit section: Headline5">edit</a>]</div><a name="Headline5"></a><h5> Headline5 </h5>
|
36
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=6" title="Edit section: Headline6">edit</a>]</div><a name="Headline6"></a><h6> Headline6 </h6>
|
37
|
-
<div class="editsection" style="float: right; margin-left: 5px;">[<a href="/wiki/index.php?title=Test&action=edit&section=7" title="Edit section: = Headline7 =">edit</a>]</div><a name=".3D_Headline7_.3D"></a><h6>= Headline7 =</h6>
|
38
|
-
<pre>This is a preformatted <b> </b> << <i> </i> text
|
39
|
-
yes
|
40
|
-
|
41
|
-
|
42
|
-
</pre>
|
43
|
-
<hr>
|
44
|
-
<p>This is a text after the line.
|
45
|
-
</p>
|
46
|
-
<ul><li>foo
|
47
|
-
</li><li> foo2
|
48
|
-
</li></ul>
|
data/test/dataproducers/html.rb~
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'mediacloth/mediawikilexer'
|
2
|
-
require 'mediacloth/mediawikiparser'
|
3
|
-
require 'mediacloth/mediawikiparams'
|
4
|
-
require 'mediacloth/mediawikihtmlgenerator'
|
5
|
-
|
6
|
-
def produce(index)
|
7
|
-
file = File.new("../data/html#{index}", "w")
|
8
|
-
inputFile = File.new("../data/input#{index}", "r")
|
9
|
-
input = inputFile.read
|
10
|
-
|
11
|
-
parser = MediaWikiParser.new
|
12
|
-
parser.lexer = MediaWikiLexer.new
|
13
|
-
ast = parser.parse(input)
|
14
|
-
MediaWikiParams.instance.time = Time.mktime(2000, 1, 1, 1, 1, 1, 1)
|
15
|
-
generator = MediaWikiHTMLGenerator.new
|
16
|
-
generator.parse(ast)
|
17
|
-
|
18
|
-
# puts generator.html
|
19
|
-
file.write(generator.html)
|
20
|
-
file.close
|
21
|
-
end
|
22
|
-
|
23
|
-
# (3..5).each { |i| produce(i) }
|
24
|
-
produce(5)
|
data/test/dataproducers/lex.rb~
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'mediacloth/mediawikilexer'
|
2
|
-
|
3
|
-
def produce(index)
|
4
|
-
file = File.new("../data/lex#{index}", "w")
|
5
|
-
inputFile = File.new("../data/input#{index}", "r")
|
6
|
-
input = inputFile.read
|
7
|
-
|
8
|
-
lexer = MediaWikiLexer.new
|
9
|
-
tokens = lexer.tokenize(input)
|
10
|
-
file.write(tokens.to_s)
|
11
|
-
file.close
|
12
|
-
end
|
13
|
-
|
14
|
-
#1..5.each { |i| produce(1) }
|
15
|
-
produce(8)
|