aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/digests.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-05-25 10:01:43 -0400
committerRalph Amissah <ralph@amissah.com>2014-05-25 10:01:43 -0400
commit16c30474f06ed3774ad524a38b55b7840de057d0 (patch)
tree03f20a30c1853b3d5cb893556aa633be2407a4d8 /lib/sisu/v5/digests.rb
parentv5 v6: version & changelog (& rakefile) (diff)
v5: merge v6 to v5, version bump to 5.4.*, reason adds structure checksisu_5.4.0
* ao, document structure check, stop processing on major error (with error message & text at location of failure) [reason for version bump the addition of structure check] * utils, add ok code marker * ao, heading with no ocn, distinguish ~# from -# * ~# is general & means no ocn (for any object to which it is applied) * -# is relevant only for 1~ dummy headings & instructs that they should be removed from output where possible * applied so far to pdf, odt & plaintext * ao_images, reduce warnings when ruby RMagic absent as program used directly * reduced dependency on ruby RMagic library (as some time way back had issues) * ao, document markup structure check, skip processing file on major error * with error message & text at location of failure * texpdf, urls in creator cause breakage * texpdf, mailto markup links set for normal text objects * texpdf, '&' in heading breaks toc (now removed from toc (not heading)), bug * revisit, bug * texpdf, for urls switch to sans serif (small fontsize) * instead of typewriter, latex default * texpdf, pdf colored hyperlinks configurable * --pdf-hyperlinks-color --pdf-hyperlinks-no-color or --pdf-hyperlinks-monochrome * ['default']['pdf_hyperlinks']='color' (other options switch hyperlink color off 'no-color' 'color-off' 'monochrome') * texpdf, pdf default font size configurable (cli & sisurc.yml) (no fractions) * --pdf-fontsize-12 --pdf-fontsize-8 * default: texpdf_fontsize: 12 * texpdf, headings and table of contents representation * fixes 1~ and 2~ result in the same formatting 1~ 2~ & 3~ now differentiated, see discussion in sisu.org under #744383 * fixes :A smaller formatted than :B A~ B~ C~ now the same size, see discussion in sisu.org under #744383 * :B and :C result in the same formatting, issue explained see sisu.org * texpdf, (internal coding) fontface, rename texpdf_font texpdf_fontface * texpdf, (internal coding) use symbols to identify page orientation * param, metadata rights, line-breaks instead of semicolons separating rights * fixes remove trailing semicolon after :copyright: * digests sha512 option implemented * options sha512 sha256 md5 * command line --sha512 * rcconf.yml ['defsault']['digest'] = sha512 * xml object citation numbering (docbook fictionbook)
Diffstat (limited to 'lib/sisu/v5/digests.rb')
-rw-r--r--lib/sisu/v5/digests.rb70
1 files changed, 46 insertions, 24 deletions
diff --git a/lib/sisu/v5/digests.rb b/lib/sisu/v5/digests.rb
index b3dd40bd..6cea7c3e 100644
--- a/lib/sisu/v5/digests.rb
+++ b/lib/sisu/v5/digests.rb
@@ -108,9 +108,14 @@ module SiSU_DigestView
private
class Scroll <Source
@@dl=nil
- @@ds={}
- @@description,@@ds[:digests],@@ds[:tree],@@ds[:summary],@@sc_info=[],[],[],[],[]
- def initialize(particulars) #data='',md='')
+ @@ds={
+ digests_clean: [],
+ digests_with_markup: [],
+ tree: [],
+ summary: [],
+ }
+ @@description,@@sc_info=[],[]
+ def initialize(particulars)
@particulars=particulars
@data,@env,@md=@particulars.ao_array,@particulars.env,@particulars.md
SiSU_Env::FileOp.new(@md).mkdir
@@ -123,7 +128,7 @@ module SiSU_DigestView
@sp=' '
end
def songsheet
- @@description,@@ds[:digests],@@ds[:tree],@@ds[:summary],@@sc_info=[],[],[],[],[]
+ @@description,@@ds[:digests_clean],@@ds[:digests_with_markup],@@ds[:tree],@@ds[:summary],@@sc_info=[],[],[],[],[],[]
message_digest
ao_structure
supplementary
@@ -133,9 +138,13 @@ module SiSU_DigestView
puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on
@@description << f << e
end
- def digests(f,e='')
+ def digests_clean(f,e='')
puts f if @md.opt.act[:verbose_plus][:set]==:on
- @@ds[:digests] << f + "\n"
+ @@ds[:digests_clean] << f + "\n"
+ end
+ def digests_with_markup(f)
+ puts f if @md.opt.act[:verbose_plus][:set]==:on
+ @@ds[:digests_with_markup] << f + "\n"
end
def ao_structure_tree(f,e='')
puts f + e.to_s if @md.opt.act[:verbose_plus][:set]==:on
@@ -152,14 +161,15 @@ module SiSU_DigestView
def output
file=SiSU_Env::FileOp.new(@md)
filename_digest=file.write_file.hash_digest
- filename_digest << @@description.join << @@ds[:digests].join << @@ds[:tree].join << @@ds[:summary].join << @@sc_info.join
+ filename_digest << @@description.join << @@ds[:digests_clean].join << @@ds[:digests_with_markup].join << @@ds[:tree].join << @@ds[:summary].join << @@sc_info.join
end
def rgx_txt(txt)
txt=txt.gsub(/([()])/,"\\\\\\1")
end
def message_digest
+ @p=[]
+ @g,@v,@r='','',''
manifest="#{@env.url.root}/#{@md.fnb}/sisu_manifest.html"
- a=%{ocn digest clean (no markup/notes),#{@sp*33}digest all (includes markup & endnotes)\n}
description("#{@md.title.full}\n")
description("#{@md.author}\n")
description("#{@md.fns}\n")
@@ -171,39 +181,51 @@ module SiSU_DigestView
description("Sourcefile digest: #{@md.dgst[1]}\n")
description(" source filename: #{@md.fns}\n")
description("available outputs: #{manifest}\n")
- #description(" time generated: #{@g}\n")
- #description(" SiSU version used: #{@v}\n")
- #description(" Ruby version used: #{@r}\n")
description("------------\n")
description("Document Digests\n")
- description(a)
end
def ao_structure
+ a=%{\nocn digests (#{@dg}) clean text (stripped markup)}
+ digests_clean(a)
data=@data
endnotes=nil
data.each do |t_o|
dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst
if dgst
if t_o.is==:heading
- digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}")
+ digests_clean("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]} #{t_o.lv}")
elsif t_o.is==:heading_insert
- digests("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}")
+ digests_clean("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]} #{t_o.lv}")
else
- digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]}")
+ digests_clean("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:is]}")
if dgst[:images]
dgst[:images].each do |img|
- digests("#{@sp*8}#{img[:img_dgst]}#{@sp*66}#{img[:img_type]} #{img[:img_name]}")
+ digests_clean("#{@sp*8}#{img[:img_dgst]}#{@sp*66}#{img[:img_type]} #{img[:img_name]}")
end
end
end
if dgst[:endnotes]
dgst[:endnotes].each do |en|
- digests("#{@sp*8}#{en[:note_dgst]}#{@sp*66}note [#{en[:note_number]}]")
+ digests_clean("#{@sp*8}#{en[:note_dgst]} note [#{en[:note_number]}]")
endnotes=en[:note_number]
end
end
end
end
+ b=%{\nocn object (#{@dg}) digests (object includes its markup & endnotes (if any))}
+ digests_with_markup(b)
+ data.each do |t_o|
+ dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst
+ if dgst
+ if t_o.is==:heading
+ digests_with_markup("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}")
+ elsif t_o.is==:heading_insert
+ digests_with_markup("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}")
+ else
+ digests_with_markup("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_markedup_txt]} #{dgst[:is]}")
+ end
+ end
+ end
l=Hash.new(0)
ocn=nil
ao_structure_tree("------------\n")
@@ -211,19 +233,19 @@ module SiSU_DigestView
data.each do |t_o|
if t_o.is==:heading
x=case t_o.ln
- when 1 then l[0] +=1 #fix Mx[:lv_o]
+ when 0 then l[0] +=1
' '*0 << ':A'
- when 1 then l[1] +=1 #fix Mx[:lv_o]
+ when 1 then l[1] +=1
' '*1 << ':B'
- when 2 then l[2] +=1 #fix Mx[:lv_o]
+ when 2 then l[2] +=1
' '*2 << ':C'
- when 3 then l[3] +=1 #fix Mx[:lv_o]
+ when 3 then l[3] +=1
' '*3 << ':D'
- when 4 then l[4] +=1 #fix Mx[:lv_o]
+ when 4 then l[4] +=1
' '*4 << '1'
- when 5 then l[5] +=1 #fix Mx[:lv_o]
+ when 5 then l[5] +=1
' '*5 << '2'
- when 6 then l[6] +=1 #fix Mx[:lv_o]
+ when 6 then l[6] +=1
' '*6 << '3'
else nil
end