diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v4/constants.rb | 1 | ||||
-rw-r--r-- | lib/sisu/v4/odf_format.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/constants.rb | 1 | ||||
-rw-r--r-- | lib/sisu/v5/manifest.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v5/odf.rb | 9 | ||||
-rw-r--r-- | lib/sisu/v5/odf_format.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v5/plaintext.rb | 180 | ||||
-rw-r--r-- | lib/sisu/v5/plaintext_format.rb | 14 | ||||
-rw-r--r-- | lib/sisu/v5/sysenv.rb | 8 |
9 files changed, 177 insertions, 51 deletions
diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 478b7277..f95b1dbd 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -176,6 +176,7 @@ Rx={ meta: /#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}/, } Dx={ + ocn_o: '「', ocn_c: '」', url_o: '‹', url_c: '›', url_o_xml: '<', url_c_xml: '>', rel_o: '‹', rel_c: '›', diff --git a/lib/sisu/v4/odf_format.rb b/lib/sisu/v4/odf_format.rb index 348ebb62..79f68478 100644 --- a/lib/sisu/v4/odf_format.rb +++ b/lib/sisu/v4/odf_format.rb @@ -69,12 +69,12 @@ module SiSU_ODF_Format end def set_ref_and_display set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') + disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) { display: disp, set_ref: set_ref } end def set_bookmark_and_display set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') + disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) { display: disp, set_ref: set_ref } end def name diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index d89a391a..26130506 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -176,6 +176,7 @@ Rx={ meta: /#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}/, } Dx={ + ocn_o: '「', ocn_c: '」', url_o: '‹', url_c: '›', url_o_xml: '<', url_c_xml: '>', rel_o: '‹', rel_c: '›', diff --git a/lib/sisu/v5/manifest.rb b/lib/sisu/v5/manifest.rb index 071959c7..3d6a5835 100644 --- a/lib/sisu/v5/manifest.rb +++ b/lib/sisu/v5/manifest.rb @@ -418,12 +418,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.txt.dir)==true - id=if @md.opt.cmd =~/a/ then 'Plaintext (Unix (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/e/ then 'Plaintext (Unix (UTF-8) with endnotes)' - elsif @md.opt.cmd =~/A/ then 'Plaintext (dos (UTF-8) with footnotes)' - elsif @md.opt.cmd =~/E/ then 'Plaintext (dos (UTF-8) with endnotes)' - else 'Plaintext (UTF-8)' - end + id='Plaintext (UTF-8)' pth=@f.output_path.txt.dir rel=@f.output_path.txt.rel_sm url=@f.output_path.txt.url diff --git a/lib/sisu/v5/odf.rb b/lib/sisu/v5/odf.rb index ae9a09ec..5e277992 100644 --- a/lib/sisu/v5/odf.rb +++ b/lib/sisu/v5/odf.rb @@ -548,10 +548,11 @@ module SiSU_ODF end p_num={ display: '', set_ref: '' } if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ - if defined? dob.ocn \ - and dob.ocn.is_a?(Fixnum) - p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display - #p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_ref_and_display + if @env.odt_ocn? + if defined? dob.ocn \ + and dob.ocn.is_a?(Fixnum) + p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn).set_bookmark_and_display + end end end if dob.is==:heading diff --git a/lib/sisu/v5/odf_format.rb b/lib/sisu/v5/odf_format.rb index d3630df9..28c69c44 100644 --- a/lib/sisu/v5/odf_format.rb +++ b/lib/sisu/v5/odf_format.rb @@ -69,12 +69,12 @@ module SiSU_ODF_Format end def set_ref_and_display set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:reference-mark-start text:name="\1"/><text:reference-mark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') + disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) { display: disp, set_ref: set_ref } end def set_bookmark_and_display set_ref=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript"><text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/></text:span>') - disp=@paranum.gsub(/(\d+)/,' <text:span text:style-name="Span_subscript">[\1]</text:span>') + disp=@paranum.gsub(/(\d+)/,%{ <text:span text:style-name="Span_subscript">#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}</text:span>}) { display: disp, set_ref: set_ref } end def name 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: '}#', diff --git a/lib/sisu/v5/plaintext_format.rb b/lib/sisu/v5/plaintext_format.rb index 092e69f6..acad8828 100644 --- a/lib/sisu/v5/plaintext_format.rb +++ b/lib/sisu/v5/plaintext_format.rb @@ -68,7 +68,7 @@ module SiSU_Plaintext_Format @paranum=/(\d+)/m.match(paranum.to_s)[1] end def display - @paranum.gsub(/(\d+)/,"\n[\\1]") + @paranum.gsub(/(\d+)/,"\n#{Dx[:ocn_o]}\\1#{Dx[:ocn_c]}") end def name #unused @paranum.gsub(/(\d+)/,'\1') @@ -97,18 +97,6 @@ module SiSU_Plaintext_Format def scr_endnote_body "<endnote>#{@txt}</endnote> " end - def heading_body1 - end - def heading_body2 - end - def heading_body3 - end - def heading_body4 - end - def heading_body5 - end - def heading_body6 - end end class XML end diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index b23b7f80..f1076c68 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -1474,15 +1474,15 @@ module SiSU_Env end def odt_ocn? ((defined? @rc['odt']['ocn']) \ - && @rc['odt']['ocn']==true) \ + && @rc['odt']['ocn']==false) \ ? @rc['odt']['ocn'] - : false + : true end def plaintext_ocn? ((defined? @rc['plaintext']['ocn']) \ - && @rc['plaintext']['ocn']==true) \ + && @rc['plaintext']['ocn']==false) \ ? @rc['plaintext']['ocn'] - : false + : true end def widget #needs (md) #move @rc=SiSU_Env::GetInit.new.sisu_yaml.rc |