diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-06-11 21:52:44 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-06-11 21:52:48 -0400 |
commit | ba7bc57883b444ae447ac8a15ce37c9750d8f3de (patch) | |
tree | 1035705f4bc4dd362be915ddf35d250e2bb71adb | |
parent | vim syntax, highlight header @make: :texpdf_font: (diff) |
dal_syntax, apply fontfaces also to tables
* bold, italics, superscript etc.
-rw-r--r-- | lib/sisu/v2/dal_syntax.rb | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index 0b7c6541..5e04730f 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -234,9 +234,51 @@ module SiSU_Syntax end dob end + def fontface(dob) + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? + dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|\(|\>|\S)9\{(.+?)\}9/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript + dob.obj.gsub!(/(^|[^\\]),\{(.+?)\},/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #deleted text + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}\\3") #underscore single word, watch (made more complicated by url decoration escape tag (_url)) + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+)-([^{]\S+?)-( |$)/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}\\3") #underscore single word, watch + dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + dob + end def bodymarkup(dob) # << http://www.jus.uio.no/sisu/sisu_markup_table/markup >> # See: data/sisu/sample/document_samples_sisu_markup/ + ## fontface # *{emphasis}* e{emphasis}e <strong>emphasis</strong> # !{bold text}! b{bold}b <b>bold text</b> # _{underline}_ u{underline}u <u>underline</u> @@ -246,6 +288,7 @@ module SiSU_Syntax # ,{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 @@ -350,44 +393,7 @@ module SiSU_Syntax %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) end dob.obj.gsub!(/<:?p([nb])>/,"#{Mx[:fa_o]}p\\1#{Mx[:fa_c]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)\*\{(.+?)\}\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasis - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\(|\>)\/\{(.+?)\}\//, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|#{Mx[:br_line]}|#{Mx[:br_paragraph]}|[\(\[\{]|\>)_\{(.+?)\}_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? - dob.obj.gsub!(/(^|[^\\])\^\{(.+?)\}\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|\(|\>|\S)9\{(.+?)\}9/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript - dob.obj.gsub!(/(^|[^\\]),\{(.+?)\},/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}") #subscript - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}") #inserted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #strikethrough - deleted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}") #deleted text - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}") #emphasise single word, watch - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold single word, watch - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([^a-zA-Z0-9]|[ ,.;:'"~$]|$)/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3") #italics single word, watch - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_([.,!'")]?(?:\s|$))/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}\\3") #underscore single word, watch (made more complicated by url decoration escape tag (_url)) - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+)-([^{]\S+?)-( |$)/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}\\3") #underscore single word, watch - dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + dob=fontface(dob) dob.obj.gsub!(/<[:e]\s+(.+?)!?>/, "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") #not tested dob.obj.gsub!(/^\s*_\*\s*/, @@ -417,6 +423,7 @@ module SiSU_Syntax dob.obj.gsub!(/\{\s*(.+?)\s*\}(image)/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image elsif dob.is=='table' + dob=fontface(dob) elsif dob.is =='code' # /^<:code>/ #should be enough # underscore used as escape for angle brackets dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') dob.obj.gsub!(/([<>])/,'_\1') |