From dba6d8b359e626a30d613685b0a686c29df4e98b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 26 Jul 2011 20:30:47 -0400 Subject: v3: texpdf, indent ... --- data/doc/sisu/CHANGELOG_v3 | 4 +- lib/sisu/v3/texpdf.rb | 8 ++- lib/sisu/v3/texpdf_format.rb | 148 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 3 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 98a6380d..73d1062d 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -26,8 +26,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.14.orig.tar.gz _[0-9]?_[1-9] initial indent; paragraph text indent - * done: dal, plaintext, css, html, epub, xhtml, xml sax, xml dom; - not done: pdf, odf, man, info + * done: dal, plaintext, css, html, epub, xhtml, xml sax, xml dom, pdf; + not done: odf, man, info check: po4a, html_lite (used in sql search results) * syntax highlighting done: vim (sisu.vim), emacs (sisu-mode.el) diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 22269fc2..9e223920 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -515,8 +515,14 @@ module SiSU_TeX if dob.bullet_ dob.tmp=tst.bullet elsif dob.indent \ - and dob.indent =~/[1-9]/ + and dob.hang \ + and dob.indent =~/[1-9]/ \ + and dob.indent == dob.hang dob.tmp=tst.indent + elsif dob.hang \ + and dob.hang =~/[0-9]/ \ + and (dob.indent != dob.hang or dob.indent =~/[1-9]/) + dob.tmp=tst.hang else dob.tmp.strip! dob=enclose(dob) unless dob.tmp =~/^$/ diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index cd63cd4e..76f0630a 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -293,6 +293,141 @@ module SiSU_TeX_Pdf # '\subsubsection*{\1}') dob end + def hang + case @dob.indent + when /0/ + case @dob.hang + when /0/; indent,hang='0mm', '0mm' + when /1/; indent,hang='0mm','10mm' + when /2/; indent,hang='0mm','20mm' + when /3/; indent,hang='0mm','30mm' + when /4/; indent,hang='0mm','40mm' + when /5/; indent,hang='0mm','50mm' + when /6/; indent,hang='0mm','60mm' + when /7/; indent,hang='0mm','70mm' + when /8/; indent,hang='0mm','80mm' + when /9/; indent,hang='0mm','90mm' + end + when /1/ + case @dob.hang + when /0/; indent,hang='10mm','-10mm' + when /1/; indent,hang='10mm', '0mm' + when /2/; indent,hang='10mm', '10mm' + when /3/; indent,hang='10mm', '20mm' + when /4/; indent,hang='10mm', '30mm' + when /5/; indent,hang='10mm', '40mm' + when /6/; indent,hang='10mm', '50mm' + when /7/; indent,hang='10mm', '60mm' + when /8/; indent,hang='10mm', '70mm' + when /9/; indent,hang='10mm', '80mm' + end + when /2/ + case @dob.hang + when /0/; indent,hang='20mm','-20mm' + when /1/; indent,hang='20mm','-10mm' + when /2/; indent,hang='20mm', '0mm' + when /3/; indent,hang='20mm', '10mm' + when /4/; indent,hang='20mm', '20mm' + when /5/; indent,hang='20mm', '30mm' + when /6/; indent,hang='20mm', '40mm' + when /7/; indent,hang='20mm', '50mm' + when /8/; indent,hang='20mm', '60mm' + when /9/; indent,hang='20mm', '70mm' + end + when /3/ + case @dob.hang + when /0/; indent,hang='30mm','-30mm' + when /1/; indent,hang='30mm','-20mm' + when /2/; indent,hang='30mm','-10mm' + when /3/; indent,hang='30mm', '0mm' + when /4/; indent,hang='30mm', '10mm' + when /5/; indent,hang='30mm', '20mm' + when /6/; indent,hang='30mm', '30mm' + when /7/; indent,hang='30mm', '40mm' + when /8/; indent,hang='30mm', '50mm' + when /9/; indent,hang='30mm', '60mm' + end + when /4/ + case @dob.hang + when /0/; indent,hang='40mm','-40mm' + when /1/; indent,hang='40mm','-30mm' + when /2/; indent,hang='40mm','-20mm' + when /3/; indent,hang='40mm','-10mm' + when /4/; indent,hang='40mm', '0mm' + when /5/; indent,hang='40mm', '10mm' + when /6/; indent,hang='40mm', '20mm' + when /7/; indent,hang='40mm', '30mm' + when /8/; indent,hang='40mm', '40mm' + when /9/; indent,hang='40mm', '50mm' + end + when /5/ + case @dob.hang + when /0/; indent,hang='50mm','-50mm' + when /1/; indent,hang='50mm','-40mm' + when /2/; indent,hang='50mm','-30mm' + when /3/; indent,hang='50mm','-20mm' + when /4/; indent,hang='50mm','-10mm' + when /5/; indent,hang='50mm', '0mm' + when /6/; indent,hang='50mm', '10mm' + when /7/; indent,hang='50mm', '20mm' + when /8/; indent,hang='50mm', '30mm' + when /9/; indent,hang='50mm', '40mm' + end + when /6/ + case @dob.hang + when /0/; indent,hang='60mm','-60mm' + when /1/; indent,hang='60mm','-50mm' + when /2/; indent,hang='60mm','-40mm' + when /3/; indent,hang='60mm','-30mm' + when /4/; indent,hang='60mm','-20mm' + when /5/; indent,hang='60mm','-10mm' + when /6/; indent,hang='60mm', '0mm' + when /7/; indent,hang='60mm', '10mm' + when /8/; indent,hang='60mm', '20mm' + when /9/; indent,hang='60mm', '30mm' + end + when /7/ + case @dob.hang + when /0/; indent,hang='70mm','-70mm' + when /1/; indent,hang='70mm','-60mm' + when /2/; indent,hang='70mm','-50mm' + when /3/; indent,hang='70mm','-40mm' + when /4/; indent,hang='70mm','-30mm' + when /5/; indent,hang='70mm','-20mm' + when /6/; indent,hang='70mm','-10mm' + when /7/; indent,hang='70mm', '0mm' + when /8/; indent,hang='70mm', '10mm' + when /9/; indent,hang='70mm', '20mm' + end + when /8/ + case @dob.hang + when /0/; indent,hang='80mm','-80mm' + when /1/; indent,hang='80mm','-70mm' + when /2/; indent,hang='80mm','-60mm' + when /3/; indent,hang='80mm','-50mm' + when /4/; indent,hang='80mm','-40mm' + when /5/; indent,hang='80mm','-30mm' + when /6/; indent,hang='80mm','-20mm' + when /7/; indent,hang='80mm','-10mm' + when /8/; indent,hang='80mm', '0mm' + when /9/; indent,hang='80mm', '10mm' + end + when /9/ + case @dob.hang + when /0/; indent,hang='90mm','-90mm' + when /1/; indent,hang='90mm','-80mm' + when /2/; indent,hang='90mm','-70mm' + when /3/; indent,hang='90mm','-60mm' + when /4/; indent,hang='90mm','-50mm' + when /5/; indent,hang='90mm','-40mm' + when /6/; indent,hang='90mm','-30mm' + when /7/; indent,hang='90mm','-20mm' + when /8/; indent,hang='90mm','-10mm' + when /9/; indent,hang='90mm', '0mm' + end + end + "\\begin{ParagraphHang}{#{indent}}{#{hang}}#{@dob.tmp} \\end{ParagraphHang}}" + end def indent indent=case @dob.indent when /1/; '0mm' @@ -928,6 +1063,19 @@ WOK \\item[] } {\\end{list}} + +\\newenvironment{ParagraphHang}[2]% +{ +\\begin{list}{}{% +\\setlength\\topsep{0pt}% +\\addtolength{\\leftmargin}{#1} +\\itemindent=#2 +\\setlength\\parsep{0pt plus 1pt}% +} +\\item[] +} +{\\end{list}} + \\newenvironment{Bullet}[1]% { \\begin{list}{}{% -- cgit v1.2.3