Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Apr 2001 20:58:52 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        Nik Clayton <nik@freebsd.org>
Cc:        doc@freebsd.org
Subject:   Re: <programlisting> cleanup (was: cvs commit: doc/en_US.ISO_8859-1/articles/fonts article.sgml ...)
Message-ID:  <20010410035852.69F523E09@bazooka.unixfreak.org>
In-Reply-To: <20010409100310.A876@canyon.nothing-going-on.org>; from nik@freebsd.org on "Mon, 9 Apr 2001 10:03:10 %2B0100"

next in thread | previous in thread | raw e-mail | index | archive | help
If any of the translation teams want to clean up their parts of the
repository to use <programlisting> correctly (you'd be amazed how many
times it isn't), keep reading.

Nik Clayton <nik@freebsd.org> writes:
> On Sun, Apr 08, 2001 at 05:33:59PM -0700, Dima Dorfman wrote:
> >   Log:
> >   DocBook police: open and close tags for <programlisting> should cuddle
> >   up to the contents within.
> 
> Can you post the script/code that did this to the -doc list, so that the
> translation teams can use it as well.  Cheers,

Attached is the Emacs Lisp program (if you can call it that) to
correct one file.  Run it like this:

	emacs -batch -l /home/you/the-prog.el filename.sgml -f correct-buffer

where /home/you/the-prog.el is the path to the program attached, and
filename.sgml is the file you want to correct.  I ran it inside a loop
like so to correct all SGML files under en_US.ISO_8859-1:

	#!/bin/sh
	for f in `find . -name "*.sgml" -print`; do
	  emacs -batch -l /home/dima/pgc.el $f -f correct-buffer;
	done

It's not terribly efficient since it runs Emacs multiple times (and we
all know how large that is), but it works well as far as I know.

					Dima Dorfman
					dima@unixfreak.org

P.S.  I used elisp because it seems Emacs has the only regular
expression engine capable of dealing with newlines correctly.  Yes,
you could do it in sed using the 'N' function, but I couldn't get it
to work right.


(defun opentag-pass ()
  (beginning-of-buffer)
  (while (re-search-forward "\\(<programlisting>\\)\n" nil t)
    (replace-match "\\1" nil nil)))

(defun closetag-pass ()
  (beginning-of-buffer)
  (while (re-search-forward "\n *\\(</programlisting>\\)" nil t)
    (replace-match "\\1" nil nil)))

(defun correct-buffer ()
  (opentag-pass)
  (closetag-pass)
  (save-buffer))


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-doc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010410035852.69F523E09>