This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: DOCBOOK: auto-indent tool, it worksd with tidy
- To: madhu <b_maddy_016 at yahoo dot com>
- Subject: DOCBOOK-APPS: Re: DOCBOOK: auto-indent tool, it worksd with tidy
- From: Carlos Eduardo Selonke de Souza <cess at matrix dot com dot br>
- Date: Tue, 13 Jun 2000 15:22:50 -0300 (EST)
- Cc: docbook-apps at lists dot oasis-open dot org, camille at mandrakesoft dot com
On 12-Jun-00 madhu wrote:
> it is possible to do it with Tidy ;-)
> the trick is to make tidy think that it is a xml document
> so do this to your document, just add <xml> at the begining and </xml> at the
> end and you need not rename it to .xml or any such thing . and use this
> command
> with tidy:
>
> tidy -i -m -xml *.sgm or .sgml
> bingo
> only thing is tidy attaches <?xml version="1.0" ?> to your document at the
> begining just remove it with the <xml></xml> tag that shouldn't be too much
> of
> a job ?
Hello
It works very well.
My little contribution.
1. You dont need to add <xml></xml> to your documents.
Just use
#tidy -m -i -xml foo.sgml
2. Tidy will add <?xml version="1.0" ?>
as the first line of your document.
To extract that line, you have several options :).
My option.
If you are using a UNIX OS, you can use sed.
You can use runsed, a script from UNIX Power Tools book (www.
ftp.oreilly.com/published/oreilly/power_tools/unix/split/runsed
runsed is a script that helps you to run sed in many files without needing to
rename them.
You have to create a file called
sedscr
in the directory where you will run runsed. This file will contain the
instructions to applies to the input files.
An Example, indent the test.sgml file.
Original test.sgml:
[15:13][magnus@magnus sgml]$ cat test.sgml
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<article>
<sect1>
<title>Teste</title>
<sect2>
<title>Teste title sect2</title>
<subtitle>teste subtile sect2</subtitle>
<para>Para</para>
</sect2>
<sect2>
<title>Teste title sect2</title>
<subtitle>Teste subtitle sect2</subtitle>
<para>Para</para>
</sect2>
</sect1>
</article>
Run tidy:
[15:14][magnus@magnus sgml]$ tidy -i -m -xml test.sgml
[15:14][magnus@magnus sgml]$ cat test.sgml
<?xml version="1.0"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<article>
<sect1>
<title>Teste</title>
<sect2>
<title>Teste title sect2</title>
<subtitle>teste subtile sect2</subtitle>
<para>Para</para>
</sect2>
<sect2>
<title>Teste title sect2</title>
<subtitle>Teste subtitle sect2</subtitle>
<para>Para</para>
</sect2>
</sect1>
</article>
Remove first line of test.sgml using runsed script.
Create the file sedscr, with the options for sed.
sedscr will remove the first line of the input file. (1d)
[15:14][magnus@magnus sgml]$ cat sedscr
1d
[15:15][magnus@magnus sgml]$ runsed test.sgml
runsed: editing test.sgml:
runsed: done with test.sgml
runsed: all done
[15:16][magnus@magnus sgml]$ cat test.sgml
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<article>
<sect1>
<title>Teste</title>
<sect2>
<title>Teste title sect2</title>
<subtitle>teste subtile sect2</subtitle>
<para>Para</para>
</sect2>
<sect2>
<title>Teste title sect2</title>
<subtitle>Teste subtitle sect2</subtitle>
<para>Para</para>
</sect2>
</sect1>
</article>
If you have a lot of files to indent I belive this is a solution, because you
can use tidy and runsed with pattern matching.
Hope that helps.
Regards
Carlos Eduardo Selonke de Souza
http://www.br-unix.org/users/cess
-----BEGIN GEEK CODE BLOCK-----
Version:3.1
GE d+@ s+:+ a-- C+++ UB++> P+ !L E W++(+) N+> K- w--
!O !M V- PS+ PE+ Y PGP- t+ 5 X++ R- tv++ b++ DI++ D+
G e++ h r+++ y+++
-----END GEEK CODE BLOCK------