1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
=begin
* Name: SiSU
* Description: a framework for document structuring, publishing and search
* Author: Ralph Amissah
* Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007 Ralph Amissah All Rights Reserved.
* License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007 Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
If you have Internet connection, the latest version of the GPL should be
available at these locations:
<http://www.fsf.org/licenses/gpl.html>
<http://www.gnu.org/copyleft/gpl.html>
<http://www.jus.uio.no/sisu/gpl.fsf>
* SiSU uses:
* Standard SiSU markup syntax,
* Standard SiSU meta-markup syntax, and the
* Standard SiSU object citation numbering and system
* Hompages:
<http://www.jus.uio.no/sisu>
<http://www.sisudoc.org>
* Download:
<http://www.jus.uio.no/sisu/SiSU/download.html>
* Ralph Amissah
<ralph@amissah.com>
<ralph.amissah@gmail.com>
** Description: Syntax for markup, input markup syntaxes, determined here
=end
module Syntax
class Words
def initialize(line,md,mkp)
@line,@md,@mkp=line,md,mkp
end
end
class Markup
def initialize(md='',data='')
@data,@md=data,md
@vz=SiSU_Env::Get_init.instance.skin
@data_new=[]
@http_m='\{.+?\}https?://\S+|https?:\S+|\.\.\/\S+|\S+?\.png\b|[*]~\S+|^0~.+|<:(?:code|group|alt|verse)(?:-end)?>|<:br>'
@manmkp_ital='[i/]\\{.+?\\}[i/]'
tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)}
tail_m_bold=%q{(?:(?:<\/i>)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?}
bold_line=%q{^!_\s.+?(?:<br>|\n|$)}
@line_scan_ital=if defined? @md.make_italic[:str] and defined? @vz.markup_make_italic[:str]
/#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|(?:#{@md.make_italic[:str]}|#{@vz.markup_make_italic[:str]})#{tail_m_ital}|\S+|\n/
elsif defined? @md.make_italic[:str]
/#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|#{@md.make_italic[:str]}#{tail_m_ital}|\S+|\n/
elsif defined? @vz.markup_make_italic[:str]
/#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|#{@vz.markup_make_italic[:str]}#{tail_m_ital}|\S+|\n/
end
@manmkp_bold='^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]'
@line_scan_bold=if (defined? @md.make_bold[:str] and @md.make_bold[:str]) and (defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str])
/#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@md.make_bold[:str]}|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/
elsif defined? @md.make_bold[:str] and @md.make_bold[:str]
/#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@md.make_bold[:str]})#{tail_m_bold}|\S+|\n/
elsif defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str]
/#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/
end
end
def songsheet
@data.each do |line|
line=pre(line)
line=wordlist_italics(line)
line=wordlist_bold(line)
line=bodymarkup(line)
@data_new << line
end
@data_new
end
def pre(line)
line=line.dup
if line =~/\{(?:t|table)(?:~h)?\s*c?[\d; ]*\}/; line.gsub!(/(\n)/,';;\1') #markup for alternative tables
end
line
end
def wordlist_italics(line)
line=line.dup
if (defined? @md.make_italic[:str] and @md.make_italic[:str]) \
or (defined? @vz.markup_make_italic[:str] and @vz.markup_make_italic[:str])
line= if line !~/^(0~|%{1,4}\s)/ #!~/^(?:[0-6]~|!_|%+\s)/
word=line.scan(@line_scan_ital)
word.flatten!
word.compact! #reinstated
line_array=[]
word.each do |w|
unless /#@manmkp_ital|#@http_m/.match(w)
if defined? @md.make_italic[:regx] and @md.make_italic[:regx]
w.gsub!(@md.make_italic[:regx],'<i>\1</i>')
elsif defined? @vz.markup_make_italic and @vz.markup_make_italic
w.gsub!(@vz.markup_make_italic,'<i>\1</i>')
end
end
line_array << w
end
line_array.join(' ')
else line
end
end
line
end
def embolden(given)
given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)(<br>)/,'<b>\1</b>\2')
given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s+((?:[*]~\S+\s*)+)/,'<b>\1</b> \2')
given.gsub!(/(?:^!_|^[7-9]~)\s+(.+?)\s*([~-]#)$/,'<b>\1</b> \2')
given.gsub!(/(?:^!_\s+|^[7-9]~\s+)(.*)?\s*$/,'<b>\1</b>')
end
def wordlist_bold(line)
line=line.dup
if (defined? @md.make_bold[:str] and @md.make_bold[:str]) or (defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str])
line=if line !~/^(?:[0-9]~|%+\s)/
line_array=[]
word=line.scan(@line_scan_bold)
word.flatten!
word.compact!
word.each do |w|
unless /#@manmkp_bold|#@http_m/.match(w)
if defined? @md.make_bold[:regx] and @md.make_bold[:regx] #document header: 0~bold [bold word list]
w.gsub!(@md.make_bold[:regx],'<b>\1</b>')
elsif defined? @vz.markup_make_bold and @vz.markup_make_bold #defaults and skin adjusted bold word list
w.gsub!(@vz.markup_make_bold,'<b>\1</b>')
end
else
if w =~ /(?:^!_|^[7-9]~)\s+/; embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost!
end
end
line_array << w
end
line_array.join(' ')
else line
end
else
if line !~/^(?:[0-9]~|%+\s)/ and line =~ /(?:^!_|^[7-9]~)\s+/; embolden(line)
end
end
line
end
def bodymarkup(line)
# << http://www.jus.uio.no/sisu/sisu_markup_table/markup >>
# See: data/sisu/sample/document_samples_sisu_markup/
# !{emphasis}! e{emphasis}e <strong>emphasis</strong>
# *{bold text}* b{bold}b <b>bold text</b>
# _{underline}_ u{underline}u <u>underline</u>
# /{italics}/ i{italics}i <i>italics</i>
# "{citation}" c{citation}c <cite>citation</cite> #blockquote?
# ^{superscript}^ <sup>superscript</sup>
# ,{subscript}, <sub>subscript</sub>
# +{inserted text}+ <ins>inserted text</ins>
# -{deleted text}- <del>deleted text</del>
# {url address}:url
# {image.png}imageurl
# {image.png}png
# ~{endnote}~ <!e endnote !>
# !_ #bold/emphasise paragraph
# _" #blockquote paragraph
# _1 <:i1> #indent paragraph 1 step
# _2 <:i2> #indent paragraph 2 steps
# _3 <:i3> #indent paragraph 3 steps
# _4 <:i4> #indent paragraph 4 steps
# _* #bullet (list) ●
# _1* #bullet (list) indented
# _1* #bullet (list) indented
# # #numbered (list) level 1
# _# #numbered (list) level 2
line=line.dup
unless line =~/^0~|<:codeline>|<:code-end>/
#special characters: ~ { } < > - _ / also used : ^ ! #
line_array=[]
line.gsub!(/^%{1,4} .+/mi,'') #remove comments
word=line.scan(/\S+|\n/) unless line =~/^(?:0~\S|%+\s)/
if word
word.each do |w| # _ - / # | : ! ^ ~
unless w =~/^[0-9]~|~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table/
w.gsub!(/\\~/,'~') #escaped special character
w.gsub!(/~/,'~')
end
w.gsub!(/^\<$/,'<') #escaped special character
w.gsub!(/^\>$/,'>') #escaped special character
line_array << w
end
line=line_array.join(' ')
line=line.strip
end
line.gsub!(/^(1~\??) @title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},<br />\\2#{@md.dc_creator}")
line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") #
line.gsub!(/^([23]~\??) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}") #
line.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup
line.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30
line.gsub!(/<!(\S+)!>/,'<:\1>') #escaped special character
line.gsub!(/\\~/,'~') #escaped special character
line.gsub!(/\\\{/,'{') #escaped special character
line.gsub!(/\\\}/,'}') #escaped special character
line.gsub!(/\\\<</,'<<') #escaped special character
line.gsub!(/\\\>>/,'>>') #escaped special character
line.gsub!(/\\\</,'<') #escaped special character
line.gsub!(/\\\>/,'>') #escaped special character
line.gsub!(/\\\_/,'_') #escaped special character
line.gsub!(/\\\-/,'-') #escaped special character
line.gsub!(/\\\+/,'+') #escaped special character
line.gsub!(/\\\//,'/') #escaped special character
line.gsub!(/\\\#/,'#') #escaped special character
line.gsub!(/\\\&/,'&') #& #escaped special character
line.gsub!(/\\\|/,'|') #not really a sisu special character but made available as possibility
line.gsub!(/\\\:/,':') #not really a sisu special character but made available as possibility
line.gsub!(/\\\!/,'!') #not really a sisu special character but made available as possibility
line.gsub!(/\\\^/,'^') #not really a sisu special character but made available as possibility
line.gsub!(/\\\,/,',') #not really a sisu special character but made available as possibility
#ADD -->
line.gsub!(/\\\\/,'\') #escaped special character
line.gsub!(/\\\*/,'*') #escaped special character
line.gsub!(/\\\!/,'!') #escaped special character
line.gsub!(/(?:^| )\*~([a-z0-9._-]+)/i,' <:name#\1>') #html name marker <a name="\\1"></a>
line.gsub!(/^([56]~)(\S+)(.+)/,'\1\2 \3 <:name#\2>') #html name marker <a name="\\1"></a>, however at present takes you to correct position within sub-toc, will nneed to clean from sub-toc leaving in main body only
line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|ftp):\S+?)([;,.]?(?=\s[^~]|$))/,'\1{ \2 }\3\4 ~{ \3 }~ ') #text url endnote url shortcut {~^ [text] }http://url is { [text] }http://url ~{ http://url }~ [plus adjustment for commas] #means for this class, non-object, un-numbered ~# will not work # shortcut should not be used in conjunction with rebgular matches #reversed order, and addition of no-tilde..
line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch
line.gsub!(/<:?br>/,'<br />') #xml requires
# depreciated -->
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)e\{(.+?)\}e/,'\1<b>\2</b>') #emphasis
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)b\{(.+?)\}b/,'\1<b>\2</b>') #bold
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)u\{(.+?)\}u/,'\1<u>\2</u>') #underscore
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)c\{(.+?)\}c/,'\1<cite>\2</cite>') #cite /blockquote?
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)i\{(.+?)\}i/,'\1<i>\2</i>') #italics
# depreciated ^
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)!\{(.+?)\}!/,'\1<em>\2</em>') #emphasis
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)\*\{(.+?)\}\*/,'\1<b>\2</b>') #bold
line.gsub!(/(^|\s+|['"]| |[\(\[\{]|\>)_\{(.+?)\}_/,'\1<u>\2</u>') #underscore
line.gsub!(/(^|\s+|['"]| |[\(\[]|\(|\>)\/\{(.+?)\}\//,'\1<i>\2</i>') #italics
line.gsub!(/(^|\s+|['"]| |\(|\>)\"\{(.+?)\}\"/,'\1<cite>\2</cite>') #cite /blockquote?
line.gsub!(/(^|[^\\])\^\{(.+?)\}\^/,'\1<sup>\2</sup>') #superscript
line.gsub!(/(^|\s+|['"]| |\(|\>|\S)9\{(.+?)\}9/,'\1<sup>\2</sup>') #superscript
line.gsub!(/(^|[^\\]),\{(.+?)\},/,'\1<sub>\2</sub>') #subscript
line.gsub!(/(^|\s+|['"]| |\(|\>)6\{(.+?)\}6/,'\1<sub>\2</sub>') #subscript
line.gsub!(/(^|\s+|['"]| |\(|\>)\+\{(.+?)\}\+/,'\1<ins>\2</ins>') #inserted text
line.gsub!(/(^|\s+|['"]| |\(|\>)v\{(.+?)\}v/,'\1<ins>\2</ins>') #inserted text
line.gsub!(/(^|\s+|['"]| |\(|\>)-\{(.+?)\}-/,'\1<del>\2</del>') #strikethrough - deleted text
line.gsub!(/(^|\s+|['"]| |\(|\>)x\{(.+?)\}x/,'\1<del>\2</del>') #deleted text
line.gsub!(/(^|\s+|['"]| |\(|\>)\*(\S+?)\*/,'\1<b>\2</b>') #bold single word, watch
line.gsub!(/(^|\s+|['"]| |\(|\>)\!(\S+?)\!/,'\1<b>\2</b>') #bold single word, watch
line.gsub!(/(^|\s+|['"]| |\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/,'\1<i>\2</i>\3') #italics single word, watch
line.gsub!(/(^|\s+|['"]| |\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/,'\1<u>\2</u>\3') #underscore single word, watch (made more complicated by url decoration escape tag (_url))
line.gsub!(/(^|\s+)-([^{]\S+?)-( |$)/,'\1<del>\2</del>\3') #underscore single word, watch
line.gsub!(/(^|\s+|['"]| |\(|\>|\d+)\^(\S+?)\^/,'\1<sup>\2</sup>') #superscript single word, watch digit added
line.gsub!(/<[:e]\s+(.+?)!?>/,'~{ \1 }~') # not tested
line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') #bullets, shortcut
line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ') #indent
line.gsub!(/(?:<br>|<br \/>)\s*_[12]\s+/,'<br> ') #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ')
line.gsub!(/<:?br>/,'<br />') #adjustment 2004w41, from # line.gsub!(/<br>/,'<br />')
##added
#line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?([~-]#)$/i,'<b>\1</b> \2') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost!
#line.gsub!(/(?:^!_\s+|^[7-9]~\s+|<:b>)(.*)?\s*$/i,'<b>\1</b>') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost!
#line.gsub!(/(?:(?:^| )!_ |^[7-9]~ |<:b>)(.*)\n/mi,'<b>\1</b> ') #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost!
#line.gsub!(/^_" (.*)\n/i,'<blockquote>\1</blockquote> ') #blockquotes #introduce KEEP
line.gsub!(/<:hi>/,'<span style="background-color: rgb(255,240,196)">') # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200)
line.gsub!(/<:\/hi>/,'</span>')
line.gsub!(/(<:verse>.+)/m,"\\1\n")
line.gsub!(/[ ]+($)/,'\1')
if line =~/(<:(?:verse|group)>)/; line.gsub!(/(<:(?:verse|group)>)/i,"\\1\n") #cosmetic
else line.gsub!(/(<br \/>)/i,"\\1\n")
end
else #code blocks
line.gsub!(/(^|\s)(https?:\/\/\S+)/,'\1_\2') #line.gsub!(/(^|\s)(http:\/\/\S+)/,"\\1\\\\\\2") #escape urls
line.gsub!(/(^|\s)<(https?:\/\/\S+)>([\s,.]|$)/,'\1\2\3') #clean/unescape urls with decoration, re-apply decoration later
line.gsub!(/<:codeline>/,"\n ") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n")
end
line
end
def tech #script markup planned to be more strict for technical documents
# !{emphasis}! e{emphasis}e <strong>emphasis</strong>
# *{bold text}* b{bold}b <b>bold text</b>
# _{underline}_ u{underline}u <u>underline</u>
# /{italics}/ i{italics}i <i>italics</i>
# "{citation}" c{citation}c <cite>citation</cite>
# ^{superscript}^ <sup>superscript</sup>
# ,{subscript}, <sub>subscript</sub>
# +{inserted text}+ <ins>inserted text</ins>
# -{deleted text}- <del>deleted text</del>
# {url address}:url
# {image.png}imageurl
# {image.png}png
# ~{endnote}~ <!e endnote !>
# +1 <!i1!>
# +2 <!i2!>
puts 'tech'
@data.each do |line|
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)e\{(.+?)\}e/,'\1<b>\2</b>') #emphasis
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)b\{(.+?)\}b/,'\1<b>\2</b>') #bold
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)u\{(.+?)\}u/,'\1<u>\2</u>') #underscore
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)c\{(.+?)\}c/,'\1<cite>\2</cite>') #cite
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)i\{(.+?)\}i/,'\1<i>\2</i>') #italics
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)!\{(.+?)\}!/,'\1<em>\2</em>') #emphasis
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)\*\{(.+?)\}\*/,'\1<b>\2</b>') #bold
line.gsub!(/(^|\s+|['"]|[\(\[]|\>)_\{(.+?)\}_/,'\1<u>\2</u>') #underscore
line.gsub!(/(^|\s+|['"]|[\(\[]|\(|\>)\/\{(.+?)\}\//,'\1<i>\2</i>') #italics
line.gsub!(/(^|\s+|['"]|\(|\>)\"\{(.+?)\}\"/,'\1<cite>\2</cite>')
line.gsub!(/(^|\s+|['"]|\(|\>|\S)\^\{(.+?)\}\^/,'\1<sup>\2</sup>')
line.gsub!(/(^|\s+|['"]|\(|\>|\S)9\{(.+?)\}9/,'\1<sup>\2</sup>')
line.gsub!(/(^|\s+|['"]|\(|\>),\{(.+?)\},/,'\1<sub>\2</sub>')
line.gsub!(/(^|\s+|['"]|\(|\>)6\{(.+?)\}6/,'\1<sub>\2</sub>')
line.gsub!(/(^|\s+|['"]|\(|\>)\+\{(.+?)\}\+/,'\1<ins>\2</ins>')
line.gsub!(/(^|\s+|['"]|\(|\>)v\{(.+?)\}v/,'\1<ins>\2</ins>')
line.gsub!(/(^|\s+|['"]|\(|\>)-\{(.+?)\}-/,'\1<del>\2</del>')
line.gsub!(/(^|\s+|['"]|\(|\>)x\{(.+?)\}x/,'\1<del>\2</del>')
line.gsub!(/(^|\s+|['"]|\(|\>)\*(\S+?)\*/,'\1<b>\2</b>') #bold single word, watch
line.gsub!(/(^|\s+|['"]|\(|\>)\!(\S+?)\!/,'\1<b>\2</b>') #bold single word, watch
line.gsub!(/(^|\s+|['"]|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/,'\1<i>\2</i>\3') #italics single word, watch
line.gsub!(/(^|\s+|['"]|\(|\>)_(\S+?)_/,'\1<u>\2</u>') #underscore single word, watch
line.gsub!(/(^|\s+|['"]|\(|\>|\d+)\^(\S+?)\^/,'\1<sup>\2</sup>') #superscript single word, watch digit added
line.gsub!(/^\s*_([1-9])(\*+)\s*/,'<:i\1> _* ') # bullets, shortcut
line.gsub!(/^\s*_([1-9])\s+/,'<:i\1> ')
line.gsub!(/<:?br>/,'<br />')
end
@data
end
end
end
__END__
NOTE:
downstream code blocks are not currently/yet honoured, e.g. stuff within angle brackets are removed
|