Re: Color and font size of cells within a table

Subject: Re: Color and font size of cells within a table
From: Norman Walsh <norm@xxxxxxxxxxxxx>
Date: Wed, 11 Mar 1998 14:32:21 -0500
/ "Jordi Mulet" <jmulet@xxxxxxxxxx> was heard to say:
[...]
| We are using the DocBook style sheets of Norman and we are interested 
| about modify the color and the font size of several cells in a table. We 
| are pursuing to redefine the process in an external file conveni.dsl as 
|  
| (define ($process-cell-para-contents$ para colnum align body)
[...]
|  
| but use a Processing Instruction in the table or in the cell

I understand you to mean that you want to do something like this in
your source document:

...
<row>
  <entry><?cell-color red>some red text</entry>
  <entry>regular colored text</entry>
</row>

Where the "cell-color" PI might be inherited from the <row>
level or even farther above.  If this is the case, I think that
$process-cell-para-contents$ is probably not quite the right
plae to do it.

Instead, I'd modify $process-cell$.  The lines marked with *** below
are the lines I'm adding/changing:

(define ($process-cell$ entry preventry overhang)
  (let* (
;;	 (celldebug (debug (string-append 
;;			  (number->string (cell-column-number entry overhang))
;;			  " "
;;			  (data entry))))
	 (colnum (cell-column-number entry overhang))
	 (lastcellcolumn (if (node-list-empty? preventry)
			     0
			     (- (+ (cell-column-number preventry overhang)
				   (hspan preventry))
				1)))
	 (lastcolnum (if (> lastcellcolumn 0)
			 (overhang-skip overhang lastcellcolumn)
			 0))
;; *** vvv
	 (color ($find-color-pi$))
;; *** ^^^
	 (htmlgi (if (have-ancestor? "TBODY" entry)
		     "TD"
		     "TH")))
    (make sequence
      ;; This is a little bit complicated.  We want to output empty cells
      ;; to skip over missing data.  We start count at the column number
      ;; arrived at by adding 1 to the column number of the previous entry
      ;; and skipping over any MOREROWS overhanging entrys.  Then for each
      ;; iteration, we add 1 and skip over any overhanging entrys.
      (let loop ((count (overhang-skip overhang (+ lastcolnum 1))))
	(if (>= count colnum)
	    (empty-sosofo)
	    (make element gi: htmlgi
		  (make entity-ref name: "nbsp")
;;		  (literal (number->string lastcellcolumn) ", ")
;;		  (literal (number->string lastcolnum) ", ")
;;		  (literal (number->string (hspan preventry)) ", ")
;;		  (literal (number->string colnum ", "))
;;		  ($debug-pr-overhang$ overhang)
		  (loop (overhang-skip overhang (+ count 1))))))

      (make element gi: htmlgi
	    attributes: (append
			 (if (> (hspan entry) 1)
			     (list (list "COLSPAN" (number->string (hspan entry))))
			     '())
			 (if (> (vspan entry) 1)
			     (list (list "ROWSPAN" (number->string (vspan entry))))
			     '())
;; *** vvv
			 (if color
			     (list (list "STYLE" (string-append "color: " color)))
			     '())
;; *** ^^^
			 (if (equal? (cell-colwidth entry colnum) "")
			     '()
			     (list (list "WIDTH" (cell-colwidth entry colnum))))
			 (list (list "ALIGN" (cell-align entry colnum)))
			 (list (list "VALIGN" (cell-valign entry colnum))))
	    ($process-cell-contents$ entry colnum)))))

I've used the CSS style attribute to change the color of the cell, I can't
think of another way to do it off the top of my head.  If you need to do
it with <FONT> or something, you'll have to adjust the function a little
more.  

Now all we need is a definition of $find-color-pi$. The HTML stylesheets
already include a pi-matching function, so I think this will do it:

(define ($find-color-pi$)
  (let ((color (inherited-pi-value (current-node) "cell-color")))
    (if color
	color
	#f)))

Does that help?

| and no an fix factor. 

I'm a little lost here.  Could you explain in a little more detail
what you mean by a fix factor?

--norm


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • Color and font size of cells within a table
    • Jordi Mulet - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id CAA14672Wed, 11 Mar 1998 02:53:17 -0500 (EST)
      • <Possible follow-ups>
      • Jordi Mulet - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id EAA21080Wed, 11 Mar 1998 04:59:12 -0500 (EST)
      • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id OAA28707Wed, 11 Mar 1998 14:35:53 -0500 (EST)
      • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id OAA28729Wed, 11 Mar 1998 14:35:58 -0500 (EST) <=
      • Jordi Mulet - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id MAA21179Thu, 12 Mar 1998 12:10:23 -0500 (EST)
      • Jordi Mulet - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id OAA15256Fri, 13 Mar 1998 14:04:28 -0500 (EST)