Class: SiSU_JSON_Munge::Trans

Inherits:
Object
  • Object
show all
Includes:
SiSU_Parts_JSON
Defined in:
lib/sisu/json_shared.rb

Instance Method Summary collapse

Methods included from SiSU_Parts_JSON

#the_line_break, #the_table_close, #the_url_decoration, #txt_close, #txt_open, #xml_close, #xml_open

Methods included from SiSU_Parts_Generic

#footer_signature, #home, #home_txt, #i_choice, #i_home_button, #i_ico, #i_new, #rl_root, #root_http, #sisu, #sisu_txt, #sisudoc, #site, #the_icon, #the_text, #the_url, #txt_home, #txt_hp, #txt_hp_alias, #txt_signature, #urify, #url_close, #url_open

Constructor Details

#initialize(md) ⇒ Trans

Returns a new instance of Trans.



77
78
79
80
81
82
83
84
# File 'lib/sisu/json_shared.rb', line 77

def initialize(md)
  @md=md
  @sys=SiSU_Env::SystemCall.new
  @dir=SiSU_Env::InfoEnv.new(@md.fns)
  if @md.sem_tag
    @ab ||=semantic_tags.default
  end
end

Instance Method Details

#char_encObject

character encode



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
# File 'lib/sisu/json_shared.rb', line 125

