From 89cc9097cfad4241433b2133a89fc02fd1b02936 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 2 Nov 2013 22:57:23 -0400 Subject: v5: plaintext, reorganize --- data/doc/sisu/CHANGELOG_v5 | 3 + lib/sisu/v5/plaintext.rb | 180 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 20 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 7d6fa055..b79254bc 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -33,6 +33,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.0.23.orig.tar.xz * constants, ocn output delimiter (where used) changed to 「...」 (from square brackets [...]) +* plaintext + * reorganize + %% 5.0.22.orig.tar.xz (2013-10-27:42/7) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.0.22 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.0.22-1 diff --git a/lib/sisu/v5/plaintext.rb b/lib/sisu/v5/plaintext.rb index f7c40d7a..b82013aa 100644 --- a/lib/sisu/v5/plaintext.rb +++ b/lib/sisu/v5/plaintext.rb @@ -218,6 +218,129 @@ at: * SiSU #{vz.url_sisu} WOK end + def decorate + def heading_underscore + def l1 + '*' + end + def l2 + '=' + end + def l3 + '~' + end + def l4 + '-' + end + def l5 + '.' + end + def l6 + '.' + end + self + end + def bold + def open + '*' + end + def close + '*' + end + self + end + def italics + def open + '/' + end + def close + '/' + end + self + end + def underscore + def open + '_' + end + def close + '_' + end + self + end + #def emphasis + # def open + # '' + # end + # def close + # '' + # end + # self + #end + def cite + def open + '"' + end + def close + '"' + end + self + end + def insert + def open + '+' + end + def close + '+' + end + self + end + def strike + def open + '-' + end + def close + '-' + end + self + end + def superscript + def open + '^' + end + def close + '^' + end + self + end + def subscript + def open + '[' + end + def close + ']' + end + self + end + def hilite + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '#' + end + def close + '#' + end + self + end + self + end def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document lv=n=n3=nil if dob.is==:heading @@ -253,12 +376,12 @@ WOK times=wrapped.length times=@wrap_width if times > @wrap_width @plaintext[:body] << case lv - when 1; wrapped.upcase << @br << Px[:lv1]*times + p_num << @br*2 - when 2; wrapped.upcase << @br << Px[:lv2]*times + p_num << @br*2 - when 3; wrapped.upcase << @br << Px[:lv3]*times + p_num << @br*2 - when 4; wrapped.upcase << @br << Px[:lv4]*times + p_num << @br*2 - when 5; wrapped.upcase << @br << Px[:lv5]*times + p_num << @br*2 - when 6; wrapped.upcase << @br << Px[:lv6]*times + p_num << @br*2 + when 1; wrapped.upcase << @br << decorate.heading_underscore.l1*times + p_num << @br*2 + when 2; wrapped.upcase << @br << decorate.heading_underscore.l2*times + p_num << @br*2 + when 3; wrapped.upcase << @br << decorate.heading_underscore.l3*times + p_num << @br*2 + when 4; wrapped.upcase << @br << decorate.heading_underscore.l4*times + p_num << @br*2 + when 5; wrapped.upcase << @br << decorate.heading_underscore.l5*times + p_num << @br*2 + when 6; wrapped.upcase << @br << decorate.heading_underscore.l6*times + p_num << @br*2 end else @plaintext[:body] << wrapped + p_num << @br # main text, contents, body KEEP @@ -283,23 +406,23 @@ WOK dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+/um,"#{@br}#{table_message}"). #fix gsub(/.+?#{Mx[:gl_o]}-##{Mx[:gl_c]}/,''). # remove dummy headings (used by html) #check also [~-]# gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, - "#{Px[:bold_o]}\\1#{Px[:bold_c]}"). + "#{decorate.bold.open}\\1#{decorate.bold.close}"). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, - "#{Px[:italics_o]}\\1#{Px[:italics_c]}"). + "#{decorate.italics.open}\\1#{decorate.italics.close}"). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/, - "#{Px[:underscore_o]}\\1#{Px[:underscore_c]}"). + "#{decorate.underscore.open}\\1#{decorate.underscore.close}"). gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/, - "#{Px[:subscript_o]}\\1#{Px[:subscript_c]}"). + "#{decorate.subscript.open}\\1#{decorate.subscript.close}"). gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/, - "#{Px[:superscript_o]}\\1#{Px[:superscript_c]}"). + "#{decorate.superscript.open}\\1#{decorate.superscript.close}"). gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/, - "#{Px[:insert_o]}\\1#{Px[:insert_c]}"). + "#{decorate.insert.open}\\1#{decorate.insert.close}"). gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/, - "#{Px[:cite_o]}\\1#{Px[:cite_c]}"). + "#{decorate.cite.open}\\1#{decorate.cite.close}"). gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/, - "#{Px[:strike_o]}\\1#{Px[:strike_c]}"). + "#{decorate.strike.open}\\1#{decorate.strike.close}"). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, - "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}") + "#{decorate.monospace.open}\\1#{decorate.monospace.close}") unless dob.is==:code dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). @@ -341,10 +464,6 @@ WOK gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - #if defined? dob.ocn and dob.ocn.to_s =~/\d+/ - # paranum=dob.ocn.to_s - # @p_num=SiSU_Plaintext_Format::ParagraphNumber.new(paranum) - #end p_num='' if @env.plaintext_ocn? if defined? dob.ocn \ @@ -431,4 +550,25 @@ WOK end end __END__ -!\|#\|&*\|-\|/\|_\|{\|}\|~\|&# + bold_o: '*', bold_c: '*', + #bold_o: '!', bold_c: '!', + #emphasis_o: '*', emphasis_c: '*', + italics_o: '/', italics_c: '/', + underscore_o: '_', underscore_c: '_', + cite_o: '"', cite_c: '"', + insert_o: '+', insert_c: '+', + strike_o: '-', strike_c: '-', + superscript_o: '^', superscript_c: '^', + subscript_o: '[', subscript_c: ']', + hilite_o: '*', hilite_c: '*', + monospace_o: '', monospace_c: '', + po_bold_o: '!{', po_bold_c: '}!', + po_italics_o: '/{', po_italics_c: '}/', + po_underscore_o: '_{', po_underscore_c: '}_', + po_cite_o: '"{', po_cite_c: '}"', + po_insert_o: '+{', po_insert_c: '}+', + po_strike_o: '-{', po_strike_c: '}-', + po_superscript_o: '^{', po_superscript_c: '}^', + po_subscript_o: ',{', po_subscript_c: '},', + po_hilite_o: '*{', po_hilite_c: '}*', + po_monospace_o: '#{', po_monospace_c: '}#', -- cgit v1.2.3