From owner-freebsd-doc Mon Apr 9 20:58:55 2001 Delivered-To: freebsd-doc@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id C5AD937B42C; Mon, 9 Apr 2001 20:58:52 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 69F523E09; Mon, 9 Apr 2001 20:58:52 -0700 (PDT) To: Nik Clayton Cc: doc@freebsd.org Subject: Re: cleanup (was: cvs commit: doc/en_US.ISO_8859-1/articles/fonts article.sgml ...) In-Reply-To: <20010409100310.A876@canyon.nothing-going-on.org>; from nik@freebsd.org on "Mon, 9 Apr 2001 10:03:10 +0100" Date: Mon, 09 Apr 2001 20:58:52 -0700 From: Dima Dorfman Message-Id: <20010410035852.69F523E09@bazooka.unixfreak.org> Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org If any of the translation teams want to clean up their parts of the repository to use correctly (you'd be amazed how many times it isn't), keep reading. Nik Clayton writes: > On Sun, Apr 08, 2001 at 05:33:59PM -0700, Dima Dorfman wrote: > > Log: > > DocBook police: open and close tags for 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 "\\(\\)\n" nil t) (replace-match "\\1" nil nil))) (defun closetag-pass () (beginning-of-buffer) (while (re-search-forward "\n *\\(\\)" 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