diff options
-rw-r--r-- | CHANGELOG_v2 | 8 | ||||
-rw-r--r-- | data/doc/sisu/v2/CHANGELOG | 8 | ||||
-rw-r--r-- | lib/sisu/v2/constants.rb | 1 | ||||
-rw-r--r-- | lib/sisu/v2/dal_doc_objects.rb | 117 | ||||
-rw-r--r-- | lib/sisu/v2/dal_doc_str.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v2/dal_syntax.rb | 23 | ||||
-rw-r--r-- | lib/sisu/v2/texpdf.rb | 4 |
7 files changed, 100 insertions, 64 deletions
diff --git a/CHANGELOG_v2 b/CHANGELOG_v2 index 86cbf103..858ec9a6 100644 --- a/CHANGELOG_v2 +++ b/CHANGELOG_v2 @@ -20,6 +20,14 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_2.7.7.orig.tar.gz [debian freeze, fix] + * numbered codeblocks, fix, where codeblock opens with code{# + (requested fix needed by debian-live:live-manual, Ben Armstrong & Mark + Schneider) + * dal changes as required, flag markup request and number + * constants, provide vertical line symbol, use to separate numbered + codeblock from code + * texpdf substitute \vline for numbered codeblock line separator + * texpdf, first space following a bullet should be fixed width, fix (used \enspace (0.5em)) (requested fix and suggested latex solution, Ben Armstrong) diff --git a/data/doc/sisu/v2/CHANGELOG b/data/doc/sisu/v2/CHANGELOG index 84e519cf..d7bfa080 100644 --- a/data/doc/sisu/v2/CHANGELOG +++ b/data/doc/sisu/v2/CHANGELOG @@ -20,6 +20,14 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_2.7.7.orig.tar.gz [debian freeze, fix] + * numbered codeblocks, fix, where codeblock opens with code{# + (requested fix needed by debian-live:live-manual, Ben Armstrong & Mark + Schneider) + * dal changes as required, flag markup request and number + * constants, provide vertical line symbol, use to separate numbered + codeblock from code + * texpdf substitute \vline for numbered codeblock line separator + * texpdf, first space following a bullet should be fixed width, fix (used \enspace (0.5em)) (requested fix and suggested latex solution, Ben Armstrong) diff --git a/lib/sisu/v2/constants.rb b/lib/sisu/v2/constants.rb index 7fe795da..9367e9cd 100644 --- a/lib/sisu/v2/constants.rb +++ b/lib/sisu/v2/constants.rb @@ -103,6 +103,7 @@ Mx[:rel_o]='⌈'; Mx[:rel_c]='⌋' Mx[:tag_o]='⌊'; Mx[:tag_c]='⌉' Mx[:sm_set_o]='《'; Mx[:sm_set_c]='》' Mx[:sm_subset_o]='《 '; Mx[:sm_subset_c]='》' +Mx[:vline]='┆' # ¦ | #Mx[:sm_set_o]='∈ '; Mx[:sm_set_c]='∋ ' #Mx[:sm_subset_o]='∈ '; Mx[:sm_subset_c]='∋ ' Rx[:mx_fa_clean]= /#{Mx[:fa_o]}.+?#{Mx[:fa_c]}|#{Mx[:pa_o]}.+?#{Mx[:pa_c]}|#{Mx[:mk_o]}.+?#{Mx[:mk_c]}/ diff --git a/lib/sisu/v2/dal_doc_objects.rb b/lib/sisu/v2/dal_doc_objects.rb index 0102ff94..bc0020b2 100644 --- a/lib/sisu/v2/dal_doc_objects.rb +++ b/lib/sisu/v2/dal_doc_objects.rb @@ -221,84 +221,85 @@ module SiSU_document_structure end end class Object_group - attr_accessor :obj,:is,:of,:tags,:idx,:ocn,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp + attr_accessor :obj,:is,:of,:tags,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp def initialize @of='group' - @is=@obj=@idx=@ocn=@odv=@osp=@parent=@note_=@ocn_=@digest=@tmp=nil + @is=@obj=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil @tags=[] end def code(h,o=nil) - of= @of #String, classification - group #alt 'code' - is= 'code' #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] + of= @of #String, classification - group #alt 'code' + is= 'code' #String, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + number_= h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,number_,note_,ocn_,digest,tmp self end def group(h,o=nil) - of= @of #String, classification - group - is= 'group' #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] + of= @of #String, classification - group + is= 'group' #String, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end def alt(h,o=nil) #see group - of= @of #String, classification - group - is= 'alt' #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] + of= @of #String, classification - group + is= 'alt' #String, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp self end def verse(h,o=nil) #part of poem decide how you deal with this - of= @of #String, classification - group - is= 'verse' #String, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - ocn_=if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] + of= @of #String, classification - group + is= 'verse' #String, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + ocn_= if h[:ocn_].nil?; ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, either sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp @h=nil self diff --git a/lib/sisu/v2/dal_doc_str.rb b/lib/sisu/v2/dal_doc_str.rb index 2d4ee192..6eb2ee69 100644 --- a/lib/sisu/v2/dal_doc_str.rb +++ b/lib/sisu/v2/dal_doc_str.rb @@ -198,6 +198,7 @@ module SiSU_document_structure_extract if t_o =~/^code\{/ @@flag['code']=true @@counter=1 + @codeblock_numbered=(t_o =~/^code\{#/) ? true : false h={:obj=>'code block start'} #introduce a counter t_o=SiSU_document_structure::Object_comment.new.comment(h) #t_o=SiSU_document_structure::Object_layout.new.insert(h) elsif t_o =~/^poem\{/ @@ -314,7 +315,7 @@ module SiSU_document_structure_extract if t_o =~/^\}code/ @@flag['code']=false obj,tags=extract_tags(@tuned_code.join("\n")) - h={:obj=>obj,:tags=>tags} + h={:obj=>obj,:tags=>tags,:number_=>@codeblock_numbered} t_o=SiSU_document_structure::Object_group.new.code(h) @tuned_code=[] tuned_file << t_o diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index 2f78fbe6..fbc62158 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -427,14 +427,31 @@ module SiSU_Syntax "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image elsif dob.is=='table' dob=fontface(dob) - elsif dob.is =='code' # /^<:code>/ #should be enough # underscore used as escape for angle brackets + elsif dob.is =='code' +#p dob.obj dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') dob.obj.gsub!(/([<>])/,'_\1') dob.obj.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy dob.obj.gsub!(/_<(br(?: \/)?)_>/,'<\1>') #convert <br> <br /> back, clumsy dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy - dob.obj.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/, - "\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + if dob.number_ + codeline=[] + ln=1 + dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}|<br(?: \/)?>|\n/).each_with_index do |cl,i| + unless i == 0 + cl.gsub!(Mx[:br_nl],'') + w=3-ln.to_s.length + cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{Mx[:nbsp]}#{Mx[:nbsp]}#{cl}#{Mx[:br_nl]}" + ln +=1 + end + codeline << cl + end + codeline= codeline.join("") + dob.obj=codeline + else + dob.obj.gsub!(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/, + "\n#{Mx[:nbsp]}#{Mx[:nbsp]}") #temporary fix, prefer: #line.gsub!(/<:codeline>/,"\n") + end dob else # @\S+?: end diff --git a/lib/sisu/v2/texpdf.rb b/lib/sisu/v2/texpdf.rb index 9f59032b..92f8e0ba 100644 --- a/lib/sisu/v2/texpdf.rb +++ b/lib/sisu/v2/texpdf.rb @@ -436,8 +436,8 @@ module SiSU_TeX when /code/ sp_char=SiSU_TeX_Pdf::Special_characters.new(@md,dob.tmp,dob.is) dob.tmp=sp_char.special_characters_safe - dob.tmp.gsub!(/#{Mx[:nbsp]}/,'{~}') - #dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/,'{~}') + dob.tmp.gsub!(/#{Mx[:nbsp]}/,'{~}') #dob.tmp.gsub!(/#{Mx[:nbsp]}\s*/,'{~}') + dob.tmp.gsub!(/#{Mx[:vline]}/m,'\vline') dob.tmp.gsub!(/ \\( |#{Mx[:br_nl]})/,' {\textbackslash}\1') dob.tmp.gsub!(/(?:#{Mx[:br_nl]}\s*)+/,' \\\\\\ ') #watch dob.tmp.gsub!(/\n\n\n/m," \\newline\n\n") #watch |