From e0fcd082741e964c3564bc2be3e4c775deb99f00 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Nov 2014 22:44:43 -0500 Subject: d: txt outputs, reorganize, introduce new files --- lib/sisu/develop/manpage.rb | 100 +++---------- lib/sisu/develop/txt_asciidoc.rb | 235 ++--------------------------- lib/sisu/develop/txt_asciidoc_decorate.rb | 207 ++++++++++++++++++++++++++ lib/sisu/develop/txt_markdown.rb | 238 +++-------------------------- lib/sisu/develop/txt_markdown_decorate.rb | 207 ++++++++++++++++++++++++++ lib/sisu/develop/txt_output.rb | 30 ++++ lib/sisu/develop/txt_plain.rb | 239 ++++-------------------------- lib/sisu/develop/txt_plain_decorate.rb | 189 +++++++++++++++++++++++ lib/sisu/develop/txt_read.rb | 109 ++++++++++++++ lib/sisu/develop/txt_rst.rb | 214 ++------------------------ lib/sisu/develop/txt_rst_decorate.rb | 186 +++++++++++++++++++++++ lib/sisu/develop/txt_textile.rb | 236 ++++------------------------- lib/sisu/develop/txt_textile_decorate.rb | 186 +++++++++++++++++++++++ lib/sisu/develop/wikispeak.rb | 2 +- 14 files changed, 1239 insertions(+), 1139 deletions(-) create mode 100644 lib/sisu/develop/txt_asciidoc_decorate.rb create mode 100644 lib/sisu/develop/txt_markdown_decorate.rb create mode 100644 lib/sisu/develop/txt_output.rb create mode 100644 lib/sisu/develop/txt_plain_decorate.rb create mode 100644 lib/sisu/develop/txt_read.rb create mode 100644 lib/sisu/develop/txt_rst_decorate.rb create mode 100644 lib/sisu/develop/txt_textile_decorate.rb (limited to 'lib') diff --git a/lib/sisu/develop/manpage.rb b/lib/sisu/develop/manpage.rb index 2d46a229..75d4c360 100644 --- a/lib/sisu/develop/manpage.rb +++ b/lib/sisu/develop/manpage.rb @@ -63,10 +63,12 @@ module SiSU_Manpage include SiSU_ManpageFormat require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source + include SiSU_Txt_Read def initialize(opt) @opt=opt if @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -77,37 +79,14 @@ module SiSU_Manpage end def read begin - @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::InfoEnv.new(@opt.fns) - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.text_editor} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - && @opt.act[:quiet][:set]==:on \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Manpage', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Manpage', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}" - ).flow - end - @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - SiSU_Manpage::Source::Scroll.new(@md,@ao_array).songsheet + md=SiSU_Param::Parameters.new(@opt).get + specific={ + description: 'Manpage', + output_path: md.file.output_path.manpage.dir, + output_file: md.file.base_filename.manpage, + } + read_generic(@opt,specific) + SiSU_Manpage::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -121,8 +100,8 @@ module SiSU_Manpage include SiSU_Parts_Generic include SiSU_TextUtils @@endnotes={ para: [], end: [] } - def initialize(md,data) - @md,@data=md,data + def initialize(md,data,wrap_width) + @md,@data,@wrap_width=md,data,wrap_width @tab="\t" @@notes=:end @manpage={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] } @@ -153,8 +132,8 @@ module SiSU_Manpage notes=@n.flatten notes.each do |e| util=(e.to_s =~/^\[[\d*+]+\]:/) \ - ? (SiSU_TextUtils::Wrap.new(e.to_s,78,4,1)) - : (SiSU_TextUtils::Wrap.new(e.to_s,78,0,1)) + ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1)) + : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,0,1)) wrap=util.line_wrap wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m wrap.gsub(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires @@ -219,19 +198,19 @@ WOK if dob.indent =~/[1-9]/ \ and dob.indent == dob.hang util=if dob.bullet_ - SiSU_TextUtils::Wrap.new("* #{paragraph}",78,dob.indent.to_i*2) - else SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2) + SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,dob.indent.to_i*2) + else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2) end elsif dob.hang =~/[0-9]/ \ and dob.indent != dob.hang # NOT yet implemented - util=SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2) + util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2) else util=if dob.bullet_ - SiSU_TextUtils::Wrap.new("* #{paragraph}",78,0) - else SiSU_TextUtils::Wrap.new(paragraph,78,0) + SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,0) + else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0) end end - else util=SiSU_TextUtils::Wrap.new(paragraph,78,0) + else util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0) end w=util.line_wrap w=w.gsub(/^(\\\.)/,' \1') @@ -239,7 +218,7 @@ WOK end if lv times=wrapped.length - times=78 if times > 78 + times=@wrap_width if times > @wrap_width @manpage[:body] << case lv when 0 then '.SH ' << wrapped.upcase << break_line << break_line when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line @@ -387,42 +366,11 @@ WOK content << @@endnotes[:end] if @@notes==:end content << manpage[:metadata] content << manpage[:tail] - Output.new(@md,content).manpage + outputfile=SiSU_Env::FileOp.new(@md).write_file.manpage + Txt_Output::Output.new.document(content,outputfile) @@endnotes={ para: [], end: [] } end end - class Output 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - filename_manpage.puts line #unix manpage - end - end - end - else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/ - end - end - filename_manpage.close - end - end end end __END__ diff --git a/lib/sisu/develop/txt_asciidoc.rb b/lib/sisu/develop/txt_asciidoc.rb index 0b7fa669..14bb3f09 100644 --- a/lib/sisu/develop/txt_asciidoc.rb +++ b/lib/sisu/develop/txt_asciidoc.rb @@ -60,11 +60,15 @@ module SiSU_Txt_AsciiDoc include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_asciidoc_decorate' # txt_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source + include SiSU_Txt_Read def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -74,46 +78,13 @@ module SiSU_Txt_AsciiDoc def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'AsciiDoc (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'AsciiDoc (plaintext utf-8)', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{md.file.output_path.asciidoc.dir}/#{md.file.base_filename.asciidoc}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_AsciiDoc::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'AsciiDoc (plaintext utf-8)', + output_path: md.file.output_path.asciidoc.dir, + output_file: md.file.base_filename.asciidoc, + } + read_generic(@opt,specific) + SiSU_Txt_AsciiDoc::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -125,6 +96,7 @@ module SiSU_Txt_AsciiDoc class Scroll 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ diff --git a/lib/sisu/develop/txt_asciidoc_decorate.rb b/lib/sisu/develop/txt_asciidoc_decorate.rb new file mode 100644 index 00000000..c63d508d --- /dev/null +++ b/lib/sisu/develop/txt_asciidoc_decorate.rb @@ -0,0 +1,207 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext decoration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end + +module SiSU_Decorate_Txt_AsciiDoc + def decorate + def heading + def inline + def l0 + '=' + end + def l1 + '==' + end + def l2 + '===' + end + def l3 + '====' + end + def l4 + '=====' + end + def l5 + '' #'======' #logical + end + self + end + def underscore + def l0 + '=' + end + def l1 + '-' + end + def l2 + '~' + end + def l3 + '^' + end + def l4 + '+' + end + def l5 + '.' #'.' #proposed + end + self + 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 #bold + def open + '*' + end + def close + '*' + end + self + end + def monospace + def open + '+' + end + def close + '+' + end + self + end + self + end +end +__END__ diff --git a/lib/sisu/develop/txt_markdown.rb b/lib/sisu/develop/txt_markdown.rb index 52f3b911..e927c0ec 100644 --- a/lib/sisu/develop/txt_markdown.rb +++ b/lib/sisu/develop/txt_markdown.rb @@ -60,11 +60,15 @@ module SiSU_Txt_Markdown include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_markdown_decorate' # txt_markdown_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source + include SiSU_Txt_Read def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -74,45 +78,13 @@ module SiSU_Txt_Markdown def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Markdown (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Markdown (plaintext utf-8)', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns,"#{md.file.output_path.markdown.dir}/#{md.file.base_filename.markdown}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_Markdown::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'Markdown (plaintext utf-8)', + output_path: md.file.output_path.markdown.dir, + output_file: md.file.base_filename.markdown, + } + read_generic(@opt,specific) + SiSU_Txt_Markdown::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -124,6 +96,7 @@ module SiSU_Txt_Markdown class Scroll 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ diff --git a/lib/sisu/develop/txt_markdown_decorate.rb b/lib/sisu/develop/txt_markdown_decorate.rb new file mode 100644 index 00000000..20029efd --- /dev/null +++ b/lib/sisu/develop/txt_markdown_decorate.rb @@ -0,0 +1,207 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext decoration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end + +module SiSU_Decorate_Txt_Markdown + def decorate + def heading + def inline #atx + def l0 + '#' + end + def l1 + '##' + end + def l2 + '###' + end + def l3 + '####' + end + def l4 + '#####' + end + def l5 + '######' + end + self + end + def underscore #Setext + def l1 + '=' + end + def l2 + '-' + end + def l3 + '' + end + def l4 + '' + end + def l5 + '' + end + def l6 + '' + end + self + 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 +end +__END__ diff --git a/lib/sisu/develop/txt_output.rb b/lib/sisu/develop/txt_output.rb new file mode 100644 index 00000000..98a295ef --- /dev/null +++ b/lib/sisu/develop/txt_output.rb @@ -0,0 +1,30 @@ +module Txt_Output + class Output + include SiSU_Param + include SiSU_Env + def document(content,outputfile) + emptyline=0 + content.each do |para| # this is a hack + if para.is_a?(Array) \ + and para.length > 0 + para.each do |line| + if line + line=line.gsub(/[ \t]+$/m,''). + gsub(/^\A[ ]*\Z/m,'') + (line=~/^\A\Z/) \ + ? (emptyline+=1) + : emptyline=0 + if emptyline < 2 #remove additional empty lines + outputfile.puts line + end + end + end + else outputfile.puts para #unix plaintext # /^([*=-]|\.){5}/ + end + end + outputfile.close + end + end +end +__END__ + diff --git a/lib/sisu/develop/txt_plain.rb b/lib/sisu/develop/txt_plain.rb index 2c314708..2c19c7d2 100644 --- a/lib/sisu/develop/txt_plain.rb +++ b/lib/sisu/develop/txt_plain.rb @@ -60,11 +60,15 @@ module SiSU_Txt_Plain include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_plain_decorate' # txt_plain_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source + include SiSU_Txt_Read def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -74,46 +78,13 @@ module SiSU_Txt_Plain def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Plaintext', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Plaintext', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{md.file.output_path.txt.dir}/#{md.file.base_filename.txt}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_Plain::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'Plaintext (utf-8)', + output_path: md.file.output_path.txt.dir, + output_file: md.file.base_filename.txt, + } + read_generic(@opt,specific) + SiSU_Txt_Plain::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -125,6 +96,7 @@ module SiSU_Txt_Plain class Scroll 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ @@ -585,13 +398,13 @@ __END__ 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: '}#', + p_bold_o: '!{', p_bold_c: '}!', + p_italics_o: '/{', p_italics_c: '}/', + p_underscore_o: '_{', p_underscore_c: '}_', + p_cite_o: '"{', p_cite_c: '}"', + p_insert_o: '+{', p_insert_c: '}+', + p_strike_o: '-{', p_strike_c: '}-', + p_superscript_o: '^{', p_superscript_c: '}^', + p_subscript_o: ',{', p_subscript_c: '},', + p_hilite_o: '*{', p_hilite_c: '}*', + p_monospace_o: '#{', p_monospace_c: '}#', diff --git a/lib/sisu/develop/txt_plain_decorate.rb b/lib/sisu/develop/txt_plain_decorate.rb new file mode 100644 index 00000000..6bceb9ce --- /dev/null +++ b/lib/sisu/develop/txt_plain_decorate.rb @@ -0,0 +1,189 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext decoration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end + +module SiSU_Decorate_Txt_Plain + def decorate + def heading_underscore + def l0 + '=' + end + def l1 + '*' + end + def l2 + '+' + end + def l3 + '~' + end + def l4 + '-' + end + def l5 + '.' + end + def l6 + '.' + end + def l7 + '.' + 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 +end +__END__ diff --git a/lib/sisu/develop/txt_read.rb b/lib/sisu/develop/txt_read.rb new file mode 100644 index 00000000..204b94c5 --- /dev/null +++ b/lib/sisu/develop/txt_read.rb @@ -0,0 +1,109 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext (smarttext) generation, asciidoc + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_Txt_Read + require_relative 'se' # se.rb + include SiSU_Env + def read_generic(opt,specific) + begin + env=SiSU_Env::InfoEnv.new(opt.fns) + unless opt.act[:quiet][:set]==:on + tool=(opt.act[:verbose][:set]==:on \ + || opt.act[:verbose_plus][:set]==:on \ + || opt.act[:maintenance][:set]==:on) \ + ? "#{env.program.text_editor} #{specific[:output_path]}/#{specific[:output_file]}" + : "[#{opt.f_pth[:lng_is]}] #{opt.fno}" + (opt.act[:verbose][:set]==:on \ + || opt.act[:verbose_plus][:set]==:on \ + || opt.act[:maintenance][:set]==:on) \ + ? SiSU_Screen::Ansi.new( + opt.act[:color_state][:set], + specific[:description], + tool + ).green_hi_blue + : SiSU_Screen::Ansi.new( + opt.act[:color_state][:set], + specific[:description], + tool + ).green_title_hi + if (opt.act[:verbose_plus][:set]==:on \ + || opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + opt.act[:color_state][:set], + opt.fns, + "#{specific[:output_path]}/#{specific[:output_file]}" + ).flow + end + end + @ao_array=SiSU_AO::Source.new(opt).get # ao file drawn here + @wrap_width=if defined? md.make.plaintext_wrap \ + and md.make.plaintext_wrap + md.make.plaintext_wrap + elsif defined? env.plaintext_wrap \ + and env.plaintext_wrap + env.plaintext_wrap + else 78 + end + #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 + rescue + SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end +end + diff --git a/lib/sisu/develop/txt_rst.rb b/lib/sisu/develop/txt_rst.rb index 052051fe..a596fa85 100644 --- a/lib/sisu/develop/txt_rst.rb +++ b/lib/sisu/develop/txt_rst.rb @@ -60,11 +60,15 @@ module SiSU_Txt_rST include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_rst_decorate' # txt_rst_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source + include SiSU_Txt_Read def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -74,46 +78,13 @@ module SiSU_Txt_rST def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'rST (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'rST (plaintext utf-8)', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{md.file.output_path.rst.dir}/#{md.file.base_filename.rst}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_rST::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'rST (plaintext utf-8)', + output_path: md.file.output_path.rst.dir, + output_file: md.file.base_filename.rst, + } + read_generic(@opt,specific) + SiSU_Txt_rST::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -125,6 +96,7 @@ module SiSU_Txt_rST class Scroll @wrap_width @@ -515,41 +361,11 @@ WOK content << plaintext[:metadata] content << "#{break_line}#{divider*@wrap_width}#{break_line}" if @md.stmp =~/\w+/ #not used? content << plaintext[:tail] - Output.new(content,@md).rst + outputfile=SiSU_Env::FileOp.new(@md).write_file.rst + Txt_Output::Output.new.document(content,outputfile) @@endnotes={ para: [], end: [] } end end - class Output 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ diff --git a/lib/sisu/develop/txt_rst_decorate.rb b/lib/sisu/develop/txt_rst_decorate.rb new file mode 100644 index 00000000..6f1de7fd --- /dev/null +++ b/lib/sisu/develop/txt_rst_decorate.rb @@ -0,0 +1,186 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext decoration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end + +module SiSU_Decorate_Txt_rST + def decorate + def heading + def underscore + def l0 + '=' + end + def l1 + '-' + end + def l2 + '`' + end + def l3 + ':' + end + def l4 + "'" + end + def l5 + '"' + end + self + 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 +end +__END__ diff --git a/lib/sisu/develop/txt_textile.rb b/lib/sisu/develop/txt_textile.rb index 4aa9c87f..d777587e 100644 --- a/lib/sisu/develop/txt_textile.rb +++ b/lib/sisu/develop/txt_textile.rb @@ -60,12 +60,16 @@ module SiSU_Txt_Textile include SiSU_Env require_relative 'shared_metadata' # shared_metadata.rb require_relative 'generic_parts' # generic_parts.rb + require_relative 'txt_read' # txt_read.rb require_relative 'txt_shared' # txt_shared.rb + require_relative 'txt_textile_decorate' # txt_textile_decorate.rb + require_relative 'txt_output' # txt_output.rb include SiSU_Param - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source - include SiSU_Parts_Generic + include SiSU_Txt_Read + #include SiSU_Parts_Generic def initialize(opt) @opt=opt unless @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ @@ -75,46 +79,13 @@ module SiSU_Txt_Textile def read begin md=SiSU_Param::Parameters.new(@opt).get - env=SiSU_Env::InfoEnv.new(@opt.fns) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Textile (plaintext utf-8)', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Textile (plaintext utf-8)', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "#{md.file.output_path.textile.dir}/#{md.file.base_filename.textile}" - ).flow - end - end - ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - wrap_width=if defined? md.make.plaintext_wrap \ - and md.make.plaintext_wrap - md.make.plaintext_wrap - elsif defined? env.plaintext_wrap \ - and env.plaintext_wrap - env.plaintext_wrap - else 78 - end - #wrap_width=(defined? md.make.plaintext_wrap) ? md.make.plaintext_wrap : 78 - SiSU_Txt_Textile::Source::Scroll.new(md,ao_array,wrap_width).songsheet + specific={ + description: 'Textile (plaintext utf-8)', + output_path: md.file.output_path.textile.dir, + output_file: md.file.base_filename.textile, + } + read_generic(@opt,specific) + SiSU_Txt_Textile::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do __LINE__.to_s + ':' + __FILE__ @@ -126,6 +97,7 @@ module SiSU_Txt_Textile class Scroll 0 - para.each do |line| - if line - line=line.gsub(/[ \t]+$/m,''). - gsub(/^\A[ ]*\Z/m,'') - (line=~/^\A\Z/) \ - ? (emptyline+=1) - : emptyline=0 - if emptyline < 2 #remove additional empty lines - file_plaintext.puts line - end - end - end - else file_plaintext.puts para #unix plaintext # /^([*=-]|\.){5}/ - end - end - file_plaintext.close - end - end end end __END__ diff --git a/lib/sisu/develop/txt_textile_decorate.rb b/lib/sisu/develop/txt_textile_decorate.rb new file mode 100644 index 00000000..03fdc68b --- /dev/null +++ b/lib/sisu/develop/txt_textile_decorate.rb @@ -0,0 +1,186 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** plaintext decoration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + This program is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + this program. If not, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end + +module SiSU_Decorate_Txt_Textile + def decorate + def heading + def inline + def l0 + 'h1. ' + end + def l1 + 'h2. ' + end + def l2 + 'h3. ' + end + def l3 + 'h4. ' + end + def l4 + 'h5. ' + end + def l5 + 'h6. ' + end + self + 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 +end +__END__ diff --git a/lib/sisu/develop/wikispeak.rb b/lib/sisu/develop/wikispeak.rb index 5a740696..d1682858 100644 --- a/lib/sisu/develop/wikispeak.rb +++ b/lib/sisu/develop/wikispeak.rb @@ -64,7 +64,7 @@ module SiSU_Wikispeak include Format require_relative 'html_parts' # html_parts.rb require_relative 'txt_shared' - @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0 + @@alt_id_count,@@alt_id_count=0,0 @@tablefoot='' class Source def initialize(opt) -- cgit v1.2.3