From bcbbdf4b3e151fd35b007a80aaf914110e8880c7 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:35:47 -0400 Subject: css (for html), right pane dark, distinguish from selected content --- lib/sisu/v2/css.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/sisu/v2/css.rb b/lib/sisu/v2/css.rb index e187d24a..f088c44e 100644 --- a/lib/sisu/v2/css.rb +++ b/lib/sisu/v2/css.rb @@ -329,6 +329,7 @@ WOK right: 0px; margin-left: 75%; width: 20%; + background-color: #aaaaaa; } .norm, .bold, .verse, .group, .alt { -- cgit v1.2.3 From 15a3a15a549853ac0d7c3f1e81a10f9badb9069a Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:37:22 -0400 Subject: minor (cosmetic, & info retention) --- lib/sisu/v2/constants.rb | 2 +- lib/sisu/v2/xml_tables.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/constants.rb b/lib/sisu/v2/constants.rb index 7fc3b056..9eec8370 100644 --- a/lib/sisu/v2/constants.rb +++ b/lib/sisu/v2/constants.rb @@ -110,7 +110,7 @@ Rx[:lv],Rx[:lv_1],Rx[:lv_2],Rx[:lv_3],Rx[:lv_4],Rx[:lv_5],Rx[:lv_6],Rx[:lv_7],Rx Rx[:meta]=/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}/ Dx[:url_o]='‹'; Dx[:url_c]='›' Dx[:url_o_xml]='<'; Dx[:url_c_xml]='>' -Dx[:rel_o]='‹'; Dx[:rel_c]='›' +Dx[:rel_o]='‹'; Dx[:rel_c]='›' # Dx[:rel_o]='「'; Dx[:rel_c]='」' Tex[:backslash]="\\\\" Tex[:backslash]="\\\\" Tex[:tilde]='\\\\\\~' diff --git a/lib/sisu/v2/xml_tables.rb b/lib/sisu/v2/xml_tables.rb index f5b2845c..71bcb37e 100644 --- a/lib/sisu/v2/xml_tables.rb +++ b/lib/sisu/v2/xml_tables.rb @@ -142,9 +142,7 @@ module SiSU_Tables #{tablefoot}} end def table_row(inf,h=false) - bold=if h; '' - else '' - end + bold=h ? '' : '' %{ #{bold}} @@ -155,9 +153,7 @@ module SiSU_Tables end end def table_row_close(h=false) - bold_close=if h; '' - else '' - end + bold_close=h ? '' : '' "#{bold_close}" end def table -- cgit v1.2.3 From 4e298b688a7c8e2967865fdba2a13f382cadec39 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:39:03 -0400 Subject: param, fix breakage on malformed sisu identifier (top header line) '% SiSU ...' [where badly formed] --- lib/sisu/v2/param.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index fbc4ccde..a4ac4589 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -868,8 +868,8 @@ module SiSU_Param fns_array=@data.dup skip unless fns_array # consider @markup_version=SiSU_Markup_type::Markup_identify.new(fns_array,@opt).markup_version? #% determine markup version - if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?[\d.]*|sisu-[\d.]+)$/ #check markup and markup version - if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)[\d.]+$/ #check markup and markup version + if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?[\d.]*|sisu-[\d.]+)$/ #check markup and markup version + if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)(?:[0-9]+)?(?:\.[0-9]+)?(?:\.[0-9]+)?$/ #check markup and markup version @markup_version_declared=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([\d.]+)$/)[1] sm_a,sm_b,sm_c=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([0-9]+)?(?:\.([0-9]+))?(?:\.([0-9]+))?$/)[1..3] sm_c ||=0 -- cgit v1.2.3 From 4ceb5ecac549b1525c5301ea805c82fa321208a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:46:50 -0400 Subject: texpdf set/select font, default "Liberation Sans" * requires that Liberation fonts be installed, hence version bump * set font in: sisurc.yml under default: texpdf_font: marked up document under @make: :texpdf_font: default if nothing set "Liberation Sans" --- lib/sisu/v2/param.rb | 29 +++++++++++++++++------------ lib/sisu/v2/sysenv.rb | 14 +++++++++++--- lib/sisu/v2/texpdf_format.rb | 1 + 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index a4ac4589..98478626 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -148,8 +148,8 @@ module SiSU_Param end end class Md - def initialize(str,opt) - @s,@opt=str,opt + def initialize(str,opt,env) + @s,@opt,@env=str,opt,env end def validate_length(s,l,n) #s=(s.length <= l) ? s : nil @@ -668,6 +668,11 @@ module SiSU_Param else nil end end + def texpdf_font + @h['texpdf_font'] && (@h['texpdf_font']=~/\S{3,}/) \ + ? @h['texpdf_font'] \ + : @env.font.texpdf + end def skin @h['skin'] end @@ -922,23 +927,23 @@ module SiSU_Param case para when /^@ocn:\s+(.+?)$/m; @ocn=$1 #% processing when /^@title:(.+)/m #% metainfo DC - @title=Md.new($1.strip,@opt).title + @title=Md.new($1.strip,@opt,@env).title when /^@creator:(.+)/m #% metainfo DC - @creator=Md.new($1.strip,@opt).creator + @creator=Md.new($1.strip,@opt,@env).creator @authorship=@author=@creator.author @authors=@creator.author_detail when /^@classify:(.+)/m; classify=$1 - @classify=Md.new($1.strip,@opt).classify + @classify=Md.new($1.strip,@opt,@env).classify when /^@publisher:\s+(.+)/m - @publisher=Md.new($1.strip,@opt).current_publisher + @publisher=Md.new($1.strip,@opt,@env).current_publisher when /^@original:(.+)/m - @original=Md.new($1.strip,@opt).original + @original=Md.new($1.strip,@opt,@env).original @source=@original.source when /^@writing_focus[:.]nationality:\s+(.+?)$/; @writing_focus=$1 # e.g. Finland (where and article on Finnish law) when /^@date:(.+)/m #% metainfo DC - @date=Md.new($1.strip,@opt).date + @date=Md.new($1.strip,@opt,@env).date when /^@rights:(.+)/m; #@rights=$1.gsub(/<(?:\/\s*)?br(?:\s*\/)?>/,Mx[:br_line]) #% metainfo DC copyright, public domain, copyleft, creative commons, etc. - @rights=Md.new($1.strip,@opt).rights + @rights=Md.new($1.strip,@opt,@env).rights when /^@papersize:\s+(.+?)$/m #% metainfo DC l=$1 if @mod.inspect !~/--papersize[=-]\S+/ @@ -946,7 +951,7 @@ module SiSU_Param @papersize=l end when /^@make:(.+)/m #% metainfo DC - @make=Md.new($1.strip,@opt).make + @make=Md.new($1.strip,@opt,@env).make if defined? @make.breaks \ and @make.breaks[:page_new] #clearpage @pagenew=@make.breaks[:page_new] @@ -978,7 +983,7 @@ module SiSU_Param @man_section=(defined? @make.manpage.section) ? @make.manpage.section : 1 end when /^@links:\s+(.+?)\Z/m #% processing - doc_links=Md.new($1.strip,@opt).links + doc_links=Md.new($1.strip,@opt,@env).links count=1 @lnk=[] doc_links.each do |doc_link| @@ -989,7 +994,7 @@ module SiSU_Param end end when /^@notes?:\s(.+)/ #% metainfo - Md.new($1.strip,@opt).notes + Md.new($1.strip,@opt,@env).notes when /^@base_program:\s+(.+?)$/; @base_program=$1 #% processing end @lv1 ||=/^1~/ diff --git a/lib/sisu/v2/sysenv.rb b/lib/sisu/v2/sysenv.rb index 4daccbcd..8a9e38be 100644 --- a/lib/sisu/v2/sysenv.rb +++ b/lib/sisu/v2/sysenv.rb @@ -1265,6 +1265,14 @@ WOK end end end + def font + def texpdf + (defined? @rc['default']['texpdf_font']) \ + ? @rc['default']['texpdf_font'] \ + : 'Liberation Sans' #'Liberation Sans' #'Liberation Serif' + end + self + end def path #dir def home @sys.home @@ -1329,9 +1337,9 @@ WOK @yamlrc_dir end def man #check use - if defined? @rc['webserv']['man']; "#{webserv}/#{@rc['webserv']['man']}" - else defaults[:webserv_man] - end + (defined? @rc['webserv']['man']) \ + ? "#{webserv}/#{@rc['webserv']['man']}" \ + : defaults[:webserv_man] end def webserv_path #testing, check need, remove webserv diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index b53864ec..87a946d0 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -635,6 +635,7 @@ module SiSU_TeX_Pdf \\usepackage{polyglossia, ucs, fontspec, xltxtra, xunicode} \\setmainlanguage{#{tex_head_lang}} \\setotherlanguage{english} +\\setmainfont{#{@md.make.texpdf_font}} WOK when /pdf/ if @md.file_encoding =~ /iso-?8859/i #% iso8859 -- cgit v1.2.3 From ba7bc57883b444ae447ac8a15ce37c9750d8f3de Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:52:44 -0400 Subject: dal_syntax, apply fontfaces also to tables * bold, italics, superscript etc. --- lib/sisu/v2/dal_syntax.rb | 83 +++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 38 deletions(-) (limited to 'lib') 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 emphasis # !{bold text}! b{bold}b bold text # _{underline}_ u{underline}u underline @@ -246,6 +288,7 @@ module SiSU_Syntax # ,{subscript}, subscript # +{inserted text}+ inserted text # -{deleted text}- deleted text + # # {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!(/(?:
|
)\s*_([12])\s+/,'
<: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') -- cgit v1.2.3 From cb4968bec9b2e8a0ba75a9fa906f87791ba288ae Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 21:55:00 -0400 Subject: texpdf_format: add fontface to tables * tables add fontfaces (e.g. bold, italics, superscript) --- lib/sisu/v2/texpdf_format.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index 87a946d0..e756aa03 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -107,6 +107,19 @@ module SiSU_TeX_Pdf def ocn_display(dob) "\\begin{tiny}\\hspace{0mm}\\end{tiny}{\\marginpar{\\begin{tiny}\\hspace{0mm}\\hypertarget{#{dob.ocn}}{#{dob.ocn}}\\end{tiny}}}" #ocn object citation numbering end + def table_special_characters(r) + r.gsub!(/#{Mx[:tc_p]}|$/u,'&') + r.gsub!(/%/,'\%') + r.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}') + r.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\emph{\1}') + r.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\uline{\1}') # ulem + r.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,"``\\1''") # quote #CHECK + r.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\uline{\1}') # ulem + r.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\sout{\1}') # ulem + r.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$") + r.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$") + r + end def longtable_landscape end_table='\end{longtable}' row_break='\\\\\\' @@ -137,7 +150,7 @@ module SiSU_TeX_Pdf rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end rows.each do |r| - r.gsub!(/#{Mx[:tc_p]}|$/,'&') + r=table_special_characters(r) r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\/ # not tested table footer if any tablefoot=$1 @@ -180,7 +193,7 @@ module SiSU_TeX_Pdf rows[0].gsub!(/&\s*$/," #{row_break} \\hline\\endhead #{row_break}") end rows.each do |r| - r.gsub!(/#{Mx[:tc_p]}|$/u,'&') + r=table_special_characters(r) r.gsub!(/$/," #{row_break}\n") unless r =~/#{row_break*2}$/ if r=~/\/ # not tested table footer if any tablefoot=$1 @@ -942,6 +955,7 @@ WOK para_array=[] str=if word word.each do |w| # _ - / # | : ! ^ ~ + w.gsub!(/#{Mx[:gl_o]}#lt#{Mx[:gl_c]}/,'<'); w.gsub!(/#{Mx[:gl_o]}#gt#{Mx[:gl_c]}/,'>') w.gsub!(/[\\]?~/,'<=tilde>') w.gsub!(/[#{Mx[:br_line]}#{Mx[:br_paragraph]}]/,' \newline ') #watch w.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/,'<=tilde>') #126 usual -- cgit v1.2.3 From 2da35997e8a74068821a6b4c52cd5eac7240874c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Jun 2010 22:00:33 -0400 Subject: table, (xhtml, odf): empty cell (single tilde to indicate); allow line breaks --- lib/sisu/v2/odf_format.rb | 1 + lib/sisu/v2/xhtml_table.rb | 2 ++ 2 files changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/sisu/v2/odf_format.rb b/lib/sisu/v2/odf_format.rb index f0163f81..384b46b7 100644 --- a/lib/sisu/v2/odf_format.rb +++ b/lib/sisu/v2/odf_format.rb @@ -147,6 +147,7 @@ module SiSU_ODF_format 'Table_20_Heading' else 'P7' end + str.gsub!(/^~$/,'') # tilde / empty cell %{#{@br}} + %{#{@br}} + %{#{str}} + diff --git a/lib/sisu/v2/xhtml_table.rb b/lib/sisu/v2/xhtml_table.rb index 2b0cb5e7..25db60c8 100644 --- a/lib/sisu/v2/xhtml_table.rb +++ b/lib/sisu/v2/xhtml_table.rb @@ -78,6 +78,8 @@ module SiSU_XHTML_table table_row_with_columns=table_row.split(Mx[:tc_p]) trc,nc=[],0 table_row_with_columns.each do |c| + c.gsub!(/^~$/,'') # tilde / empty cell + c.gsub!(/<:br>/,'
') trc <<= if table_obj.head_ and nr==0; %{#{c}} else %{#{c}} end -- cgit v1.2.3