aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/develop/po4a.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/develop/po4a.rb')
-rw-r--r--lib/sisu/develop/po4a.rb76
1 files changed, 58 insertions, 18 deletions
diff --git a/lib/sisu/develop/po4a.rb b/lib/sisu/develop/po4a.rb
index e0b31ce0..a302e02e 100644
--- a/lib/sisu/develop/po4a.rb
+++ b/lib/sisu/develop/po4a.rb
@@ -747,25 +747,65 @@ GSUB
unwrapped=util.no_line_wrap_block
@pot[:body] << unwrapped << br
end
+ def pot_structure_idx_markup(idx)
+ struct=['={']
+ idx.sort.each do |x|
+ x.each_with_index do |y,i0|
+ case y
+ when String
+ struct << ';' unless struct[-1] =~/=\{/
+ struct << y
+ if x[i0+1].class == Hash \
+ and x[i0+1][:sub].length > 0
+ struct << ':'
+ end
+ when Hash
+ if y[:plus].to_i > 0
+ struct << '+' + y[:plus].to_s
+ end
+ if y[:sub].length > 0
+ y[:sub].each_with_index do |z,i1|
+ z.each_with_index do |a,i2|
+ #p a
+ if z.length > 0
+ struct << a[0]
+ if a[1][:plus].to_i > 0
+ struct << '+' + a[1][:plus].to_s
+ end
+ if (i1 + 1) < y[:sub].length
+ struct << '|'
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ struct << '}'
+ #puts struct.join
+ struct.join
+ end
def pot_structure_idx(dob_src='',dob_trn='') #% used for book index but broken as original markup lost, already abstracted, fix
- #mark="={ ... }"
- #instruct=s_mark=''
- #if @md.opt.act[:maintenance][:set]==:on
- # instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)"
- # s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
- #end
- #d='book-idx'
- #desc="#{d}#{s_mark}#{instruct}"
- #orig='={' + dob_src.idx + '}'
- #trans=if defined? dob_trn.idx \
- #and not dob_trn.idx.nil? \
- #and not dob_trn.idx.empty?
- # '={' + dob_trn.idx + '}'
- #else ''
- #end
- #util=pot_structure(desc,orig,trans)
- #unwrapped=util.no_line_wrap_block
- #@pot[:body] << unwrapped << br
+ mark="={ ... }"
+ instruct=s_mark=''
+ if @md.opt.act[:maintenance][:set]==:on
+ instruct=%{\n# the book index should be attached unwrapped to the preceding text block } \
+ + %{(there should be a new line, but no empty line)}
+ s_mark="\n# " + %{"\\n#{mark}\\n\\n"}
+ end
+ d='book-idx'
+ desc="#{d}#{s_mark}#{instruct}"
+ orig=pot_structure_idx_markup(dob_src.idx) #'={' + dob_src.idx + '}'
+ trans=if defined? dob_trn.idx \
+ and not dob_trn.idx.nil? \
+ and not dob_trn.idx.empty?
+ pot_structure_idx_markup(dob_trn.idx) #'={' + dob_trn.idx + '}'
+ else ''
+ end
+ util=pot_structure(desc,orig,trans)
+ unwrapped=util.no_line_wrap_block
+ @pot[:body] << unwrapped << br
end
def pot_markup(data_src,data_trn)
#@endnotes,@copen,@pot_contents_close=Array.new(3){[]}