aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2010-03-17 15:41:47 -0400
committerRalph Amissah <ralph@amissah.com>2010-03-17 15:41:47 -0400
commitf7a5bfcd7b7e6b922b992019e616d36f475ad091 (patch)
tree5f50d1770ebb90ec4edb22d6a675dd484e2a8152
parentparam, adjustment for manpage synopsis (diff)
plaintext docoration (more flexible markings)
-rw-r--r--lib/sisu/v2/constants.rb19
-rw-r--r--lib/sisu/v2/plaintext.rb44
2 files changed, 46 insertions, 17 deletions
diff --git a/lib/sisu/v2/constants.rb b/lib/sisu/v2/constants.rb
index 384c8c19..9abe9c0b 100644
--- a/lib/sisu/v2/constants.rb
+++ b/lib/sisu/v2/constants.rb
@@ -58,7 +58,7 @@
=end
Sfx={:txt=>'.txt',:html=>'.html',:xhtml=>'.xhtml',:xml=>'.xml',:epub=>'.epub',:epub_xhtml=>'.xhtml',:odt=>'.odt',:pdf=>'.pdf'}
-Ax,Xx,Mx,Rx,Hx,Dx,Db,Tex={},{},{},{},{},{},{},{}
+Ax,Xx,Mx,Rx,Hx,Dx,Px,Db,Tex={},{},{},{},{},{},{},{},{}
Ax[:tab]="\t"
Xx[:protect]='☞'
Xx[:segment]='Ф'
@@ -115,6 +115,23 @@ Db[:name_prefix]="SiSU#{SiSU_version_dir}_"
Tex[:backslash]="\\\\"
Tex[:backslash]="\\\\"
Tex[:tilde]='\\\\\\~'
+Px[:bold_o]= '*'; Px[:bold_c]= '*'
+Px[:italics_o]= '/'; Px[:italics_c]= '/'
+Px[:underscore_o]= '_'; Px[:underscore_c]= '_'
+Px[:cite_o]= '"'; Px[:cite_c]= '"'
+Px[:insert_o]= '+'; Px[:insert_c]= '+'
+Px[:strike_o]= '-'; Px[:strike_c]= '-'
+Px[:superscript_o]='^'; Px[:superscript_c]='^'
+Px[:subscript_o]= '['; Px[:subscript_c]= ']'
+Px[:hilite_o]= '*'; Px[:hilite_c]= '*'
+Px[:lv1]= '*'
+Px[:lv2]= '='
+Px[:lv3]= '='
+#Px[:lv2_3]= '='
+Px[:lv4]= '-'
+Px[:lv5]= '.'
+Px[:lv6]= '.'
+#Px[:lv5_6]= '.'
__END__
consider:
〔comment〕
diff --git a/lib/sisu/v2/plaintext.rb b/lib/sisu/v2/plaintext.rb
index 4e7cb2f1..ddc82839 100644
--- a/lib/sisu/v2/plaintext.rb
+++ b/lib/sisu/v2/plaintext.rb
@@ -237,10 +237,14 @@ WOK
times=wrapped.length
times=78 if times > 78
@plaintext[:body] << case lv
- when 1; wrapped.upcase << @br << '*'*times << @br
- when 2..3; wrapped.upcase << @br << '='*times << @br
- when 4; wrapped.upcase << @br << '-'*times << @br
- when 5..6; wrapped.upcase << @br << '.'*times << @br
+ when 1; wrapped.upcase << @br << Px[:lv1]*times << @br
+ when 2; wrapped.upcase << @br << Px[:lv2]*times << @br
+ when 3; wrapped.upcase << @br << Px[:lv3]*times << @br
+ #when 2..3; wrapped.upcase << @br << Px[:lv2_3]*times << @br
+ when 4; wrapped.upcase << @br << Px[:lv4]*times << @br
+ when 5; wrapped.upcase << @br << Px[:lv5]*times << @br
+ when 6; wrapped.upcase << @br << Px[:lv6]*times << @br
+ #when 5..6; wrapped.upcase << @br << Px[:lv5_6]*times << @br
end
else
@plaintext[:body] << wrapped << @br # main text, contents, body KEEP
@@ -266,15 +270,23 @@ WOK
fix=[]
data.each do |dob|
dob.obj.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}") #fix
- dob.obj.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check
- dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'*\1*')
- dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'/\1/')
- dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'_\1_')
- dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'[\1]')
- dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'^\1^')
- dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+\1+')
- dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"')
- dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'-\1-')
+ dob.obj.gsub!(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,'') # remove dummy headings (used by html) #check also [~-]#
+ dob.obj.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
+ "#{Px[:bold_o]}\\1#{Px[:bold_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
+ "#{Px[:italics_o]}\\1#{Px[:italics_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
+ "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
+ "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
+ "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,
+ "#{Px[:insert_o]}\\1#{Px[:insert_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,
+ "#{Px[:cite_o]}\\1#{Px[:cite_c]}")
+ dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,
+ "#{Px[:strike_o]}\\1#{Px[:strike_c]}")
unless dob.is=='code'
dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1')
dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]')
@@ -305,11 +317,11 @@ WOK
dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _> _<
dob.obj.gsub!(/(^|[^}])_([<>])/m,'\1\2') # _<_<
end
- dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks
+ dob.obj.gsub!(/#{Mx[:br_page]}\s*|#{Mx[:br_page_new]}/,'') # remove page breaks
dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1')
dob.obj.gsub!(/<a href=".+?">(.+?)<\/a>/m,'\1')
- dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links
- dob.obj.gsub!(/&nbsp;|#{Mx[:nbsp]}/,' ') # decide on
+ dob.obj.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'') # remove name links
+ dob.obj.gsub!(/&nbsp;|#{Mx[:nbsp]}/,' ') # decide on
dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]")
dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]') #"[ #{dir.url.images_local}\/\\1 ]")
dob.obj.gsub!(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]')