TITLE
}
{#define END=
}
{#define SmallFont=}
{#define EndSmallFont=}
{#define TOC=TOC}
{#define pre=}
{#define ppre=}
{#define tt/X=X}
{#define product=SOURCE SPLIT v1.0}
{@define file=%file}
%file index.html.jam
{product}
%file indexf.html.jam
{START/{product}}
This program is a simple one. It splits a text file into small pieces.
The source file is like:
{pre}
{file} first.txt
these are the
lines of first.txt
{file} second.txt
these are the lines of the second
file
{file} third.txt
the third file
{ppre}
and the results are three files each containing the lines between the directive {tt %file}
and next one.
You start the program using the command line:
{pre}
ssplit file [directory]
{ppre}
to split the {tt file} into the {tt directory}. The default directory is the current one.
You can change the directory using the directive {tt %dir} in the source file. The directory
given on the command line, the directory given on the directive {tt %dir} and the actual
file name are appended to calculate the result file. Directories are automatically created.
When a file has the same content as it had before it is not saved over the old one. This means
that tools, like {tt make} can depend on file time.
Why do anyone need this tool? You may not. It is a matter of taste how big files you like
to edit and maintain. Sometimes I have to edit many small files. Those times it is better
to have a larger one.
Program source Perl program, this is a text file.
You may need CRLF conversion if I uploaded the wrong way or if you are on a different
opsys.
Documentation source in a single file. (Do not just click on it!
Push the right eye of your mouse, {tt Save target as} and use notepad, vi, more as you like.)
Be aware that the documentation is made using
{jamal} under Windows NT.
This means that this example source file will contain not only pure HTML but also weird macros.
You may also be interested to have a look at the Windows NT command file
that starts the scripts to generate the final HTML that you read. Note that the script locations
reflect those I have on my web development system. Also be aware that this weird script first
splits the source file, then applies {jamal} to generate another command file that processes
all files with extension {tt .jam} that were generated. May be woth looking at how it works.
using with {jamal}
If oyu are a {jamal} user see my notes.
Bugs
There are no bugs in it that I know of otherwise I would have corrected it.
You might consider it a bug:
- There is no way to include a line into the output that looks like {tt %file } or
{tt %dir}. This could be done, like replacing all {tt %%} to {tt %} and all {tt %%%} to {tt %%} and
so on, but I saw no reason.
- {tt %dir} is relative. You may say {tt %dir /etc}, but that is going to be {tt ./etc} or
{tt anydir/etc} if you specified {tt anydir} on the command line.
- {tt %dir} is no additive. You can not say {tt %dir etc} and {tt %dir sbin} but it won't give
{tt etc/sbin}. You have to use {tt %dir etc} and then {tt %dir etc/sbin}.
- File names may contain directory path. If this is a bug and not a feature. The directive {tt %dir}
is a help to maintain location.
Feedback
As usual by eMail
{END}
%file lm.html.jam
%file jamal.html.jam
{START/Using ssplit with jamal}
There are three ways using {product} together with {jamal}:
- Apply {jamal} to the source then split.
- Split the source, then apply {jamal} to the fractions.
- Apply {jamal} to the source then split and apply {jamal} to the fractions.
When choosing a method consider the followings:
- Splitting is a fast action, {jamal} is somewhat slower because it performs more complex tasks.
Therefore using method 1. will put all the content through {jamal}, while 2. will only process
the content that was changed. The method 2. is usually faster.
- When you split the source the macros defined in the source file are available only whithin
the fractions created by the splitting process.
You should specify a {jamal} include file fraction
(usually with extension {tt jim}) and include it into all files.
This way the macro file is processed by jamal for each fraction processed. If this macro file
is large it might be faster to follow method 1.
- Method 3. is complex and needs the redefinition of the macro bracket characters recommended
for {jamal} experts only.
You may also write a j-SEX module that generate several files.
{END}
%file build.txt
{#define jamal=perl ../jamal/jamal.pl}
{@dir/./-f *.jam/
{#if|{#>= {#-t {$file$name}} {#-t ../{$file$nam}}}|\
{jamal} -m temp/macros.jim temp/{$file$name} {$file$nam}|}
}