mediacloth 0.0.3 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/README.md +36 -0
  2. data/lib/mediacloth/mediawikiast.rb +58 -1
  3. data/lib/mediacloth/mediawikihtmlgenerator.rb +229 -73
  4. data/lib/mediacloth/mediawikilexer.rb +1030 -656
  5. data/lib/mediacloth/mediawikilinkhandler.rb +89 -0
  6. data/lib/mediacloth/mediawikiparams.rb +1 -10
  7. data/lib/mediacloth/mediawikiparser.rb +939 -409
  8. data/lib/mediacloth/mediawikiparser.tab.rb +1357 -0
  9. data/lib/mediacloth/mediawikiparser.y +256 -52
  10. data/lib/mediacloth/mediawikisignedwikigenerator.rb +42 -0
  11. data/lib/mediacloth/mediawikitemplatehandler.rb +8 -0
  12. data/lib/mediacloth/mediawikiwalker.rb +72 -1
  13. data/lib/mediacloth.rb +33 -10
  14. data/test/data/ast1 +68 -0
  15. data/test/data/ast10 +196 -0
  16. data/test/data/ast11 +34 -0
  17. data/test/data/ast12 +39 -0
  18. data/test/data/ast13 +25 -0
  19. data/test/data/ast14 +13 -0
  20. data/test/data/ast15 +25 -0
  21. data/test/data/ast16 +17 -0
  22. data/test/data/ast17 +9 -0
  23. data/test/data/ast18 +21 -0
  24. data/test/data/ast19 +32 -0
  25. data/test/data/ast2 +4 -0
  26. data/test/data/ast20 +10 -0
  27. data/test/data/ast21 +27 -0
  28. data/test/data/ast22 +22 -0
  29. data/test/data/ast23 +5 -0
  30. data/test/data/ast3 +6 -0
  31. data/test/data/ast4 +122 -0
  32. data/test/data/ast5 +122 -0
  33. data/test/data/ast6 +22 -0
  34. data/test/data/ast7 +143 -0
  35. data/test/data/ast8 +3 -0
  36. data/test/data/ast9 +11 -0
  37. data/test/data/html1 +33 -5
  38. data/test/data/html10 +31 -27
  39. data/test/data/html11 +19 -0
  40. data/test/data/html12 +32 -0
  41. data/test/data/html13 +29 -0
  42. data/test/data/html14 +4 -0
  43. data/test/data/html15 +29 -0
  44. data/test/data/html16 +28 -0
  45. data/test/data/html17 +10 -0
  46. data/test/data/html18 +8 -0
  47. data/test/data/html19 +27 -0
  48. data/test/data/html2 +1 -1
  49. data/test/data/html20 +7 -0
  50. data/test/data/html21 +5 -0
  51. data/test/data/html22 +24 -0
  52. data/test/data/html23 +7 -0
  53. data/test/data/html3 +1 -1
  54. data/test/data/html4 +60 -11
  55. data/test/data/html5 +45 -6
  56. data/test/data/html6 +5 -5
  57. data/test/data/html7 +59 -1
  58. data/test/data/html8 +1 -1
  59. data/test/data/html9 +10 -2
  60. data/test/data/input1 +4 -0
  61. data/test/data/input11 +19 -0
  62. data/test/data/input12 +32 -0
  63. data/test/data/input13 +10 -0
  64. data/test/data/input14 +8 -0
  65. data/test/data/input15 +10 -0
  66. data/test/data/input16 +28 -0
  67. data/test/data/input17 +10 -0
  68. data/test/data/input18 +16 -0
  69. data/test/data/input19 +29 -0
  70. data/test/data/input20 +8 -0
  71. data/test/data/input21 +18 -0
  72. data/test/data/input22 +20 -0
  73. data/test/data/input23 +8 -0
  74. data/test/data/input4 +13 -1
  75. data/test/data/input5 +45 -4
  76. data/test/data/input7 +25 -1
  77. data/test/data/lex1 +17 -18
  78. data/test/data/lex10 +57 -87
  79. data/test/data/lex11 +18 -0
  80. data/test/data/lex12 +32 -0
  81. data/test/data/lex13 +3 -0
  82. data/test/data/lex14 +1 -0
  83. data/test/data/lex15 +3 -0
  84. data/test/data/lex16 +27 -0
  85. data/test/data/lex17 +9 -0
  86. data/test/data/lex18 +4 -0
  87. data/test/data/lex19 +27 -0
  88. data/test/data/lex2 +2 -2
  89. data/test/data/lex20 +7 -0
  90. data/test/data/lex21 +4 -0
  91. data/test/data/lex22 +3 -0
  92. data/test/data/lex23 +7 -0
  93. data/test/data/lex3 +1 -1
  94. data/test/data/lex4 +35 -29
  95. data/test/data/lex5 +57 -18
  96. data/test/data/lex6 +7 -7
  97. data/test/data/lex7 +42 -18
  98. data/test/data/lex8 +1 -1
  99. data/test/data/lex9 +6 -6
  100. data/test/dataproducers/ast.rb +24 -0
  101. data/test/dataproducers/html.rb +11 -12
  102. data/test/dataproducers/lex.rb +9 -4
  103. data/test/debugwalker.rb +25 -11
  104. data/test/htmlgenerator.rb +170 -13
  105. data/test/lexer.rb +626 -83
  106. data/test/linkhandler.rb +39 -0
  107. data/test/parser.rb +176 -9
  108. data/test/signedwikigenerator.rb +113 -0
  109. metadata +158 -79
  110. data/README +0 -37
  111. data/lib/mediacloth/mediawikilexer.rb~ +0 -491
  112. data/lib/mediacloth/mediawikiparser.y~ +0 -210
  113. data/test/data/result1 +0 -48
  114. data/test/dataproducers/html.rb~ +0 -24
  115. 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&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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> &lt;&lt; <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>
@@ -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)
@@ -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)