[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: table.el downcase HTML tags

From: Stuart D. Herring
Subject: Re: table.el downcase HTML tags
Date: Tue, 30 May 2006 15:08:51 -0700 (PDT)
User-agent: SquirrelMail/1.4.3a-11.EL3

[Sorry if this is a resend; mail client broke.]

> (defun table--generate-source-html-tag (tag-symbol text &optional options)
>   (let ((tag-symbol (if table-uppercase-html-tags
>                      (upcase tag-symbol)
>                    tag-symbol)))
>     (format "<%s %s> %s </%s>" tag-symbol options text tag-symbol)))
> This would also simplify a lot of the table.el code that generates HTML :)

The resulting HTML would be ugly and somewhat incorrect:

(table--generate-source-html-tag "a" "")
 => "<a nil>  </a>"

I'd use

(defun table--generate-source-html-tag (tag &optional body attrs)
  (when table-uppercase-html-tags (setq tag (upcase tag)))
  (concat "<" tag (if attrs " ") attrs
          (if body (concat ">" body "</" tag) "/") ">"))


(table--generate-source-html-tag "a" "b" "c=d")
 => "<a c=d>b</a>"
(table--generate-source-html-tag "a")
 => "<a/>"

I removed the spaces around the body because they could break things and
are trivial to include in the argument.  I'd really be tempted to make
attrs an alist, but that might be overengineering the problem.  The
XML-style empty tags might be undesirable, but they're optional:

(table--generate-source-html-tag "a" "")
 => "<a></a>"

Hope it helps,

This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during

reply via email to

[Prev in Thread] Current Thread [Next in Thread]