Subject: Re: PROPOSAL: Indentation style and other nits
To: Hubert Feyrer <hubert@feyrer.de>
From: Rui Paulo <rpaulo@NetBSD.org>
List: netbsd-docs
Date: 07/16/2005 23:35:55
On 2005.07.17 00:29:48 +0000, Hubert Feyrer wrote:
 | On Sat, 16 Jul 2005, Rui Paulo wrote:
 | >| I wonder if there's some tool like pkgsrc/www/tidy or indent(1) for
 | >| DocBook/XML, to make it easier to get to that style?
 | >
 | >I wasn't able to tell tidy about this specific indentation. I normally
 | >use Emacs + psgml.. but not everyone likes emacs.
 | 
 | Let me put the question the other way round: Is there some ~easy[1]
 | way to transform a "badly" indented file into a "properly" indented file, 
 | with as little manual effort as possible? Assuming the file's in proper 
 | structure, XML-wise, of course.

Yes, it is. It's called Emacs PSGML mode.
I use the following settings:

;
; psgml mode
;
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)

(setq sgml-catalog-files '("/usr/pkg/share/sgml/catalog"
                           "/home/rpaulo/cvs.netbsd.org/htdocs/guide/en/share/catalog"
                           "/home/rpaulo/cvs.netbsd.org/htdocs/share/xml/catalog"
                           ))

(setq auto-mode-alist
      (append '(("\\.html?$" . sgml-mode)
                ("\\.sgml?$" . sgml-mode)
                ("\\.xml$" . xml-mode)
                ("\\.xsl$" . xml-mode))
              auto-mode-alist))

(setq sgml-indent-data t)
(setq sgml-balanced-tag-edit t)
(setq sgml-auto-activate-dtd nil)

(make-face 'sgml-comment-face)
(make-face 'sgml-start-tag-face)
(make-face 'sgml-end-tag-face)
(make-face 'sgml-entity-face)
(make-face 'sgml-doctype-face)

(set-face-foreground 'sgml-comment-face "FireBrick")
(set-face-foreground 'sgml-start-tag-face "SlateBlue")
(set-face-foreground 'sgml-end-tag-face "SlateBlue")
(set-face-background 'sgml-entity-face "SlateBlue")
(set-face-foreground 'sgml-entity-face "Red")
(set-face-foreground 'sgml-doctype-face "FireBrick")

(setq sgml-set-face t)  ; without this, all SGML text is in same color
(setq sgml-markup-faces
   '((comment   . sgml-comment-face)
     (start-tag . sgml-start-tag-face)
     (end-tag   . sgml-end-tag-face)
     (doctype   . sgml-doctype-face)
     (entity    . sgml-entity-face)))



 | Personally I include emacs as "easy"; problematic would be things like 
 | GNOME or KDE, size- and dependency-wise. This doesn't answer the "no 
 | manual effort" part though (I like emacs myself, but am not competent 
 | enough to tell what psgml-mode is :).

http://www.lysator.liu.se/projects/about_psgml.html :) there are pkgsrc
pkgs too. :)


		-- Rui Paulo