From 7ef0302aa8c9e810bd9d8de86a2b92a2d9bea0fe Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 26 Jun 2011 14:40:52 -0400 Subject: v2 v3: texpdf, define hardspace & provide backslash * define \hardspace to simplify placing a hardspace * provide backslash character in code block --- lib/sisu/v2/texpdf.rb | 4 ++++ lib/sisu/v2/texpdf_format.rb | 5 +++++ lib/sisu/v3/texpdf.rb | 4 ++++ lib/sisu/v3/texpdf_format.rb | 5 +++++ 4 files changed, 18 insertions(+) (limited to 'lib/sisu') diff --git a/lib/sisu/v2/texpdf.rb b/lib/sisu/v2/texpdf.rb index a1a2813f..6503c931 100644 --- a/lib/sisu/v2/texpdf.rb +++ b/lib/sisu/v2/texpdf.rb @@ -341,6 +341,8 @@ module SiSU_TeX if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ dob.tmp=SiSU_TeX_Pdf::Format_text_object.new(@md,dob.tmp).url_str_internal(dob.tmp) end + elsif dob.is =='code' + dob.tmp=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters_code elsif dob.is =='break' if dob.obj==Mx[:br_page]; dob.tmp='\newpage' elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage' @@ -573,6 +575,8 @@ module SiSU_TeX \\newcommand{\\Codeblock}[1]{\\normaltext\\raggedright\\small\\ttfamily\\texbackslash#1} \\newcommand{\\monosp}[1]{\\normaltext\\ttfamily\\texbackslash#1} \\newcommand{\\parasep}{\\\\ \\begin{center}*\\hspace{2em}*\\hspace{2em}*\\end{center} \\\\} +\\newcommand{\\hardspace}{{~}} +%\\newcommand{\\hardspace}{\\hspace{.5em}} % \\sloppy \\begin{document} WOK diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index b2dd0e32..018232ac 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -1162,6 +1162,11 @@ WOK str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues @txt=str end + def special_characters_code + str=@txt + str.gsub!(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') + str + end end class Use_TeX attr_accessor :url,:txt,:date diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index c9e0f032..0f16e991 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -349,6 +349,8 @@ module SiSU_TeX if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ dob.tmp=SiSU_TeX_Pdf::Format_text_object.new(@md,dob.tmp).url_str_internal(dob.tmp) end + elsif dob.is =='code' + dob.tmp=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp).special_characters_code elsif dob.is =='break' if dob.obj==Mx[:br_page]; dob.tmp='\newpage' elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage' @@ -582,6 +584,8 @@ module SiSU_TeX \\newcommand{\\Codeblock}[1]{\\normaltext\\raggedright\\small\\ttfamily\\texbackslash#1} \\newcommand{\\monosp}[1]{\\normaltext\\ttfamily\\texbackslash#1} \\newcommand{\\parasep}{\\\\ \\begin{center}*\\hspace{2em}*\\hspace{2em}*\\end{center} \\\\} +\\newcommand{\\hardspace}{{~}} +%\\newcommand{\\hardspace}{\\hspace{.5em}} % \\sloppy \\begin{document} WOK diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 8c53b458..f7e63066 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -1164,6 +1164,11 @@ WOK str=xetex_special_characters_2(str,is) unless str.nil? # remove this to start with, causes issues @txt=str end + def special_characters_code + str=@txt + str.gsub!(/ \\\\([ #{Mx[:br_nl]}]+|$)/,' \textbackslash\textbackslash\hardspace\1') + str + end end class Use_TeX attr_accessor :url,:txt,:date -- cgit v1.2.3