[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-wiki-discuss] Re: Indenting <example> tags
From: |
Michael Olson |
Subject: |
[emacs-wiki-discuss] Re: Indenting <example> tags |
Date: |
Wed, 22 Jun 2005 02:08:22 -0500 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
Allen Halsey <address@hidden> writes:
> I like to indent my <example> tags so that they stand out from the
> text, like this:
>
> <example>
> # Print a message
> echo 'hello world'
> <example>
>
> However, the published html includes the indentation spaces:
>
> [snip]
>
> Any hints on how I can achieve this?
Try adding the following to your .emacs.
(defun emacs-wiki-example-tag (beg end highlight-p)
(if highlight-p
(progn
(remove-text-properties
beg end '(face nil font-lock-multiline nil
invisible nil intangible nil display nil
mouse-face nil keymap nil help-echo nil))
(goto-char end))
(insert "<pre class=\"example\">")
(while (memq (char-after) '(?\n ?\ ?\t))
(delete-char 1)) ; delete leading whitespace.
(save-excursion
(save-match-data
(while (re-search-forward (concat "^["
emacs-wiki-regexp-blank
"]+")
end t)
(replace-match ""))))
(emacs-wiki-escape-html-specials end)
(when (< (point) end)
(goto-char end))
(insert "</pre>")
(add-text-properties beg (point) '(rear-nonsticky (read-only)
read-only t))))
--
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: anime, Debian, XHTML, wiki, Emacs Lisp
/` |\ | | | IRC: mwolson on freenode.net: #hcoop, #muse, #pulug
|_] | \| |_| Jabber: mwolson_at_hcoop.net
pgpQmpVrlIMb8.pgp
Description: PGP signature