summaryrefslogtreecommitdiff
path: root/tmac
diff options
context:
space:
mode:
authorwl <wl>2005-02-16 14:07:23 +0000
committerwl <wl>2005-02-16 14:07:23 +0000
commitadb8606f04b2c267674d6309c2263f429a0b6494 (patch)
tree2e9f244087554471645c147e82da0b4c3eac7780 /tmac
parent01317f4cac00f1d64be39b706bb84c9a8fadd284 (diff)
downloadgroff-adb8606f04b2c267674d6309c2263f429a0b6494.tar.gz
These patches modify the indentation implementation to use `<p
style=margin-left: n%>'. Many thanks to Peter and Larry for suggesting this solution. Grohtml only uses tables for `.IP' and related tags when the first operand has a short width. Similarly, they modify all vertical space code. By default, grohtml sets up a style sheet which uses no vertical space between `table', `pre', and `p' tags. It forces spaces when it needs them using `style="margin-top: 1em"'. * src/devices/grohtml/html-table.cpp: Include `html-text.h'. (html_table::emit_table_header, html_table::emit_new_row): Rewritten. (html_table::set_space): New function. (html_indent::html_indent): Don't set `is_used'. (html_indent::begin): Rewritten. (html_indent::end): Remove code in function. * src/devices/grohtml/html-table.h: Updated. (html_table): Make `out' public. * src/devices/grohtml/html-text.cpp (html_text::html_text): Initialize `start_space' with FALSE. (html_text::end_tag) <P_TAG, PRE_TAG>: Updated. (html_text::issue_tag): Add argument to handle space style. (html_text::start_tag) <P_TAG, PRE_TAG>: Updated. (html_text::flush_text): Don't set `start_space'. (html_text::push_para): Don't set `p->really_issued'. (html_text::do_emittext): Updated. (html_text::do_para): Add paremeter to handle space. Update all callers. (html_text::retrieve_para_space): New function. * src/devices/grohtml/html-text.h (STYLE_VERTICAL_SPACE): New macro. (tag_definition): Remove `really_issued'. (html_text): Updated. * src/devices/grohtml/post-html.cpp (html_printer): Add variables `current_column' and `row_space'. Update constructor. (html_printer::emit_raw, html_printer::write_header, html_printer::do_indent, html_printer::do_check_center, html_printer::do_tab_ts): Handle vertical space. (html_printer:do_tab_te, html_printer::do_end_para): Call `remove_para_space'. (html_printer::do_col): Rewritten. (html_printer::flush_globs): Remove debugging code. (html_printer::is_line_start): New function. (html_printer::start_font): Use `is_line_start'. (html_printer::writeHeadMetaStyle): New function. (html_printer::do_file_components, html_printer::~html_printer): Call `writeHeadMetaStyle'. * tmac/www.tmac (www-handle-percent): New macro. (MPIMG): Handle percent values for width and height parameters. (DC): Updated. * tmac/groff_www.man: Updated.
Diffstat (limited to 'tmac')
-rw-r--r--tmac/groff_www.man18
-rw-r--r--tmac/www.tmac111
2 files changed, 113 insertions, 16 deletions
diff --git a/tmac/groff_www.man b/tmac/groff_www.man
index ce203024..4601b7af 100644
--- a/tmac/groff_www.man
+++ b/tmac/groff_www.man
@@ -1,5 +1,6 @@
.TH GROFF_WWW @MAN7EXT@ "@MDATE@" "Groff Version @VERSION@"
-.\" Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+.\" Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
+.\" Free Software Foundation, Inc.
.\" Written by Gaius Mulley (gaius@glam.ac.uk)
.\"
.\" This file is part of groff.
@@ -329,6 +330,21 @@ Example:
.ft P
.fi
.RE
+.IP
+The height and width may also be given as percentages. The PostScript
+device calculates the width from the
+.B .l
+register and the height from the
+.B .p
+register. For example:
+.RS
+.IP
+.nf
+.ft B
+\&.MPIMG -L -G 2c foo.png 15%
+.ft P
+.fi
+.RE
.
.TP
.B .HnS n
diff --git a/tmac/www.tmac b/tmac/www.tmac
index 1f4da764..8fa1b9bd 100644
--- a/tmac/www.tmac
+++ b/tmac/www.tmac
@@ -10,7 +10,7 @@ Installed position: groff's main macro directory.
This file is part of groff, the GNU roff type-setting system.
-Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
written by Gaius Mulley <gaius@glam.ac.uk>, with additions by
Werner Lemberg <wl@gnu.org> and Bernd Warken <bwarken@mayn.de>.
@@ -524,6 +524,32 @@ www functionality. It should work with any macro set.
. wh \\n[www-left-ll-trap]u
. nr www-left-ll-trap 0
..
+.
+.\" www-handle-percent arg N1 N2 S1
+.\" arg - input string (number or number%)
+.\" output parameters:
+.\" N1 - name of number register 1=absolute 0=percentage
+.\" N2 - number register name for absolute value
+.\" S1 - string register name for percentage value
+.
+.de www-handle-percent
+. ds www-percent \\$1\"
+. substring www-percent -1 -1
+.
+. ie '\\*[www-percent]'%' \{\
+. ds www-abs \\$1\"
+. substring www-abs 0 -2
+. nr \\$2 0
+. nr \\$3 \\*[www-abs]
+. ds \\$4 \\$1\"
+. \}
+. el \{\
+. nr \\$2 1
+. nr \\$3 \\$1
+. ds \\$4 none\"
+. \}
+..
+.
.\" --------------------------------------------------------------------
.\" MPIMG [-R|-L] [-G gap] filename [width [height]]
.\"
@@ -531,6 +557,10 @@ www functionality. It should work with any macro set.
.\" -Tps and -Thtml. The default value for WIDTH is 1i; default value
.\" for HEIGHT is WIDTH; the default alignment is left (-L).
.\" -G is used to insert a gap between the text and the image.
+.\" The height and width can also be given as a percentage.
+.\" The PostScript device converts the percentage width into an
+.\" absolute value by using \\n[.l], and the height by using \\n[.p].
+.\"
.\"
.\" Note: This macro can only be used with the `-U' option of groff,
.\" activating unsafe mode, if not used with -Thtml; the PNG image
@@ -561,24 +591,74 @@ www functionality. It should work with any macro set.
. \}
. break
. \}
+.
. nr www-width 1i
-. if !'\\$2'' \
-. nr www-width \\$2
-. nr www-height \\n[www-width]
-. if !'\\$3'' \
-. nr www-height \\$3
-. nr www-width (\\n[www-width] * 100 / 240)
-. nr www-height (\\n[www-height] * 100 / 240)
+. nr www-height 1i
+. ds www-size-specs "width=\\n[www-width] height=\\n[www-height]\"
+. ie !'\\$2'' \{\
+. nr www-is-absolute 0
+. nr www-absolute 0
+. ds www-percentage none\"
+. www-handle-percent \\$2 www-is-absolute www-absolute www-percentage
+. ie !\\n[www-is-absolute] \{\
+. \" percentage of linelength requested
+. nr www-width (\\n[www-absolute] * \\n[.l] / 100)
+. if \\n[www-html] \
+. nr www-width (\\n[www-width] * 100 / 240)
+. ds www-size-specs "width=\\*[www-percentage]\"
+. \}
+. el \{\
+. nr www-width \\n[www-absolute]
+. if \\n[www-html] \
+. nr www-width (\\n[www-width] * 100 / 240)
+. ds www-size-specs "width=\\n[www-width]\"
+. \}
+.
+. nr www-height \\n[www-width]
+. ie !'\\$3'' \{\
+. nr www-is-absolute 0
+. nr www-absolute 0
+. ds www-percentage none\"
+. www-handle-percent \\$3 www-is-absolute www-absolute www-percentage
+. ie !\\n[www-is-absolute] \{\
+. \" percentage of pagelength requested
+. nr www-height (\\n[www-absolute] * \\n[.p] / 100)
+. if \\n[www-html] \
+. nr www-height (\\n[www-height] * 100 / 240)
+. ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
+. \}
+. el \{\
+. nr www-height \\n[www-absolute]
+. if \\n[www-html] \
+. nr www-height (\\n[www-height] * 100 / 240)
+. ds www-size-specs "\\*[www-size-specs] height=\\*[www-height]\"
+. \}
+. \}
+. \}
+. el \{\
+. \" height not specified; use width value
+. ie !\\n[www-is-absolute] \{\
+. \" percentage value
+. ds www-size-specs "\\*[www-size-specs] height=\\*[www-percentage]\"
+. nr www-height \\n[www-width]
+. \}
+. el \{\
+. ds www-size-specs "\\*[www-size-specs] height=\\*[www-width]\"
+. nr www-height \\n[www-width]
+. \}
+. \}
.
. ie \\n[www-html] \{\
. ie !\\n[www-image-just] \
. HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
- align=right width=\\n[www-width] height=\\n[www-height]>
+ align=right \\*[www-size-specs]>
. el \
. HTML <img src="\\$1" alt="Image \\$1" hspace=\\n[www-htmlimage-gap] \
- align=left width=\\n[www-width] height=\\n[www-height]>
+ align=left \\*[www-size-specs]>
. \}
. el \{\
+. tm www-width is \\n[www-width]
+. tm www-height is \\n[www-height]
. if !r ps4html \{\
. www-make-unique-name
. sy pngtopnm \\$1 | pnmcrop -white | @PNMTOPS_NOSETPAGE@ -noturn > \\*[www-unique-name].eps
@@ -589,7 +669,7 @@ www functionality. It should work with any macro set.
. wh \\n[www-left-ll-trap]u
. if (\\n[www-left-po-trap] > 0) \
. wh \\n[www-left-po-trap]u
-. PSPIC -R \\*[www-unique-name].eps \\$2 \\$3
+. PSPIC -R \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
. sp -\\n[ps-desht]u
. nr www-right-indent \\n[ps-deswid]u
. \" we want to have some space between text and image,
@@ -608,7 +688,7 @@ www functionality. It should work with any macro set.
. \" we must now disable a possible right image trap
. if (\\n[www-right-ll-trap] > 0) \
. wh \\n[www-right-ll-trap]u
-. PSPIC -L \\*[www-unique-name].eps \\$2 \\$3
+. PSPIC -L \\*[www-unique-name].eps \\n[www-width]u \\n[www-height]u
. sp -\\n[ps-desht]u
. nr www-left-indent \\n[ps-deswid]u
. \" increase offset by gap
@@ -790,7 +870,8 @@ www functionality. It should work with any macro set.
. ds www-dropcolor \\$3
. ie '\*(.T'html' \{\
. www-make-unique-name
-. MPIMG -L \\*[www-unique-name].png "(\\n[.v] * 2u)"
+. nr www-drop-width (100u * \\n[.v]u * 3u / \\n[.l]u)
+. MPIMG -L \\*[www-unique-name].png "\\n[www-drop-width]%"
. \}
. el \{\
. ie r ps4html \{\
@@ -801,9 +882,9 @@ www functionality. It should work with any macro set.
. \" glyphs overlap.
. bp
. ev www-DC
-. vs 80p
+. vs 320p
. nop \O[5i\\*[www-unique-name].png]\O[1]
-. nop \m[\\*[www-dropcolor]]\s[40]\O[3]\\$1\O[4]
+. nop \m[\\*[www-dropcolor]]\s[160]\O[3]\\$1\O[4]
. nop \O[2]\O[0]
. br
. ev