aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/ao_syntax.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v6/ao_syntax.rb')
-rw-r--r--lib/sisu/v6/ao_syntax.rb66
1 files changed, 42 insertions, 24 deletions
diff --git a/lib/sisu/v6/ao_syntax.rb b/lib/sisu/v6/ao_syntax.rb
index 68720aca..cdd4a389 100644
--- a/lib/sisu/v6/ao_syntax.rb
+++ b/lib/sisu/v6/ao_syntax.rb
@@ -143,7 +143,8 @@ module SiSU_AO_Syntax
&& dob.is !=:comment \
&& dob.is !=:code \
&& dob.is !=:table
- dob.obj=dob.obj.gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}").
+ dob.obj=dob.obj.
+ gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}").
gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}").
gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}").
gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated
@@ -190,7 +191,8 @@ module SiSU_AO_Syntax
dob
end
def embolden(given)
- given=given.gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
+ given=given.
+ gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
"#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2").
gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/,
"#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}").
@@ -204,7 +206,8 @@ module SiSU_AO_Syntax
"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
end
def italicise(given)
- given=given.gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
+ given=given.
+ gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/,
"#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2").
gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/,
"#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2").
@@ -282,11 +285,13 @@ module SiSU_AO_Syntax
word.each do |w|
unless /#{@manmkp_bold}|#{@http_m}/.match(w)
if defined? @md.bold_match_list[:regx] \
- and @md.bold_match_list[:regx] #document header: @bold: [bold word list]
- w=w.gsub(@md.bold_match_list[:regx],"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
+ and @md.bold_match_list[:regx] #document header: @bold: [bold word list]
+ w=w.gsub(@md.bold_match_list[:regx],
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
elsif defined? @vz.markup_make_bold \
and @vz.markup_make_bold #defaults adjusted bold word list
- w=w.gsub(@vz.markup_make_bold,"#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
+ w=w.gsub(@vz.markup_make_bold,
+ "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}")
end
else
w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/
@@ -324,7 +329,9 @@ module SiSU_AO_Syntax
else ''
end
txt="#{lead_break}#{fce}\{" + txt.split(Mx[:br_nl]).join("\}#{fce}#{Mx[:br_nl]}#{fce}\{") + "\}#{fce}"
- dob.obj=dob.obj.sub(/(?:^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m,"#{lead}#{txt}")
+ dob.obj=dob.obj.
+ sub(/(?:^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m,
+ "#{lead}#{txt}")
dob
else dob
end
@@ -336,7 +343,8 @@ module SiSU_AO_Syntax
def fontface(dob)
leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。「‹«¿¡]|\>/
dob=fontface_lines(dob,leader)
- dob.obj=dob.obj.gsub(/(#{leader})\*\{(.+?)\}\*/m,
+ dob.obj=dob.obj.
+ gsub(/(#{leader})\*\{(.+?)\}\*/m,
"\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis
gsub(/(#{leader})!\{(.+?)\}!/m,
"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold
@@ -399,18 +407,20 @@ module SiSU_AO_Syntax
word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit
if word
word.each do |w| # _ - / # | : ! ^ ~
- unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!!
- w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character
+ unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!!
+ w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character
end
- w=w.gsub(/^\<$/,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character
+ w=w.gsub(/^\<$/,
+ "#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character
line_array << w
end
dob.obj=line_array.join(' ')
dob.obj=dob.obj.strip
end
- dob.obj=dob.obj.gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators
+ dob.obj=dob.obj.
+ gsub(/^([*#-.]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators
gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]).
- gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify
+ gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify
gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c])
if dob.is ==:heading \
and dob.ln ==0
@@ -431,12 +441,14 @@ module SiSU_AO_Syntax
dob.obj=if dob.lv =~/[23]/ \
and defined? @md.creator.author \
and @md.creator.author
- dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.creator.author}")
+ dob.obj.
+ gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,
+ "\\1#{@md.creator.author}")
else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1')
end
end
end
- dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup
+ dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup
gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image').
gsub(/<!(\S+)!>/,'<:\1>'). #escaped special character
gsub(/&nbsp;/,"#{Mx[:nbsp]}"). #escaped special character
@@ -463,15 +475,18 @@ module SiSU_AO_Syntax
gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character
if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m
if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m
- dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,
- "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch
+ dob.obj=dob.obj.
+ gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch
end
if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m
- dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
- "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ")
+ dob.obj=dob.obj.
+ gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ")
end
- dob.obj=dob.obj.gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
- "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline)
+ dob.obj=dob.obj.
+ gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/,
+ "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline)
gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
%{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}).
gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m,
@@ -486,7 +501,8 @@ module SiSU_AO_Syntax
%{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3})
end
dob=fontface(dob)
- dob.obj=dob.obj.gsub(/<[:e]\s+(.+?)!?>/,
+ dob.obj=dob.obj.
+ gsub(/<[:e]\s+(.+?)!?>/,
"#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested
gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/,
"\\1#{Mx[:gl_bullet]}"). #bullets, shortcut
@@ -526,7 +542,8 @@ module SiSU_AO_Syntax
elsif dob.is==:table
dob=fontface(dob)
elsif dob.is ==:code
- dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ').
+ dob.obj=dob.obj.
+ gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ').
gsub(/(^|#{Mx[:gl_c]}|\s)&lt;(br(?: \/)?)&gt;([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy
if dob.number_
codeline=[]
@@ -569,7 +586,8 @@ module SiSU_AO_Syntax
# +2 <!i2!>
puts 'tech'
@data.each do |line|
- line=line.gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/,
+ line=line.
+ gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/,
"\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis
gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/,
"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold