wallyqs-org-ruby 0.6.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.
Files changed (123) hide show
  1. data/.bnsignore +18 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +36 -0
  5. data/History.txt +112 -0
  6. data/README.rdoc +67 -0
  7. data/Rakefile +33 -0
  8. data/TAGS +167 -0
  9. data/announcement.txt +24 -0
  10. data/bin/org-ruby +45 -0
  11. data/lib/org-ruby.rb +55 -0
  12. data/lib/org-ruby/headline.rb +110 -0
  13. data/lib/org-ruby/html_output_buffer.rb +273 -0
  14. data/lib/org-ruby/html_symbol_replace.rb +345 -0
  15. data/lib/org-ruby/line.rb +244 -0
  16. data/lib/org-ruby/output_buffer.rb +237 -0
  17. data/lib/org-ruby/parser.rb +366 -0
  18. data/lib/org-ruby/regexp_helper.rb +192 -0
  19. data/lib/org-ruby/textile_output_buffer.rb +102 -0
  20. data/lib/org-ruby/textile_symbol_replace.rb +346 -0
  21. data/lib/org-ruby/tilt.rb +29 -0
  22. data/org-ruby.gemspec +40 -0
  23. data/spec/data/freeform-example.org +113 -0
  24. data/spec/data/freeform.org +111 -0
  25. data/spec/data/hyp-planning.org +335 -0
  26. data/spec/data/remember.org +53 -0
  27. data/spec/headline_spec.rb +65 -0
  28. data/spec/html_examples/advanced-code.html +81 -0
  29. data/spec/html_examples/advanced-code.org +106 -0
  30. data/spec/html_examples/advanced-lists.html +31 -0
  31. data/spec/html_examples/advanced-lists.org +31 -0
  32. data/spec/html_examples/block_code.html +28 -0
  33. data/spec/html_examples/block_code.org +35 -0
  34. data/spec/html_examples/blockcomment.html +3 -0
  35. data/spec/html_examples/blockcomment.org +15 -0
  36. data/spec/html_examples/blockquote.html +7 -0
  37. data/spec/html_examples/blockquote.org +13 -0
  38. data/spec/html_examples/center.html +6 -0
  39. data/spec/html_examples/center.org +7 -0
  40. data/spec/html_examples/code-comment.html +18 -0
  41. data/spec/html_examples/code-comment.org +22 -0
  42. data/spec/html_examples/code-syntax.html +98 -0
  43. data/spec/html_examples/code-syntax.org +99 -0
  44. data/spec/html_examples/comment-trees.html +4 -0
  45. data/spec/html_examples/comment-trees.org +13 -0
  46. data/spec/html_examples/custom-seq-todo.html +15 -0
  47. data/spec/html_examples/custom-seq-todo.org +24 -0
  48. data/spec/html_examples/custom-todo.html +15 -0
  49. data/spec/html_examples/custom-todo.org +24 -0
  50. data/spec/html_examples/custom-typ-todo.html +15 -0
  51. data/spec/html_examples/custom-typ-todo.org +24 -0
  52. data/spec/html_examples/deflist.html +6 -0
  53. data/spec/html_examples/deflist.org +6 -0
  54. data/spec/html_examples/entities.html +4 -0
  55. data/spec/html_examples/entities.org +11 -0
  56. data/spec/html_examples/escape-pre.html +6 -0
  57. data/spec/html_examples/escape-pre.org +6 -0
  58. data/spec/html_examples/export-exclude-only.html +13 -0
  59. data/spec/html_examples/export-exclude-only.org +81 -0
  60. data/spec/html_examples/export-keywords.html +4 -0
  61. data/spec/html_examples/export-keywords.org +18 -0
  62. data/spec/html_examples/export-tags.html +8 -0
  63. data/spec/html_examples/export-tags.org +82 -0
  64. data/spec/html_examples/export-title.html +2 -0
  65. data/spec/html_examples/export-title.org +4 -0
  66. data/spec/html_examples/footnotes.html +10 -0
  67. data/spec/html_examples/footnotes.org +7 -0
  68. data/spec/html_examples/html-literal.html +2 -0
  69. data/spec/html_examples/html-literal.org +6 -0
  70. data/spec/html_examples/inline-formatting.html +20 -0
  71. data/spec/html_examples/inline-formatting.org +33 -0
  72. data/spec/html_examples/inline-images.html +10 -0
  73. data/spec/html_examples/inline-images.org +15 -0
  74. data/spec/html_examples/link-features.html +8 -0
  75. data/spec/html_examples/link-features.org +19 -0
  76. data/spec/html_examples/lists.html +23 -0
  77. data/spec/html_examples/lists.org +47 -0
  78. data/spec/html_examples/metadata-comment.html +27 -0
  79. data/spec/html_examples/metadata-comment.org +30 -0
  80. data/spec/html_examples/only-list.html +5 -0
  81. data/spec/html_examples/only-list.org +3 -0
  82. data/spec/html_examples/only-table.html +6 -0
  83. data/spec/html_examples/only-table.org +5 -0
  84. data/spec/html_examples/skip-header.html +3 -0
  85. data/spec/html_examples/skip-header.org +28 -0
  86. data/spec/html_examples/skip-table.html +4 -0
  87. data/spec/html_examples/skip-table.org +19 -0
  88. data/spec/html_examples/subsupscript-nil.html +3 -0
  89. data/spec/html_examples/subsupscript-nil.org +6 -0
  90. data/spec/html_examples/subsupscript.html +3 -0
  91. data/spec/html_examples/subsupscript.org +5 -0
  92. data/spec/html_examples/tables.html +35 -0
  93. data/spec/html_examples/tables.org +50 -0
  94. data/spec/html_examples/text.html +2 -0
  95. data/spec/html_examples/text.org +16 -0
  96. data/spec/line_spec.rb +155 -0
  97. data/spec/output_buffer_spec.rb +19 -0
  98. data/spec/parser_spec.rb +152 -0
  99. data/spec/regexp_helper_spec.rb +57 -0
  100. data/spec/spec_helper.rb +20 -0
  101. data/spec/textile_examples/block_code.org +35 -0
  102. data/spec/textile_examples/block_code.textile +29 -0
  103. data/spec/textile_examples/blockquote.org +13 -0
  104. data/spec/textile_examples/blockquote.textile +11 -0
  105. data/spec/textile_examples/center.org +7 -0
  106. data/spec/textile_examples/center.textile +6 -0
  107. data/spec/textile_examples/footnotes.org +7 -0
  108. data/spec/textile_examples/footnotes.textile +8 -0
  109. data/spec/textile_examples/keywords.org +13 -0
  110. data/spec/textile_examples/keywords.textile +11 -0
  111. data/spec/textile_examples/links.org +11 -0
  112. data/spec/textile_examples/links.textile +10 -0
  113. data/spec/textile_examples/lists.org +36 -0
  114. data/spec/textile_examples/lists.textile +20 -0
  115. data/spec/textile_examples/single-space-plain-list.org +13 -0
  116. data/spec/textile_examples/single-space-plain-list.textile +10 -0
  117. data/spec/textile_examples/tables.org +50 -0
  118. data/spec/textile_examples/tables.textile +40 -0
  119. data/spec/textile_output_buffer_spec.rb +21 -0
  120. data/tasks/test_case.rake +49 -0
  121. data/test/test_orgmode_parser.rb +0 -0
  122. data/util/gen-special-replace.el +37 -0
  123. metadata +244 -0