def char_enc #character encode
  def utf8(dob='')
    if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
      str=if defined? dob.obj then dob.obj
      elsif dob.is_a?(String) then dob
      end
      if str
        #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü
        #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷
        str=str.gsub(/</um,'&#60;').    # '&lt;'     # &#060;
          gsub(/>/um,'&#62;').    # '&gt;'     # &#062;
          gsub(/¢/um,'&#162;').   # '&cent;'   # &#162;
          gsub(/£/um,'&#163;').   # '&pound;'  # &#163;
          gsub(/¥/um,'&#165;').   # '&yen;'    # &#165;
          gsub(/§/um,'&#167;').   # '&sect;'   # &#167;
          gsub(/©/um,'&#169;').   # '&copy;'   # &#169;
          gsub(/ª/um,'&#170;').   # '&ordf;'   # &#170;
          gsub(/«/um,'&#171;').   # '&laquo;'  # &#171;
          gsub(/®/um,'&#174;').   # '&reg;'    # &#174;
          gsub(/°/um,'&#176;').   # '&deg;'    # &#176;
          gsub(/±/um,'&#177;').   # '&plusmn;' # &#177;
          gsub(/²/um,'&#178;').   # '&sup2;'   # &#178;
          gsub(/³/um,'&#179;').   # '&sup3;'   # &#179;
          gsub(/µ/um,'&#181;').   # '&micro;'  # &#181;
          gsub(//um,'&#182;').   # '&para;'   # &#182;
          gsub(/¹/um,'&#185;').   # '&sup1;'   # &#185;
          gsub(/º/um,'&#186;').   # '&ordm;'   # &#186;
          gsub(/»/um,'&#187;').   # '&raquo;'  # &#187;
          gsub(/¼/um,'&#188;').   # '&frac14;' # &#188;
          gsub(/½/um,'&#189;').   # '&frac12;' # &#189;
          gsub(/¾/um,'&#190;').   # '&frac34;' # &#190;
          gsub(/×/um,'&#215;').   # '&times;'  # &#215;
          gsub(/÷/um,'&#247;').   # '&divide;' # &#247;
          gsub(/¿/um,'&#191;').   # '&iquest;' # &#191;
          gsub(/À/um,'&#192;').   # '&Agrave;' # &#192;
          gsub(/Á/um,'&#193;').   # '&Aacute;' # &#193;
          gsub(/Â/um,'&#194;').   # '&Acirc;'  # &#194;
          gsub(/Ã/um,'&#195;').   # '&Atilde;' # &#195;
          gsub(/Ä/um,'&#196;').   # '&Auml;'   # &#196;
          gsub(/Å/um,'&#197;').   # '&Aring;'  # &#197;
          gsub(/Æ/um,'&#198;').   # '&AElig;'  # &#198;
          gsub(/Ç/um,'&#199;').   # '&Ccedil;' # &#199;
          gsub(/È/um,'&#200;').   # '&Egrave;' # &#200;
          gsub(/É/um,'&#201;').   # '&Eacute;' # &#201;
          gsub(/Ê/um,'&#202;').   # '&Ecirc;'  # &#202;
          gsub(/Ë/um,'&#203;').   # '&Euml;'   # &#203;
          gsub(/Ì/um,'&#204;').   # '&Igrave;' # &#204;
          gsub(/Í/um,'&#205;').   # '&Iacute;' # &#205;
          gsub(/Î/um,'&#206;').   # '&Icirc;'  # &#206;
          gsub(/Ï/um,'&#207;').   # '&Iuml;'   # &#207;
          gsub(/Ð/um,'&#208;').   # '&ETH;'    # &#208;
          gsub(/Ñ/um,'&#209;').   # '&Ntilde;' # &#209;
          gsub(/Ò/um,'&#210;').   # '&Ograve;' # &#210;
          gsub(/Ó/um,'&#211;').   # '&Oacute;' # &#211;
          gsub(/Ô/um,'&#212;').   # '&Ocirc;'  # &#212;
          gsub(/Õ/um,'&#213;').   # '&Otilde;' # &#213;
          gsub(/Ö/um,'&#214;').   # '&Ouml;'   # &#214;
          gsub(/Ø/um,'&#216;').   # '&Oslash;' # &#216;
          gsub(/Ù/um,'&#217;').   # '&Ugrave;' # &#217;
          gsub(/Ú/um,'&#218;').   # '&Uacute;' # &#218;
          gsub(/Û/um,'&#219;').   # '&Ucirc;'  # &#219;
          gsub(/Ü/um,'&#220;').   # '&Uuml;'   # &#220;
          gsub(/Ý/um,'&#221;').   # '&Yacute;' # &#221;
          gsub(/Þ/um,'&#222;').   # '&THORN;'  # &#222;
          gsub(/ß/um,'&#223;').   # '&szlig;'  # &#223;
          gsub(/à/um,'&#224;').   # '&agrave;' # &#224;
          gsub(/á/um,'&#225;').   # '&aacute;' # &#225;
          gsub(/â/um,'&#226;').   # '&acirc;'  # &#226;
          gsub(/ã/um,'&#227;').   # '&atilde;' # &#227;
          gsub(/ä/um,'&#228;').   # '&auml;'   # &#228;
          gsub(/å/um,'&#229;').   # '&aring;'  # &#229;
          gsub(/æ/um,'&#230;').   # '&aelig;'  # &#230;
          gsub(/ç/um,'&#231;').   # '&ccedil;' # &#231;
          gsub(/è/um,'&#232;').   # '&egrave;' # &#232;
          gsub(/é/um,'&#233;').   # '&acute;'  # &#233;
          gsub(/ê/um,'&#234;').   # '&circ;'   # &#234;
          gsub(/ë/um,'&#235;').   # '&euml;'   # &#235;
          gsub(/ì/um,'&#236;').   # '&igrave;' # &#236;
          gsub(/í/um,'&#237;').   # '&acute;'  # &#237;
          gsub(/î/um,'&#238;').   # '&icirc;'  # &#238;
          gsub(/ï/um,'&#239;').   # '&iuml;'   # &#239;
          gsub(/ð/um,'&#240;').   # '&eth;'    # &#240;
          gsub(/ñ/um,'&#241;').   # '&ntilde;' # &#241;
          gsub(/ò/um,'&#242;').   # '&ograve;' # &#242;
          gsub(/ó/um,'&#243;').   # '&oacute;' # &#243;
          gsub(/ô/um,'&#244;').   # '&ocirc;'  # &#244;
          gsub(/õ/um,'&#245;').   # '&otilde;' # &#245;
          gsub(/ö/um,'&#246;').   # '&ouml;'   # &#246;
          gsub(/ø/um,'&#248;').   # '&oslash;' # &#248;
          gsub(/ù/um,'&#250;').   # '&ugrave;' # &#250;
          gsub(/ú/um,'&#251;').   # '&uacute;' # &#251;
          gsub(/û/um,'&#252;').   # '&ucirc;'  # &#252;
          gsub(/ü/um,'&#253;').   # '&uuml;'   # &#253;
          gsub(/þ/um,'&#254;').   # '&thorn;'  # &#254;
          gsub(/ÿ/um,'&#255;').   # '&yuml;'   # &#255;
          gsub(//um,'&#8216;').  # '&lsquo;'  # &#8216;
          gsub(//um,'&#8217;').  # '&rsquo;'  # &#8217;
          gsub(//um,'&#8220;').  # &ldquo;    # &#8220;
          gsub(//um,'&#8221;').  # &rdquo;    # &#8221;
          gsub(//um,'&#8211;').  # &ndash;    # &#8211;
          gsub(//um,'&#8212;').  # &mdash;    # &#8212;
          gsub(//um,'&#8733;').  # &prop;     # &#8733;
          gsub(//um,'&#8734;').  # &infin;    # &#8734;
          gsub(//um,'&#8482;').  # &trade;    # &#8482;
          gsub(//um,'&#10016;'). # &cross;    # &#10016;
          gsub(//um,' ').       # space identify
          gsub(//um,' ')       # space identify
      end
      dob=if defined? dob.obj
        dob.obj=str
        dob
      elsif dob.is_a?(String)
        str
      end
      dob
    end
  end
  def html(dob='')
    if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
      dob.obj=dob.obj.gsub(//u,' ').           # space identify
        gsub(//u,' ')           # space identify
    end
  end
  self
end

#clean(str) ⇒ Object



349
350
351
352
# File 'lib/sisu/json_shared.rb', line 349

def clean(str)
  str=str.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;').
    gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;')
end

#defaultObject



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
# File 'lib/sisu/json_shared.rb', line 86

def default
  {
    pub:   'publication',
    conv:  'convention',
    vol:   'volume',
    pg:    'page',
    cty:   'city',
    org:   'organization',
    uni:   'university',
    dept:  'department',
    fac:   'faculty',
    inst:  'institute',
    co:    'company',
    com:   'company',
    conv:  'convention',
    dt:    'date',
    y:     'year',
    m:     'month',
    d:     'day',
    ti:    'title',
    au:    'author',
    ed:    'editor', #editor?
    v:     'version', #edition
    n:     'name',
    fn:    'firstname',
    mn:    'middlename',
    ln:    'lastname',
    in:    'initials',
    qt:    'quote',
    ct:    'cite',
    ref:   'reference',
    ab:    'abreviation',
    def:   'define',
    desc:  'description',
    trans: 'translate',
  }
end

#html(dob = '') ⇒ Object



242
243
244
245
246
247
# File 'lib/sisu/json_shared.rb', line 242

def html(dob='')
  if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
    dob.obj=dob.obj.gsub(//u,' ').           # space identify
      gsub(//u,' ')           # space identify
  end
end

#markup(dob = '') ⇒ Object



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
# File 'lib/sisu/json_shared.rb', line 260

def markup(dob='')
  wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
  dob.obj=tidywords(wordlist).join(' ').strip
  unless dob.is==:table
    dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'<br>').
      gsub(/#{Mx[:br_paragraph]}/u,'<br>').
      gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>')
  end
  dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'').
    gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
    gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
    gsub(/(^|#{Mx[:gl_c]}|\s+)<\s+/,'\1&lt; ').gsub(/\s+>(\s+|$)/,' &gt;\1').
    #gsub(/#{Mx[:fa_emphasis_o]}(.+?)#{Mx[:fa_emphasis_c]}/,'<em>\1</em>'). #reinstate
    gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/m,'<b>\1</b>').
    gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/m,'<i>\1</i>').
    gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
    gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
    gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
    gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
    gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
    gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
    gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>').
    gsub(/<:pb>\s*/,''). #Fix
    gsub(/<+[-~]#>+/,'')
  if dob.is !=:code
    #embeds a red-bullet image -->
    dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
      gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
      gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
      gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>')
    dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') unless dob.is==:table
    dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,'').
      gsub(/#{Mx[:br_page_new]}\s*/,'').
      gsub(/#{Mx[:br_page_line]}\s*/,'').
      gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,'').
      gsub(/<[-~]#>/,'').
      gsub(/href="#{Xx[:segment]}/m,'href="').
      gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\.\.\/\S+?)#{Mx[:rel_c]}/,
        '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>').
      gsub(/#{Mx[:lnk_o]}([^#{Mx[:lnk_o]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{Mx[:rel_c]}]+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}:(\S+?)#{Mx[:rel_c]}/,
        '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="../\2">\1</link>').
      gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/,
        '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="#\2">\1</link>').
      gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
        %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
      gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
        %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
      gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/,
        %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}).
      gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/,
        %{<image xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:actuate="onLoad" xl:show="embed" xl:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}).
      gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
        '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\2">\1</link>'). #watch, compare html_tune
      gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
        %{#{the_url_decoration.xml_open}<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\\1">\\1</link>#{the_url_decoration.xml_close}}).
      gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
        '<link xmlns:xl="http://www.w3.org/1999/xlink" xl:type="simple" xl:href="\1">\1</link>') #escaped urls not linked, deal with later
  else
    dob.obj=dob.obj.gsub(/</m,'&lt;').gsub(/>/m,'&gt;')
  end
  if dob.of==:block
    dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'')
  end
  dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
      %{#{the_url_decoration.xml_open}\\1#{the_url_decoration.xml_close}}).
    gsub(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}").
    gsub(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}").
    gsub(/&nbsp;|#{Mx[:nbsp]}/m,'&#160;').
    gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&amp;\1') # pattern not to match
  dob
end

#markup_block(dob = '') ⇒ Object



421
422
423
424
425
426
427
428
# File 'lib/sisu/json_shared.rb', line 421

def markup_block(dob='')
  dob.obj=dob.obj.gsub(/</,'&lt;').gsub(/>/,'&gt;').
    gsub(/&lt;:?br(?:\s+\/)?&gt;/,'<br>').
    gsub(/&lt;(link xmlns:xl=".+?")&gt;/,'<\1>').
    gsub(/&lt;(\/link)&gt;/,'<\1>').
    gsub(/&lt;(\/?en)&gt;/,'<\1>')
  dob
end

#markup_docbook(dob = '') ⇒ Object

work on, initially a copy of fictionbook!



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/sisu/json_shared.rb', line 377

def markup_docbook(dob='')                                  # work on, initially a copy of fictionbook!
  if dob.is !=:code
    dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}(\d+)\s*(.+?)#{Mx[:en_a_c]}/m,'<footnote><para><!-- fn\1 -->\2</para></footnote>').
      gsub(/\\\\/,'</para><para>').
      gsub(/&/,'&amp;'). #sort
      gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
      gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1&amp; '). #sort
      gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
    dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') unless dob.is==:table
    dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
      gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
      gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
      gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
      gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
      gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
      gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
      gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
      gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
      gsub(/#{Mx[:lnk_o]}\s*(\S+?)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,
        %{#{Xx[:split]}:spaces0:<figure id="fig-\\1">\n:spaces1:<title></title>\n:spaces1:<graphic fileref="../../_sisu/image/\\1.\\2" align="center" width="50%"></graphic>\n:spaces0:</figure>#{Xx[:split]}}). # common image location, else use ./images
      gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
        '<ulink url="\2">\1</ulink>').
      gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,
        '<ulink url="\1">\1</ulink>').
      gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
      gsub(/#{Mx[:gl_bullet]}/m,''). #&nbsp; not available
      gsub(/#{Mx[:nbsp]}/,' '). #&nbsp; not available
      gsub(/<(p|br)>/,'<\1 />')
    dob.obj=clean(dob.obj)
  elsif dob.is == :code
    dob.obj=dob.obj.gsub(/&/m,'&amp;'). #sort
      gsub(/</,'&lt;').gsub(/>/,'&gt;')
  else # p dob.is ??
  end
  dob
end

#markup_fictionbook(str = '', is = '') ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/sisu/json_shared.rb', line 353

def markup_fictionbook(str='',is='')
  str=str.gsub(/#{Mx[:en_a_o]}([\d+*]+).+?#{Mx[:en_a_c]}/m,'<a xl:href="#footnote\1" type="note">[\1]</a>').
    gsub(/&/,'&amp;'). #sort
    gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
    gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1&amp; '). #sort
    gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;')
  str=str.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br>') unless is==:table
  str=str.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>').
    gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>').
    gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>').
    gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>').
    gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>').
    gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
    gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
    gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
    gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd
    gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg|gif)).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/m,'<image xl:href="#\1" />').
    gsub(/#{Mx[:url_o]}(.+?)#{Mx[:url_c]}/,"#{Dx[:url_o]}\\1#{Dx[:url_c]}").
    gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>').
    gsub(/#{Mx[:gl_bullet]}/m,''). #&nbsp; not available
    gsub(/#{Mx[:nbsp]}/,' '). #&nbsp; not available
    gsub(/<(p|br)>/,'<\1 />')
  clean(str)
end

#markup_group(dob = '') ⇒ Object



413
414
415
416
417
418
419
420
# File 'lib/sisu/json_shared.rb', line 413

def markup_group(dob='')
  dob.obj=dob.obj.gsub(/</,'&lt;').gsub(/>/,'&gt;').
    gsub(/&lt;:?br(?:\s+\/)?&gt;/,'<br>').
    gsub(/&lt;(link xmlns:xl=".+?")&gt;/,'<\1>').
    gsub(/&lt;(\/link)&gt;/,'<\1>').
    gsub(/&lt;(\/?en)&gt;/,'<\1>')
  dob
end

#markup_light(dob = '') ⇒ Object



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/sisu/json_shared.rb', line 331

def markup_light(dob='')
  dob.obj=dob.obj.gsub(/\/\{(.+?)\}\//,'<i>\1</i>').
    gsub(/[*!]\{(.+?)\}[*!]/,'<b>\1</b>').
    gsub(/_\{(.+?)\}_/,'<u>\1</u>').
    gsub(/-\{(.+?)\}-/,'<del>\1</del>').
    gsub(/<br(\s*\/)?>/,'<br>').
    gsub(/<:pb>\s*/,'').
    gsub(/<[-~]#>/,'').
    gsub(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1&amp; '). #sort
    gsub(/&([^;]{1,5})/,'&amp;\1'). #sort, rough estimate, revisit #WATCH found in node not sax
    gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,
      "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>").
    gsub(/&nbsp;|#{Mx[:nbsp]}/,'&#160;').
    gsub(/;&([^#]|(?:[^gl][^t]|[^a][^m][^p]|[^n][^b][^s][^p])[^;])/,';&amp;\1') # pattern not to match
  wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17
  dob.obj=tidywords(wordlist).join(' ').strip
  dob
end

#semantic_tagsObject



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
# File 'lib/sisu/json_shared.rb', line 85

def semantic_tags
  def default
    {
      pub:   'publication',
      conv:  'convention',
      vol:   'volume',
      pg:    'page',
      cty:   'city',
      org:   'organization',
      uni:   'university',
      dept:  'department',
      fac:   'faculty',
      inst:  'institute',
      co:    'company',
      com:   'company',
      conv:  'convention',
      dt:    'date',
      y:     'year',
      m:     'month',
      d:     'day',
      ti:    'title',
      au:    'author',
      ed:    'editor', #editor?
      v:     'version', #edition
      n:     'name',
      fn:    'firstname',
      mn:    'middlename',
      ln:    'lastname',
      in:    'initials',
      qt:    'quote',
      ct:    'cite',
      ref:   'reference',
      ab:    'abreviation',
      def:   'define',
      desc:  'description',
      trans: 'translate',
    }
  end
  self
end

#tidywords(wordlist) ⇒ Object



250
251
252
253
254
255
256
257
258
259
# File 'lib/sisu/json_shared.rb', line 250

def tidywords(wordlist)
  wordlist_new=[]
  wordlist.each do |x|
    #imperfect solution will not catch all possible cases
    x=x.gsub(/&/,'&amp;') unless x =~/&\S+;/
    x=x.gsub(/&([A-Z])/,'&amp;\1')
    wordlist_new << x
  end
  wordlist_new
end

#utf8(dob = '') ⇒ Object



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
# File 'lib/sisu/json_shared.rb', line 126

def utf8(dob='')
  if @sys.locale =~/utf-?8/i # instead ucs for utf8 # String#encode Iñtërnâtiônàlizætiøn
    str=if defined? dob.obj then dob.obj
    elsif dob.is_a?(String) then dob
    end
    if str
      #¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûü
      #¢£¥§©ª«®°±²³µ¶¹º»¼½¾×÷
      str=str.gsub(/</um,'&#60;').    # '&lt;'     # &#060;
        gsub(/>/um,'&#62;').    # '&gt;'     # &#062;
        gsub(/¢/um,'&#162;').   # '&cent;'   # &#162;
        gsub(/£/um,'&#163;').   # '&pound;'  # &#163;
        gsub(/¥/um,'&#165;').   # '&yen;'    # &#165;
        gsub(/§/um,'&#167;').   # '&sect;'   # &#167;
        gsub(/©/um,'&#169;').   # '&copy;'   # &#169;
        gsub(/ª/um,'&#170;').   # '&ordf;'   # &#170;
        gsub(/«/um,'&#171;').   # '&laquo;'  # &#171;
        gsub(/®/um,'&#174;').   # '&reg;'    # &#174;
        gsub(/°/um,'&#176;').   # '&deg;'    # &#176;
        gsub(/±/um,'&#177;').   # '&plusmn;' # &#177;
        gsub(/²/um,'&#178;').   # '&sup2;'   # &#178;
        gsub(/³/um,'&#179;').   # '&sup3;'   # &#179;
        gsub(/µ/um,'&#181;').   # '&micro;'  # &#181;
        gsub(//um,'&#182;').   # '&para;'   # &#182;
        gsub(/¹/um,'&#185;').   # '&sup1;'   # &#185;
        gsub(/º/um,'&#186;').   # '&ordm;'   # &#186;
        gsub(/»/um,'&#187;').   # '&raquo;'  # &#187;
        gsub(/¼/um,'&#188;').   # '&frac14;' # &#188;
        gsub(/½/um,'&#189;').   # '&frac12;' # &#189;
        gsub(/¾/um,'&#190;').   # '&frac34;' # &#190;
        gsub(/×/um,'&#215;').   # '&times;'  # &#215;
        gsub(/÷/um,'&#247;').   # '&divide;' # &#247;
        gsub(/¿/um,'&#191;').   # '&iquest;' # &#191;
        gsub(/À/um,'&#192;').   # '&Agrave;' # &#192;
        gsub(/Á/um,'&#193;').   # '&Aacute;' # &#193;
        gsub(/Â/um,'&#194;').   # '&Acirc;'  # &#194;
        gsub(/Ã/um,'&#195;').   # '&Atilde;' # &#195;
        gsub(/Ä/um,'&#196;').   # '&Auml;'   # &#196;
        gsub(/Å/um,'&#197;').   # '&Aring;'  # &#197;
        gsub(/Æ/um,'&#198;').   # '&AElig;'  # &#198;
        gsub(/Ç/um,'&#199;').   # '&Ccedil;' # &#199;
        gsub(/È/um,'&#200;').   # '&Egrave;' # &#200;
        gsub(/É/um,'&#201;').   # '&Eacute;' # &#201;
        gsub(/Ê/um,'&#202;').   # '&Ecirc;'  # &#202;
        gsub(/Ë/um,'&#203;').   # '&Euml;'   # &#203;
        gsub(/Ì/um,'&#204;').   # '&Igrave;' # &#204;
        gsub(/Í/um,'&#205;').   # '&Iacute;' # &#205;
        gsub(/Î/um,'&#206;').   # '&Icirc;'  # &#206;
        gsub(/Ï/um,'&#207;').   # '&Iuml;'   # &#207;
        gsub(/Ð/um,'&#208;').   # '&ETH;'    # &#208;
        gsub(/Ñ/um,'&#209;').   # '&Ntilde;' # &#209;
        gsub(/Ò/um,'&#210;').   # '&Ograve;' # &#210;
        gsub(/Ó/um,'&#211;').   # '&Oacute;' # &#211;
        gsub(/Ô/um,'&#212;').   # '&Ocirc;'  # &#212;
        gsub(/Õ/um,'&#213;').   # '&Otilde;' # &#213;
        gsub(/Ö/um,'&#214;').   # '&Ouml;'   # &#214;
        gsub(/Ø/um,'&#216;').   # '&Oslash;' # &#216;
        gsub(/Ù/um,'&#217;').   # '&Ugrave;' # &#217;
        gsub(/Ú/um,'&#218;').   # '&Uacute;' # &#218;
        gsub(/Û/um,'&#219;').   # '&Ucirc;'  # &#219;
        gsub(/Ü/um,'&#220;').   # '&Uuml;'   # &#220;
        gsub(/Ý/um,'&#221;').   # '&Yacute;' # &#221;
        gsub(/Þ/um,'&#222;').   # '&THORN;'  # &#222;
        gsub(/ß/um,'&#223;').   # '&szlig;'  # &#223;
        gsub(/à/um,'&#224;').   # '&agrave;' # &#224;
        gsub(/á/um,'&#225;').   # '&aacute;' # &#225;
        gsub(/â/um,'&#226;').   # '&acirc;'  # &#226;
        gsub(/ã/um,'&#227;').   # '&atilde;' # &#227;
        gsub(/ä/um,'&#228;').   # '&auml;'   # &#228;
        gsub(/å/um,'&#229;').   # '&aring;'  # &#229;
        gsub(/æ/um,'&#230;').   # '&aelig;'  # &#230;
        gsub(/ç/um,'&#231;').   # '&ccedil;' # &#231;
        gsub(/è/um,'&#232;').   # '&egrave;' # &#232;
        gsub(/é/um,'&#233;').   # '&acute;'  # &#233;
        gsub(/ê/um,'&#234;').   # '&circ;'   # &#234;
        gsub(/ë/um,'&#235;').   # '&euml;'   # &#235;
        gsub(/ì/um,'&#236;').   # '&igrave;' # &#236;
        gsub(/í/um,'&#237;').   # '&acute;'  # &#237;
        gsub(/î/um,'&#238;').   # '&icirc;'  # &#238;
        gsub(/ï/um,'&#239;').   # '&iuml;'   # &#239;
        gsub(/ð/um,'&#240;').   # '&eth;'    # &#240;
        gsub(/ñ/um,'&#241;').   # '&ntilde;' # &#241;
        gsub(/ò/um,'&#242;').   # '&ograve;' # &#242;
        gsub(/ó/um,'&#243;').   # '&oacute;' # &#243;
        gsub(/ô/um,'&#244;').   # '&ocirc;'  # &#244;
        gsub(/õ/um,'&#245;').   # '&otilde;' # &#245;
        gsub(/ö/um,'&#246;').   # '&ouml;'   # &#246;
        gsub(/ø/um,'&#248;').   # '&oslash;' # &#248;
        gsub(/ù/um,'&#250;').   # '&ugrave;' # &#250;
        gsub(/ú/um,'&#251;').   # '&uacute;' # &#251;
        gsub(/û/um,'&#252;').   # '&ucirc;'  # &#252;
        gsub(/ü/um,'&#253;').   # '&uuml;'   # &#253;
        gsub(/þ/um,'&#254;').   # '&thorn;'  # &#254;
        gsub(/ÿ/um,'&#255;').   # '&yuml;'   # &#255;
        gsub(//um,'&#8216;').  # '&lsquo;'  # &#8216;
        gsub(//um,'&#8217;').  # '&rsquo;'  # &#8217;
        gsub(//um,'&#8220;').  # &ldquo;    # &#8220;
        gsub(//um,'&#8221;').  # &rdquo;    # &#8221;
        gsub(//um,'&#8211;').  # &ndash;    # &#8211;
        gsub(//um,'&#8212;').  # &mdash;    # &#8212;
        gsub(//um,'&#8733;').  # &prop;     # &#8733;
        gsub(//um,'&#8734;').  # &infin;    # &#8734;
        gsub(//um,'&#8482;').  # &trade;    # &#8482;
        gsub(//um,'&#10016;'). # &cross;    # &#10016;
        gsub(//um,' ').       # space identify
        gsub(//um,' ')       # space identify
    end
    dob=if defined? dob.obj
      dob.obj=str
      dob
    elsif dob.is_a?(String)
      str
    end
    dob
  end
end

#xml_sem_block_paired(matched) ⇒ Object

colon depth: many, recurs



429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/sisu/json_shared.rb', line 429

def xml_sem_block_paired(matched) # colon depth: many, recurs
  matched=matched.gsub(/\b(au):\{(.+?)\}:\1\b/m,  %{<sem:#{@ab[:au]} depth="many">\\2</sem:#{@ab[:au]}>}).
    gsub(/\b(vol):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:vol]} depth="many">\\2</sem:#{@ab[:vol]}>}).
    gsub(/\b(pub):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:pub]} depth="many">\\2</sem:#{@ab[:pub]}>}).
    gsub(/\b(ref):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:ref]} depth="many">\\2</sem:#{@ab[:ref]}>}).
    gsub(/\b(desc):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:desc]} depth="many">\\2</sem:#{@ab[:desc]}>}).
    gsub(/\b(conv):\{(.+?)\}:\1\b/m,%{<sem:#{@ab[:conv]} depth="many">\\2</sem:#{@ab[:conv]}>}).
    gsub(/\b(ct):\{(.+?)\}:\1\b/m,  %{<sem:#{@ab[:ct]} depth="many">\\2</sem:#{@ab[:ct]}>}).
    gsub(/\b(cty):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:cty]} depth="many">\\2</sem:#{@ab[:cty]}>}).
    gsub(/\b(org):\{(.+?)\}:\1\b/m, %{<sem:#{@ab[:org]} depth="many">\\2</sem:#{@ab[:org]}>}).
    gsub(/\b(dt):\{(.+?)\}:\1\b/m,  %{<sem:#{@ab[:dt]} depth="many">\\2</sem:#{@ab[:dt]}>}).
    gsub(/\b(n):\{(.+?)\}:\1\b/m,   %{<sem:#{@ab[:n]} depth="many">\\2</sem:#{@ab[:n]}>}).
    gsub(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m,'<sem:\1 depth="many">\2</sem:\1>')
end

#xml_semantic_tags(dob) ⇒ Object



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/sisu/json_shared.rb', line 443

def xml_semantic_tags(dob)
  if @md.sem_tag
    dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
    dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
    dob.obj.gsub!(/([a-z]+(?:[_:.][a-z]+)*)(?::\{(.+?)\}:\1)/m) {|c| xml_sem_block_paired(c) }
    dob.obj=dob.obj.gsub(/:\{(.+?)\}:au\b/m,             %{<sem:#{@ab[:au]} depth="one">\\1</sem:#{@ab[:au]}>}).
      gsub(/:\{(.+?)\}:n\b/m,              %{<sem:#{@ab[:n]} depth="one">\\1</sem:#{@ab[:n]}>}).
      gsub(/:\{(.+?)\}:ti\b/m,             %{<sem:#{@ab[:ti]} depth="one">\\1</sem:#{@ab[:ti]}>}).
      gsub(/:\{(.+?)\}:ref\b/m,            %{<sem:#{@ab[:ref]} depth="one">\\1</sem:#{@ab[:ref]}>}).
      gsub(/:\{(.+?)\}:desc\b/m,           %{<sem:#{@ab[:desc]} depth="one">\\1</sem:#{@ab[:desc]}>}).
      gsub(/:\{(.+?)\}:cty\b/m,            %{<sem:#{@ab[:cty]} depth="one">\\1</sem:#{@ab[:cty]}>}).
      gsub(/:\{(.+?)\}:org\b/m,            %{<sem:#{@ab[:org]} depth="one">\\1</sem:#{@ab[:org]}>}).
      gsub(/:\{(.+?)\}:([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="one">\1</sem:\2>').
      gsub(/;\{([^}]+(?![;]))\};ti\b/m,    %{<sem:#{@ab[:ti]} depth="zero">\\1</sem:#{@ab[:ti]}>}).
      gsub(/;\{([^}]+(?![;]))\};qt\b/m,    %{<sem:#{@ab[:qt]} depth="zero">\\1</sem:#{@ab[:qt]}>}).
      gsub(/;\{([^}]+(?![;]))\};ref\b/m,   %{<sem:#{@ab[:ref]} depth="zero">\\1</sem:#{@ab[:ref]}>}).
      gsub(/;\{([^}]+(?![;]))\};ed\b/m,    %{<sem:#{@ab[:ed]} depth="zero">\\1</sem:#{@ab[:ed]}>}).
      gsub(/;\{([^}]+(?![;]))\};v\b/m,     %{<sem:#{@ab[:v]} depth="zero">\\1</sem:#{@ab[:v]}>}).
      gsub(/;\{([^}]+(?![;]))\};desc\b/m,  %{<sem:#{@ab[:desc]} depth="zero">\\1</sem:#{@ab[:desc]}>}).
      gsub(/;\{([^}]+(?![;]))\};def\b/m,   %{<sem:#{@ab[:def]} depth="zero">\\1</sem:#{@ab[:def]}>}).
      gsub(/;\{([^}]+(?![;]))\};trans\b/m, %{<sem:#{@ab[:trans]} depth="zero">\\1</sem:#{@ab[:trans]}>}).
      gsub(/;\{([^}]+(?![;]))\};y\b/m,     %{<sem:#{@ab[:y]} depth="zero">\\1</sem:#{@ab[:y]}>}).
      gsub(/;\{([^}]+(?![;]))\};ab\b/m,    %{<sem:#{@ab[:ab]} depth="zero">\\1</sem:#{@ab[:ab]}>}).
      gsub(/;\{([^}]+(?![;]))\};pg\b/m,    %{<sem:#{@ab[:pg]} depth="zero">\\1</sem:#{@ab[:pg]}>}).
      gsub(/;\{([^}]+(?![;]))\};fn?\b/m,   %{<sem:#{@ab[:fn]} depth="zero">\\1</sem:#{@ab[:fn]}>}).
      gsub(/;\{([^}]+(?![;]))\};mn?\b/m,   %{<sem:#{@ab[:mn]} depth="zero">\\1</sem:#{@ab[:mn]}>}).
      gsub(/;\{([^}]+(?![;]))\};ln?\b/m,   %{<sem:#{@ab[:ln]} depth="zero">\\1</sem:#{@ab[:ln]}>}).
      gsub(/;\{([^}]+(?![;]))\};in\b/m,    %{<sem:#{@ab[:in]} depth="zero">\\1</sem:#{@ab[:in]}>}).
      gsub(/;\{([^}]+(?![;]))\};uni\b/m,   %{<sem:#{@ab[:uni]} depth="zero">\\1</sem:#{@ab[:uni]}>}).
      gsub(/;\{([^}]+(?![;]))\};fac\b/m,   %{<sem:#{@ab[:fac]} depth="zero">\\1</sem:#{@ab[:fac]}>}).
      gsub(/;\{([^}]+(?![;]))\};inst\b/m,  %{<sem:#{@ab[:inst]} depth="zero">\\1</sem:#{@ab[:inst]}>}).
      gsub(/;\{([^}]+(?![;]))\};dept\b/m,  %{<sem:#{@ab[:dpt]} depth="zero">\\1</sem:#{@ab[:dept]}>}).
      gsub(/;\{([^}]+(?![;]))\};org\b/m,   %{<sem:#{@ab[:org]} depth="zero">\\1</sem:#{@ab[:org]}>}).
      gsub(/;\{([^}]+(?![;]))\};com?\b/m,  %{<sem:#{@ab[:com]} depth="zero">\\1</sem:#{@ab[:com]}>}).
      gsub(/;\{([^}]+(?![;]))\};cty\b/m,   %{<sem:#{@ab[:cty]} depth="zero">\\1</sem:#{@ab[:cty]}>}).
      gsub(/;\{([^}]+(?![;]))\};([a-z]+(?:[_:.][a-z]+)*)/m,'<sem:\2 depth="zero">\1</sem:\2>')
  end
  dob
end