Bride of Text 2.0
A command-line static web page generator written in Perl5.
Though there are counless other similar projects, this one exists because I didn't write any of the others. This is a tiny tool that is tailor-made to my preferences.
See syntax.txt and syntax.html for the source and generated output. The syntax is extremely compact and strict, making it easy to write and to parse.
In particular, look at the implementation of tables. They look good in the .txt source and yet are extremely easy to type since most of the beautification in raw text is optional.
Bride takes three arguments. Example:
./bride.pl syntax.txt syntax.html template.html
The first is the source text file, the second is the destination HTML filename (Bride will create it), and the third is a template HTML file.
Generating multiple files or whole websites can be easily solved with shell scripts or with a Makefile, such as this one I use myself:
SRC = $(wildcard txt/*.txt) OUT = $(patsubst txt/%.txt,html/%.html,$(SRC)) .PHONY: all all: $(OUT) debug: # SRC: $(SRC) # OUT = $(OUT) html/%.html: txt/%.txt bride $< $@ template.html .PHONY: clean clean: rm -f $(OUT)
The Makefile converts all .txt files in a txt/ directory to .html files in an html/ directory using the
bride command (I have created a symlink to bride.pl called
I've had good luck using this Makefile with additional rules for using different templates for particular pages, etc.
Or here's a Bash shell script I've saved as
/usr/local/bin/brideit for generating stand-alone pages quickly from the commandline:
#!/bin/bash bride $1.txt $1.html /home/dave/projects/brideoftext2/template.html
(Obviously, you'll need to change the template path to the file of your choice.)
This lets you create an HTML document from foo.txt as easily as:
The different ways to accomplish this are endless and are specific to your operating system and needs.
The template contains the basic structure of the HTML document you wish to generate. It should include the
Currently, there are only two template variables which will be populated:
See the example template.html that comes with this project.