@@ -0,0 +1,345 @@
1
+ # Autogenerated by util/gen-special-replace.el
2
+
3
+ module Orgmode
4
+ def Orgmode.special_symbols_to_html(str)
5
+ str.gsub!(/\\Agrave((\{\})|(\s|$))/, "À\\3")
6
+ str.gsub!(/\\agrave((\{\})|(\s|$))/, "à\\3")
7
+ str.gsub!(/\\Aacute((\{\})|(\s|$))/, "Á\\3")
8
+ str.gsub!(/\\aacute((\{\})|(\s|$))/, "á\\3")
9
+ str.gsub!(/\\Acirc((\{\})|(\s|$))/, "Â\\3")
10
+ str.gsub!(/\\acirc((\{\})|(\s|$))/, "â\\3")
11
+ str.gsub!(/\\Atilde((\{\})|(\s|$))/, "Ã\\3")
12
+ str.gsub!(/\\atilde((\{\})|(\s|$))/, "ã\\3")
13
+ str.gsub!(/\\Auml((\{\})|(\s|$))/, "Ä\\3")
14
+ str.gsub!(/\\auml((\{\})|(\s|$))/, "ä\\3")
15
+ str.gsub!(/\\Aring((\{\})|(\s|$))/, "Å\\3")
16
+ str.gsub!(/\\AA((\{\})|(\s|$))/, "Å\\3")
17
+ str.gsub!(/\\aring((\{\})|(\s|$))/, "å\\3")
18
+ str.gsub!(/\\AElig((\{\})|(\s|$))/, "Æ\\3")
19
+ str.gsub!(/\\aelig((\{\})|(\s|$))/, "æ\\3")
20
+ str.gsub!(/\\Ccedil((\{\})|(\s|$))/, "Ç\\3")
21
+ str.gsub!(/\\ccedil((\{\})|(\s|$))/, "ç\\3")
22
+ str.gsub!(/\\Egrave((\{\})|(\s|$))/, "È\\3")
23
+ str.gsub!(/\\egrave((\{\})|(\s|$))/, "è\\3")
24
+ str.gsub!(/\\Eacute((\{\})|(\s|$))/, "É\\3")
25
+ str.gsub!(/\\eacute((\{\})|(\s|$))/, "é\\3")
26
+ str.gsub!(/\\Ecirc((\{\})|(\s|$))/, "Ê\\3")
27
+ str.gsub!(/\\ecirc((\{\})|(\s|$))/, "ê\\3")
28
+ str.gsub!(/\\Euml((\{\})|(\s|$))/, "Ë\\3")
29
+ str.gsub!(/\\euml((\{\})|(\s|$))/, "ë\\3")
30
+ str.gsub!(/\\Igrave((\{\})|(\s|$))/, "Ì\\3")
31
+ str.gsub!(/\\igrave((\{\})|(\s|$))/, "ì\\3")
32
+ str.gsub!(/\\Iacute((\{\})|(\s|$))/, "Í\\3")
33
+ str.gsub!(/\\iacute((\{\})|(\s|$))/, "í\\3")
34
+ str.gsub!(/\\Icirc((\{\})|(\s|$))/, "Î\\3")
35
+ str.gsub!(/\\icirc((\{\})|(\s|$))/, "î\\3")
36
+ str.gsub!(/\\Iuml((\{\})|(\s|$))/, "Ï\\3")
37
+ str.gsub!(/\\iuml((\{\})|(\s|$))/, "ï\\3")
38
+ str.gsub!(/\\Ntilde((\{\})|(\s|$))/, "Ñ\\3")
39
+ str.gsub!(/\\ntilde((\{\})|(\s|$))/, "ñ\\3")
40
+ str.gsub!(/\\Ograve((\{\})|(\s|$))/, "Ò\\3")
41
+ str.gsub!(/\\ograve((\{\})|(\s|$))/, "ò\\3")
42
+ str.gsub!(/\\Oacute((\{\})|(\s|$))/, "Ó\\3")
43
+ str.gsub!(/\\oacute((\{\})|(\s|$))/, "ó\\3")
44
+ str.gsub!(/\\Ocirc((\{\})|(\s|$))/, "Ô\\3")
45
+ str.gsub!(/\\ocirc((\{\})|(\s|$))/, "ô\\3")
46
+ str.gsub!(/\\Otilde((\{\})|(\s|$))/, "Õ\\3")
47
+ str.gsub!(/\\otilde((\{\})|(\s|$))/, "õ\\3")
48
+ str.gsub!(/\\Ouml((\{\})|(\s|$))/, "Ö\\3")
49
+ str.gsub!(/\\ouml((\{\})|(\s|$))/, "ö\\3")
50
+ str.gsub!(/\\Oslash((\{\})|(\s|$))/, "Ø\\3")
51
+ str.gsub!(/\\oslash((\{\})|(\s|$))/, "ø\\3")
52
+ str.gsub!(/\\OElig((\{\})|(\s|$))/, "Œ\\3")
53
+ str.gsub!(/\\oelig((\{\})|(\s|$))/, "œ\\3")
54
+ str.gsub!(/\\Scaron((\{\})|(\s|$))/, "Š\\3")
55
+ str.gsub!(/\\scaron((\{\})|(\s|$))/, "š\\3")
56
+ str.gsub!(/\\szlig((\{\})|(\s|$))/, "ß\\3")
57
+ str.gsub!(/\\Ugrave((\{\})|(\s|$))/, "Ù\\3")
58
+ str.gsub!(/\\ugrave((\{\})|(\s|$))/, "ù\\3")
59
+ str.gsub!(/\\Uacute((\{\})|(\s|$))/, "Ú\\3")
60
+ str.gsub!(/\\uacute((\{\})|(\s|$))/, "ú\\3")
61
+ str.gsub!(/\\Ucirc((\{\})|(\s|$))/, "Û\\3")
62
+ str.gsub!(/\\ucirc((\{\})|(\s|$))/, "û\\3")
63
+ str.gsub!(/\\Uuml((\{\})|(\s|$))/, "Ü\\3")
64
+ str.gsub!(/\\uuml((\{\})|(\s|$))/, "ü\\3")
65
+ str.gsub!(/\\Yacute((\{\})|(\s|$))/, "Ý\\3")
66
+ str.gsub!(/\\yacute((\{\})|(\s|$))/, "ý\\3")
67
+ str.gsub!(/\\Yuml((\{\})|(\s|$))/, "Ÿ\\3")
68
+ str.gsub!(/\\yuml((\{\})|(\s|$))/, "ÿ\\3")
69
+ str.gsub!(/\\fnof((\{\})|(\s|$))/, "ƒ\\3")
70
+ str.gsub!(/\\real((\{\})|(\s|$))/, "ℜ\\3")
71
+ str.gsub!(/\\image((\{\})|(\s|$))/, "ℑ\\3")
72
+ str.gsub!(/\\weierp((\{\})|(\s|$))/, "℘\\3")
73
+ str.gsub!(/\\Alpha((\{\})|(\s|$))/, "Α\\3")
74
+ str.gsub!(/\\alpha((\{\})|(\s|$))/, "α\\3")
75
+ str.gsub!(/\\Beta((\{\})|(\s|$))/, "Β\\3")
76
+ str.gsub!(/\\beta((\{\})|(\s|$))/, "β\\3")
77
+ str.gsub!(/\\Gamma((\{\})|(\s|$))/, "Γ\\3")
78
+ str.gsub!(/\\gamma((\{\})|(\s|$))/, "γ\\3")
79
+ str.gsub!(/\\Delta((\{\})|(\s|$))/, "Δ\\3")
80
+ str.gsub!(/\\delta((\{\})|(\s|$))/, "δ\\3")
81
+ str.gsub!(/\\Epsilon((\{\})|(\s|$))/, "Ε\\3")
82
+ str.gsub!(/\\epsilon((\{\})|(\s|$))/, "ε\\3")
83
+ str.gsub!(/\\varepsilon((\{\})|(\s|$))/, "ε\\3")
84
+ str.gsub!(/\\Zeta((\{\})|(\s|$))/, "Ζ\\3")
85
+ str.gsub!(/\\zeta((\{\})|(\s|$))/, "ζ\\3")
86
+ str.gsub!(/\\Eta((\{\})|(\s|$))/, "Η\\3")
87
+ str.gsub!(/\\eta((\{\})|(\s|$))/, "η\\3")
88
+ str.gsub!(/\\Theta((\{\})|(\s|$))/, "Θ\\3")
89
+ str.gsub!(/\\theta((\{\})|(\s|$))/, "θ\\3")
90
+ str.gsub!(/\\thetasym((\{\})|(\s|$))/, "ϑ\\3")
91
+ str.gsub!(/\\vartheta((\{\})|(\s|$))/, "ϑ\\3")
92
+ str.gsub!(/\\Iota((\{\})|(\s|$))/, "Ι\\3")
93
+ str.gsub!(/\\iota((\{\})|(\s|$))/, "ι\\3")
94
+ str.gsub!(/\\Kappa((\{\})|(\s|$))/, "Κ\\3")
95
+ str.gsub!(/\\kappa((\{\})|(\s|$))/, "κ\\3")
96
+ str.gsub!(/\\Lambda((\{\})|(\s|$))/, "Λ\\3")
97
+ str.gsub!(/\\lambda((\{\})|(\s|$))/, "λ\\3")
98
+ str.gsub!(/\\Mu((\{\})|(\s|$))/, "Μ\\3")
99
+ str.gsub!(/\\mu((\{\})|(\s|$))/, "μ\\3")
100
+ str.gsub!(/\\nu((\{\})|(\s|$))/, "ν\\3")
101
+ str.gsub!(/\\Nu((\{\})|(\s|$))/, "Ν\\3")
102
+ str.gsub!(/\\Xi((\{\})|(\s|$))/, "Ξ\\3")
103
+ str.gsub!(/\\xi((\{\})|(\s|$))/, "ξ\\3")
104
+ str.gsub!(/\\Omicron((\{\})|(\s|$))/, "Ο\\3")
105
+ str.gsub!(/\\omicron((\{\})|(\s|$))/, "ο\\3")
106
+ str.gsub!(/\\Pi((\{\})|(\s|$))/, "Π\\3")
107
+ str.gsub!(/\\pi((\{\})|(\s|$))/, "π\\3")
108
+ str.gsub!(/\\Rho((\{\})|(\s|$))/, "Ρ\\3")
109
+ str.gsub!(/\\rho((\{\})|(\s|$))/, "ρ\\3")
110
+ str.gsub!(/\\Sigma((\{\})|(\s|$))/, "Σ\\3")
111
+ str.gsub!(/\\sigma((\{\})|(\s|$))/, "σ\\3")
112
+ str.gsub!(/\\sigmaf((\{\})|(\s|$))/, "ς\\3")
113
+ str.gsub!(/\\varsigma((\{\})|(\s|$))/, "ς\\3")
114
+ str.gsub!(/\\Tau((\{\})|(\s|$))/, "Τ\\3")
115
+ str.gsub!(/\\Upsilon((\{\})|(\s|$))/, "Υ\\3")
116
+ str.gsub!(/\\upsih((\{\})|(\s|$))/, "ϒ\\3")
117
+ str.gsub!(/\\upsilon((\{\})|(\s|$))/, "υ\\3")
118
+ str.gsub!(/\\Phi((\{\})|(\s|$))/, "Φ\\3")
119
+ str.gsub!(/\\phi((\{\})|(\s|$))/, "φ\\3")
120
+ str.gsub!(/\\Chi((\{\})|(\s|$))/, "Χ\\3")
121
+ str.gsub!(/\\chi((\{\})|(\s|$))/, "χ\\3")
122
+ str.gsub!(/\\acutex((\{\})|(\s|$))/, "´x\\3")
123
+ str.gsub!(/\\Psi((\{\})|(\s|$))/, "Ψ\\3")
124
+ str.gsub!(/\\psi((\{\})|(\s|$))/, "ψ\\3")
125
+ str.gsub!(/\\tau((\{\})|(\s|$))/, "τ\\3")
126
+ str.gsub!(/\\Omega((\{\})|(\s|$))/, "Ω\\3")
127
+ str.gsub!(/\\omega((\{\})|(\s|$))/, "ω\\3")
128
+ str.gsub!(/\\piv((\{\})|(\s|$))/, "ϖ\\3")
129
+ str.gsub!(/\\partial((\{\})|(\s|$))/, "∂\\3")
130
+ str.gsub!(/\\alefsym((\{\})|(\s|$))/, "ℵ\\3")
131
+ str.gsub!(/\\ETH((\{\})|(\s|$))/, "Ð\\3")
132
+ str.gsub!(/\\eth((\{\})|(\s|$))/, "ð\\3")
133
+ str.gsub!(/\\THORN((\{\})|(\s|$))/, "Þ\\3")
134
+ str.gsub!(/\\thorn((\{\})|(\s|$))/, "þ\\3")
135
+ str.gsub!(/\\dots((\{\})|(\s|$))/, "…\\3")
136
+ str.gsub!(/\\hellip((\{\})|(\s|$))/, "…\\3")
137
+ str.gsub!(/\\middot((\{\})|(\s|$))/, "·\\3")
138
+ str.gsub!(/\\iexcl((\{\})|(\s|$))/, "¡\\3")
139
+ str.gsub!(/\\iquest((\{\})|(\s|$))/, "¿\\3")
140
+ str.gsub!(/\\shy((\{\})|(\s|$))/, "­\\3")
141
+ str.gsub!(/\\ndash((\{\})|(\s|$))/, "–\\3")
142
+ str.gsub!(/\\mdash((\{\})|(\s|$))/, "—\\3")
143
+ str.gsub!(/\\quot((\{\})|(\s|$))/, ""\\3")
144
+ str.gsub!(/\\acute((\{\})|(\s|$))/, "´\\3")
145
+ str.gsub!(/\\ldquo((\{\})|(\s|$))/, "“\\3")
146
+ str.gsub!(/\\rdquo((\{\})|(\s|$))/, "”\\3")
147
+ str.gsub!(/\\bdquo((\{\})|(\s|$))/, "„\\3")
148
+ str.gsub!(/\\lsquo((\{\})|(\s|$))/, "‘\\3")
149
+ str.gsub!(/\\rsquo((\{\})|(\s|$))/, "’\\3")
150
+ str.gsub!(/\\sbquo((\{\})|(\s|$))/, "‚\\3")
151
+ str.gsub!(/\\laquo((\{\})|(\s|$))/, "«\\3")
152
+ str.gsub!(/\\raquo((\{\})|(\s|$))/, "»\\3")
153
+ str.gsub!(/\\lsaquo((\{\})|(\s|$))/, "‹\\3")
154
+ str.gsub!(/\\rsaquo((\{\})|(\s|$))/, "›\\3")
155
+ str.gsub!(/\\circ((\{\})|(\s|$))/, "ˆ\\3")
156
+ str.gsub!(/\\vert((\{\})|(\s|$))/, "|\\3")
157
+ str.gsub!(/\\brvbar((\{\})|(\s|$))/, "¦\\3")
158
+ str.gsub!(/\\sect((\{\})|(\s|$))/, "§\\3")
159
+ str.gsub!(/\\amp((\{\})|(\s|$))/, "&\\3")
160
+ str.gsub!(/\\lt((\{\})|(\s|$))/, "<\\3")
161
+ str.gsub!(/\\gt((\{\})|(\s|$))/, ">\\3")
162
+ str.gsub!(/\\tilde((\{\})|(\s|$))/, "˜\\3")
163
+ str.gsub!(/\\dagger((\{\})|(\s|$))/, "†\\3")
164
+ str.gsub!(/\\Dagger((\{\})|(\s|$))/, "‡\\3")
165
+ str.gsub!(/\\nbsp((\{\})|(\s|$))/, " \\3")
166
+ str.gsub!(/\\ensp((\{\})|(\s|$))/, " \\3")
167
+ str.gsub!(/\\emsp((\{\})|(\s|$))/, " \\3")
168
+ str.gsub!(/\\thinsp((\{\})|(\s|$))/, " \\3")
169
+ str.gsub!(/\\curren((\{\})|(\s|$))/, "¤\\3")
170
+ str.gsub!(/\\cent((\{\})|(\s|$))/, "¢\\3")
171
+ str.gsub!(/\\pound((\{\})|(\s|$))/, "£\\3")
172
+ str.gsub!(/\\yen((\{\})|(\s|$))/, "¥\\3")
173
+ str.gsub!(/\\euro((\{\})|(\s|$))/, "€\\3")
174
+ str.gsub!(/\\EUR((\{\})|(\s|$))/, "€\\3")
175
+ str.gsub!(/\\EURdig((\{\})|(\s|$))/, "€\\3")
176
+ str.gsub!(/\\EURhv((\{\})|(\s|$))/, "€\\3")
177
+ str.gsub!(/\\EURcr((\{\})|(\s|$))/, "€\\3")
178
+ str.gsub!(/\\EURtm((\{\})|(\s|$))/, "€\\3")
179
+ str.gsub!(/\\copy((\{\})|(\s|$))/, "©\\3")
180
+ str.gsub!(/\\reg((\{\})|(\s|$))/, "®\\3")
181
+ str.gsub!(/\\trade((\{\})|(\s|$))/, "™\\3")
182
+ str.gsub!(/\\minus((\{\})|(\s|$))/, "−\\3")
183
+ str.gsub!(/\\pm((\{\})|(\s|$))/, "±\\3")
184
+ str.gsub!(/\\plusmn((\{\})|(\s|$))/, "±\\3")
185
+ str.gsub!(/\\times((\{\})|(\s|$))/, "×\\3")
186
+ str.gsub!(/\\frasl((\{\})|(\s|$))/, "⁄\\3")
187
+ str.gsub!(/\\div((\{\})|(\s|$))/, "÷\\3")
188
+ str.gsub!(/\\frac12((\{\})|(\s|$))/, "½\\3")
189
+ str.gsub!(/\\frac14((\{\})|(\s|$))/, "¼\\3")
190
+ str.gsub!(/\\frac34((\{\})|(\s|$))/, "¾\\3")
191
+ str.gsub!(/\\permil((\{\})|(\s|$))/, "‰\\3")
192
+ str.gsub!(/\\sup1((\{\})|(\s|$))/, "¹\\3")
193
+ str.gsub!(/\\sup2((\{\})|(\s|$))/, "²\\3")
194
+ str.gsub!(/\\sup3((\{\})|(\s|$))/, "³\\3")
195
+ str.gsub!(/\\radic((\{\})|(\s|$))/, "√\\3")
196
+ str.gsub!(/\\sum((\{\})|(\s|$))/, "∑\\3")
197
+ str.gsub!(/\\prod((\{\})|(\s|$))/, "∏\\3")
198
+ str.gsub!(/\\micro((\{\})|(\s|$))/, "µ\\3")
199
+ str.gsub!(/\\macr((\{\})|(\s|$))/, "¯\\3")
200
+ str.gsub!(/\\deg((\{\})|(\s|$))/, "°\\3")
201
+ str.gsub!(/\\prime((\{\})|(\s|$))/, "′\\3")
202
+ str.gsub!(/\\Prime((\{\})|(\s|$))/, "″\\3")
203
+ str.gsub!(/\\infin((\{\})|(\s|$))/, "∞\\3")
204
+ str.gsub!(/\\infty((\{\})|(\s|$))/, "∞\\3")
205
+ str.gsub!(/\\prop((\{\})|(\s|$))/, "∝\\3")
206
+ str.gsub!(/\\proptp((\{\})|(\s|$))/, "∝\\3")
207
+ str.gsub!(/\\not((\{\})|(\s|$))/, "¬\\3")
208
+ str.gsub!(/\\land((\{\})|(\s|$))/, "∧\\3")
209
+ str.gsub!(/\\wedge((\{\})|(\s|$))/, "∧\\3")
210
+ str.gsub!(/\\lor((\{\})|(\s|$))/, "∨\\3")
211
+ str.gsub!(/\\vee((\{\})|(\s|$))/, "∨\\3")
212
+ str.gsub!(/\\cap((\{\})|(\s|$))/, "∩\\3")
213
+ str.gsub!(/\\cup((\{\})|(\s|$))/, "∪\\3")
214
+ str.gsub!(/\\int((\{\})|(\s|$))/, "∫\\3")
215
+ str.gsub!(/\\there4((\{\})|(\s|$))/, "∴\\3")
216
+ str.gsub!(/\\sim((\{\})|(\s|$))/, "∼\\3")
217
+ str.gsub!(/\\cong((\{\})|(\s|$))/, "≅\\3")
218
+ str.gsub!(/\\simeq((\{\})|(\s|$))/, "≅\\3")
219
+ str.gsub!(/\\asymp((\{\})|(\s|$))/, "≈\\3")
220
+ str.gsub!(/\\approx((\{\})|(\s|$))/, "≈\\3")
221
+ str.gsub!(/\\ne((\{\})|(\s|$))/, "≠\\3")
222
+ str.gsub!(/\\neq((\{\})|(\s|$))/, "≠\\3")
223
+ str.gsub!(/\\equiv((\{\})|(\s|$))/, "≡\\3")
224
+ str.gsub!(/\\le((\{\})|(\s|$))/, "≤\\3")
225
+ str.gsub!(/\\ge((\{\})|(\s|$))/, "≥\\3")
226
+ str.gsub!(/\\sub((\{\})|(\s|$))/, "⊂\\3")
227
+ str.gsub!(/\\subset((\{\})|(\s|$))/, "⊂\\3")
228
+ str.gsub!(/\\sup((\{\})|(\s|$))/, "⊃\\3")
229
+ str.gsub!(/\\supset((\{\})|(\s|$))/, "⊃\\3")
230
+ str.gsub!(/\\nsub((\{\})|(\s|$))/, "⊄\\3")
231
+ str.gsub!(/\\sube((\{\})|(\s|$))/, "⊆\\3")
232
+ str.gsub!(/\\nsup((\{\})|(\s|$))/, "⊅\\3")
233
+ str.gsub!(/\\supe((\{\})|(\s|$))/, "⊇\\3")
234
+ str.gsub!(/\\forall((\{\})|(\s|$))/, "∀\\3")
235
+ str.gsub!(/\\exist((\{\})|(\s|$))/, "∃\\3")
236
+ str.gsub!(/\\exists((\{\})|(\s|$))/, "∃\\3")
237
+ str.gsub!(/\\empty((\{\})|(\s|$))/, "∅\\3")
238
+ str.gsub!(/\\emptyset((\{\})|(\s|$))/, "∅\\3")
239
+ str.gsub!(/\\isin((\{\})|(\s|$))/, "∈\\3")
240
+ str.gsub!(/\\in((\{\})|(\s|$))/, "∈\\3")
241
+ str.gsub!(/\\notin((\{\})|(\s|$))/, "∉\\3")
242
+ str.gsub!(/\\ni((\{\})|(\s|$))/, "∋\\3")
243
+ str.gsub!(/\\nabla((\{\})|(\s|$))/, "∇\\3")
244
+ str.gsub!(/\\ang((\{\})|(\s|$))/, "∠\\3")
245
+ str.gsub!(/\\angle((\{\})|(\s|$))/, "∠\\3")
246
+ str.gsub!(/\\perp((\{\})|(\s|$))/, "⊥\\3")
247
+ str.gsub!(/\\sdot((\{\})|(\s|$))/, "⋅\\3")
248
+ str.gsub!(/\\cdot((\{\})|(\s|$))/, "⋅\\3")
249
+ str.gsub!(/\\lceil((\{\})|(\s|$))/, "⌈\\3")
250
+ str.gsub!(/\\rceil((\{\})|(\s|$))/, "⌉\\3")
251
+ str.gsub!(/\\lfloor((\{\})|(\s|$))/, "⌊\\3")
252
+ str.gsub!(/\\rfloor((\{\})|(\s|$))/, "⌋\\3")
253
+ str.gsub!(/\\lang((\{\})|(\s|$))/, "⟨\\3")
254
+ str.gsub!(/\\rang((\{\})|(\s|$))/, "⟩\\3")
255
+ str.gsub!(/\\larr((\{\})|(\s|$))/, "←\\3")
256
+ str.gsub!(/\\leftarrow((\{\})|(\s|$))/, "←\\3")
257
+ str.gsub!(/\\gets((\{\})|(\s|$))/, "←\\3")
258
+ str.gsub!(/\\lArr((\{\})|(\s|$))/, "⇐\\3")
259
+ str.gsub!(/\\Leftarrow((\{\})|(\s|$))/, "⇐\\3")
260
+ str.gsub!(/\\uarr((\{\})|(\s|$))/, "↑\\3")
261
+ str.gsub!(/\\uparrow((\{\})|(\s|$))/, "↑\\3")
262
+ str.gsub!(/\\uArr((\{\})|(\s|$))/, "⇑\\3")
263
+ str.gsub!(/\\Uparrow((\{\})|(\s|$))/, "⇑\\3")
264
+ str.gsub!(/\\rarr((\{\})|(\s|$))/, "→\\3")
265
+ str.gsub!(/\\to((\{\})|(\s|$))/, "→\\3")
266
+ str.gsub!(/\\rightarrow((\{\})|(\s|$))/, "→\\3")
267
+ str.gsub!(/\\rArr((\{\})|(\s|$))/, "⇒\\3")
268
+ str.gsub!(/\\Rightarrow((\{\})|(\s|$))/, "⇒\\3")
269
+ str.gsub!(/\\darr((\{\})|(\s|$))/, "↓\\3")
270
+ str.gsub!(/\\downarrow((\{\})|(\s|$))/, "↓\\3")
271
+ str.gsub!(/\\dArr((\{\})|(\s|$))/, "⇓\\3")
272
+ str.gsub!(/\\Downarrow((\{\})|(\s|$))/, "⇓\\3")
273
+ str.gsub!(/\\harr((\{\})|(\s|$))/, "↔\\3")
274
+ str.gsub!(/\\leftrightarrow((\{\})|(\s|$))/, "↔\\3")
275
+ str.gsub!(/\\hArr((\{\})|(\s|$))/, "⇔\\3")
276
+ str.gsub!(/\\Leftrightarrow((\{\})|(\s|$))/, "⇔\\3")
277
+ str.gsub!(/\\crarr((\{\})|(\s|$))/, "↵\\3")
278
+ str.gsub!(/\\hookleftarrow((\{\})|(\s|$))/, "↵\\3")
279
+ str.gsub!(/\\arccos((\{\})|(\s|$))/, "arccos\\3")
280
+ str.gsub!(/\\arcsin((\{\})|(\s|$))/, "arcsin\\3")
281
+ str.gsub!(/\\arctan((\{\})|(\s|$))/, "arctan\\3")
282
+ str.gsub!(/\\arg((\{\})|(\s|$))/, "arg\\3")
283
+ str.gsub!(/\\cos((\{\})|(\s|$))/, "cos\\3")
284
+ str.gsub!(/\\cosh((\{\})|(\s|$))/, "cosh\\3")
285
+ str.gsub!(/\\cot((\{\})|(\s|$))/, "cot\\3")
286
+ str.gsub!(/\\coth((\{\})|(\s|$))/, "coth\\3")
287
+ str.gsub!(/\\csc((\{\})|(\s|$))/, "csc\\3")
288
+ str.gsub!(/\\deg((\{\})|(\s|$))/, "°\\3")
289
+ str.gsub!(/\\det((\{\})|(\s|$))/, "det\\3")
290
+ str.gsub!(/\\dim((\{\})|(\s|$))/, "dim\\3")
291
+ str.gsub!(/\\exp((\{\})|(\s|$))/, "exp\\3")
292
+ str.gsub!(/\\gcd((\{\})|(\s|$))/, "gcd\\3")
293
+ str.gsub!(/\\hom((\{\})|(\s|$))/, "hom\\3")
294
+ str.gsub!(/\\inf((\{\})|(\s|$))/, "inf\\3")
295
+ str.gsub!(/\\ker((\{\})|(\s|$))/, "ker\\3")
296
+ str.gsub!(/\\lg((\{\})|(\s|$))/, "lg\\3")
297
+ str.gsub!(/\\lim((\{\})|(\s|$))/, "lim\\3")
298
+ str.gsub!(/\\liminf((\{\})|(\s|$))/, "liminf\\3")
299
+ str.gsub!(/\\limsup((\{\})|(\s|$))/, "limsup\\3")
300
+ str.gsub!(/\\ln((\{\})|(\s|$))/, "ln\\3")
301
+ str.gsub!(/\\log((\{\})|(\s|$))/, "log\\3")
302
+ str.gsub!(/\\max((\{\})|(\s|$))/, "max\\3")
303
+ str.gsub!(/\\min((\{\})|(\s|$))/, "min\\3")
304
+ str.gsub!(/\\Pr((\{\})|(\s|$))/, "Pr\\3")
305
+ str.gsub!(/\\sec((\{\})|(\s|$))/, "sec\\3")
306
+ str.gsub!(/\\sin((\{\})|(\s|$))/, "sin\\3")
307
+ str.gsub!(/\\sinh((\{\})|(\s|$))/, "sinh\\3")
308
+ str.gsub!(/\\sup((\{\})|(\s|$))/, "⊃\\3")
309
+ str.gsub!(/\\tan((\{\})|(\s|$))/, "tan\\3")
310
+ str.gsub!(/\\tanh((\{\})|(\s|$))/, "tanh\\3")
311
+ str.gsub!(/\\bull((\{\})|(\s|$))/, "•\\3")
312
+ str.gsub!(/\\bullet((\{\})|(\s|$))/, "•\\3")
313
+ str.gsub!(/\\star((\{\})|(\s|$))/, "*\\3")
314
+ str.gsub!(/\\lowast((\{\})|(\s|$))/, "∗\\3")
315
+ str.gsub!(/\\ast((\{\})|(\s|$))/, "∗\\3")
316
+ str.gsub!(/\\odot((\{\})|(\s|$))/, "o\\3")
317
+ str.gsub!(/\\oplus((\{\})|(\s|$))/, "⊕\\3")
318
+ str.gsub!(/\\otimes((\{\})|(\s|$))/, "⊗\\3")
319
+ str.gsub!(/\\checkmark((\{\})|(\s|$))/, "✓\\3")
320
+ str.gsub!(/\\para((\{\})|(\s|$))/, "¶\\3")
321
+ str.gsub!(/\\ordf((\{\})|(\s|$))/, "ª\\3")
322
+ str.gsub!(/\\ordm((\{\})|(\s|$))/, "º\\3")
323
+ str.gsub!(/\\cedil((\{\})|(\s|$))/, "¸\\3")
324
+ str.gsub!(/\\oline((\{\})|(\s|$))/, "‾\\3")
325
+ str.gsub!(/\\uml((\{\})|(\s|$))/, "¨\\3")
326
+ str.gsub!(/\\zwnj((\{\})|(\s|$))/, "‌\\3")
327
+ str.gsub!(/\\zwj((\{\})|(\s|$))/, "‍\\3")
328
+ str.gsub!(/\\lrm((\{\})|(\s|$))/, "‎\\3")
329
+ str.gsub!(/\\rlm((\{\})|(\s|$))/, "‏\\3")
330
+ str.gsub!(/\\smile((\{\})|(\s|$))/, "☺\\3")
331
+ str.gsub!(/\\smiley((\{\})|(\s|$))/, "☺\\3")
332
+ str.gsub!(/\\blacksmile((\{\})|(\s|$))/, "☻\\3")
333
+ str.gsub!(/\\sad((\{\})|(\s|$))/, "☹\\3")
334
+ str.gsub!(/\\clubs((\{\})|(\s|$))/, "♣\\3")
335
+ str.gsub!(/\\clubsuit((\{\})|(\s|$))/, "♣\\3")
336
+ str.gsub!(/\\spades((\{\})|(\s|$))/, "♠\\3")
337
+ str.gsub!(/\\spadesuit((\{\})|(\s|$))/, "♠\\3")
338
+ str.gsub!(/\\hearts((\{\})|(\s|$))/, "♥\\3")
339
+ str.gsub!(/\\heartsuit((\{\})|(\s|$))/, "♥\\3")
340
+ str.gsub!(/\\diams((\{\})|(\s|$))/, "♦\\3")
341
+ str.gsub!(/\\diamondsuit((\{\})|(\s|$))/, "♦\\3")
342
+ str.gsub!(/\\Diamond((\{\})|(\s|$))/, "⋄\\3")
343
+ str.gsub!(/\\loz((\{\})|(\s|$))/, "◊\\3")
344
+ end
345
+ end # module Orgmode
@@ -0,0 +1,244 @@
1
+ module Orgmode
2
+
3
+ # Represents a single line of an orgmode file.
4
+ class Line
5
+
6
+ # This is the line itself.
7
+ attr_reader :line
8
+
9
+ # The indent level of this line. this is important to properly translate
10
+ # nested lists from orgmode to textile.
11
+ # TODO 2009-12-20 bdewey: Handle tabs
12
+ attr_reader :indent
13
+
14
+ # Backpointer to the parser that owns this line.
15
+ attr_reader :parser
16
+
17
+ # A line can have its type assigned instead of inferred from its
18
+ # content. For example, something that parses as a "table" on its
19
+ # own ("| one | two|\n") may just be a paragraph if it's inside
20
+ # #+BEGIN_EXAMPLE. Set this property on the line to assign its
21
+ # type. This will then affect the value of +paragraph_type+.
22
+ attr_accessor :assigned_paragraph_type
23
+
24
+ def initialize(line, parser = nil)
25
+ @parser = parser
26
+ @line = line
27
+ @indent = 0
28
+ @line =~ /\s*/
29
+ @assigned_paragraph_type = nil
30
+ @indent = $&.length unless blank?
31
+ end
32
+
33
+ def to_s
34
+ return @line
35
+ end
36
+
37
+ # Tests if a line is a comment.
38
+ def comment?
39
+ return @assigned_paragraph_type == :comment if @assigned_paragraph_type
40
+ return block_type.casecmp("COMMENT") if begin_block? or end_block?
41
+ return @line =~ /^#/
42
+ end
43
+
44
+ PropertyDrawerRegexp = /^\s*:(PROPERTIES|END):/i
45
+
46
+ def property_drawer_begin_block?
47
+ @line =~ PropertyDrawerRegexp && $1 =~ /PROPERTIES/
48
+ end
49
+
50
+ def property_drawer_end_block?
51
+ @line =~ PropertyDrawerRegexp && $1 =~ /END/
52
+ end
53
+
54
+ def property_drawer?
55
+ check_assignment_or_regexp(:property_drawer, PropertyDrawerRegexp)
56
+ end
57
+
58
+ PropertyDrawerItemRegexp = /^\s*:(\w+):\s*(.*)$/i
59
+
60
+ def property_drawer_item?
61
+ @line =~ PropertyDrawerItemRegexp
62
+ end
63
+
64
+ # Tests if a line contains metadata instead of actual content.
65
+ def metadata?
66
+ check_assignment_or_regexp(:metadata, /^\s*(CLOCK|DEADLINE|START|CLOSED|SCHEDULED):/)
67
+ end
68
+
69
+ def nonprinting?
70
+ comment? || metadata? || begin_block? || end_block?
71
+ end
72
+
73
+ def blank?
74
+ check_assignment_or_regexp(:blank, /^\s*$/)
75
+ end
76
+
77
+ def plain_list?
78
+ ordered_list? or unordered_list? or definition_list?
79
+ end
80
+
81
+ UnorderedListRegexp = /^\s*(-|\+)\s+/
82
+
83
+ def unordered_list?
84
+ check_assignment_or_regexp(:unordered_list, UnorderedListRegexp)
85
+ end
86
+
87
+ def strip_unordered_list_tag
88
+ @line.sub(UnorderedListRegexp, "")
89
+ end
90
+
91
+ DefinitionListRegexp = /^\s*(-|\+)\s*(.*?)::/
92
+
93
+ def definition_list?
94
+ check_assignment_or_regexp(:definition_list, DefinitionListRegexp)
95
+ end
96
+
97
+ OrderedListRegexp = /^\s*\d+(\.|\))\s+/
98
+
99
+ def ordered_list?
100
+ check_assignment_or_regexp(:ordered_list, OrderedListRegexp)
101
+ end
102
+
103
+ def strip_ordered_list_tag
104
+ @line.sub(OrderedListRegexp, "")
105
+ end
106
+
107
+ # Extracts meaningful text and excludes org-mode markup,
108
+ # like identifiers for lists or headings.
109
+ def output_text
110
+ return strip_ordered_list_tag if ordered_list?
111
+ return strip_unordered_list_tag if unordered_list?
112
+ return @line.sub(InlineExampleRegexp, "") if inline_example?
113
+ return line
114
+ end
115
+
116
+ def plain_text?
117
+ not metadata? and not blank? and not plain_list?
118
+ end
119
+
120
+ def table_row?
121
+ # for an org-mode table, the first non-whitespace character is a
122
+ # | (pipe).
123
+ check_assignment_or_regexp(:table_row, /^\s*\|/)
124
+ end
125
+
126
+ def table_separator?
127
+ # an org-mode table separator has the first non-whitespace
128
+ # character as a | (pipe), then consists of nothing else other
129
+ # than pipes, hyphens, and pluses.
130
+
131
+ check_assignment_or_regexp(:table_separator, /^\s*\|[-\|\+]*\s*$/)
132
+ end
133
+
134
+ # Checks if this line is a table header.
135
+ def table_header?
136
+ @assigned_paragraph_type == :table_header
137
+ end
138
+
139
+ def table?
140
+ table_row? or table_separator? or table_header?
141
+ end
142
+
143
+ BlockRegexp = /^\s*#\+(BEGIN|END)_(\w*)\s*(\w*)?/i
144
+
145
+ def begin_block?
146
+ @line =~ BlockRegexp && $1 =~ /BEGIN/i
147
+ end
148
+
149
+ def end_block?
150
+ @line =~ BlockRegexp && $1 =~ /END/i
151
+ end
152
+
153
+ def block_type
154
+ $2 if @line =~ BlockRegexp
155
+ end
156
+
157
+ def block_lang
158
+ $3 if @line =~ BlockRegexp
159
+ end
160
+
161
+ def code_block_type?
162
+ block_type =~ /^(EXAMPLE|SRC)$/i
163
+ end
164
+
165
+ InlineExampleRegexp = /^\s*:\s/
166
+
167
+ # Test if the line matches the "inline example" case:
168
+ # the first character on the line is a colon.
169
+ def inline_example?
170
+ check_assignment_or_regexp(:inline_example, InlineExampleRegexp)
171
+ end
172
+
173
+ InBufferSettingRegexp = /^#\+(\w+):\s*(.*)$/
174
+
175
+ # call-seq:
176
+ # line.in_buffer_setting? => boolean
177
+ # line.in_buffer_setting? { |key, value| ... }
178
+ #
179
+ # Called without a block, this method determines if the line
180
+ # contains an in-buffer setting. Called with a block, the block
181
+ # will get called if the line contains an in-buffer setting with
182
+ # the key and value for the setting.
183
+ def in_buffer_setting?
184
+ return false if @assigned_paragraph_type && @assigned_paragraph_type != :comment
185
+ if block_given? then
186
+ if @line =~ InBufferSettingRegexp
187
+ yield $1, $2
188
+ end
189
+ else
190
+ @line =~ InBufferSettingRegexp
191
+ end
192
+ end
193
+
194
+ # Determines the paragraph type of the current line.
195
+ def paragraph_type
196
+ return :blank if blank?
197
+ return :definition_list if definition_list? # order is important! A definition_list is also an unordered_list!
198
+ return :ordered_list if ordered_list?
199
+ return :unordered_list if unordered_list?
200
+ return :property_drawer_begin_block if property_drawer_begin_block?
201
+ return :property_drawer_end_block if property_drawer_end_block?
202
+ return :property_drawer_item if property_drawer_item?
203
+ return :metadata if metadata?
204
+ return :begin_block if begin_block?
205
+ return :end_block if end_block?
206
+ return :comment if comment?
207
+ return :table_separator if table_separator?
208
+ return :table_row if table_row?
209
+ return :table_header if table_header?
210
+ return :inline_example if inline_example?
211
+ return :paragraph
212
+ end
213
+
214
+ def self.to_textile(lines)
215
+ output = ""
216
+ output_buffer = TextileOutputBuffer.new(output)
217
+ Parser.translate(lines, output_buffer)
218
+ end
219
+
220
+ ######################################################################
221
+ private
222
+
223
+ # This function is an internal helper for determining the paragraph
224
+ # type of a line... for instance, if the line is a comment or contains
225
+ # metadata. It's used in routines like blank?, plain_list?, etc.
226
+ #
227
+ # What's tricky is lines can have assigned types, so you need to check
228
+ # the assigned type, if present, or see if the characteristic regexp
229
+ # for the paragraph type matches if not present.
230
+ #
231
+ # call-seq:
232
+ # check_assignment_or_regexp(assignment, regexp) => boolean
233
+ #
234
+ # assignment:: if the paragraph has an assigned type, it will be
235
+ # checked to see if it equals +assignment+.
236
+ # regexp:: If the paragraph does not have an assigned type,
237
+ # the contents of the paragraph will be checked against
238
+ # this regexp.
239
+ def check_assignment_or_regexp(assignment, regexp)
240
+ return @assigned_paragraph_type == assignment if @assigned_paragraph_type
241
+ return @line =~ regexp
242
+ end
243
+ end # class Line
244
+ end # module Orgmode