OK, here it is. The TextMate DocBook-bundle (click the link to download) I’m using for production.
The emphasis is on I’m using. The bundle contains the entities I need for my daily work. Means, it does not contain all entities which can be used writing books and articles in DocBook. There are no templates, since I’m tweaking my DocBook-workflow at the moment.
You can use the bundle to ease the pain regarding spurious >-signs by writing e.g. application or systemitemnext to the </para>-tag and hit the ⇥-key, instead of typing <-⇥ and removing the additional > appearing next to the </para>-tag. There are indexterms, xrefs, ulinks, etc. Check it in the Bundle-Editor in TextMate.
On shortcut probably needs explanation, if you type entity followed by ⇥, a line appears copying the symbolic name used in the document, e.g. ch08 to the end of the same line with the extension .xml added. I tend to (especially late at night) introduce typos in the filenames.
The result is a run-of-the-mill entity-declaration like this:
<!ENTITY ch08 SYSTEM "ch08.xml">
It’s your job to include the entity at the right spot in your master-document.
There is no sanity-check whatsoever, you have to make sure, that the structure is OK. The bundle is not a tool to teach anyone, it’s a tool to speed up my writing. If you are not sure about the “parents” or “children” allowed for a tag, take a look at DocBook: The Definitive Guide.
Templates will be included in one of the next incarnations. I’m thinking about adding the creation of PDFs using fop to the bundle, for the time being, you’ll have to use your own scripts. Watch this space.
I hope you can put the bundle to use. If there is anything you miss, drop me a comment (moderated).
If you have no idea what TextMate is and you are using a Macintosh running OS X to write in DocBook, check out the link, seriously.
8 Comments
Erik, what version of DocBook are you using? Does your bundle play nice with the Relax NG version of DocBook 5.0?
@GeneG1: The bundle contains just ⇥-expansions, as stated in the post. It does not check the hierarchy of tags for validity while writing, a.k.a. you have to know what you’re doing.
If you are looking for a mechanism like the one in Emacs, telling you the valid tags for the current position of your cursor, then I’m sorry.
Regarding Relax NG, as soon as my publisher (read the printshop) is able to cope with that, I’ll look into it. The sole purpose of the bundle is to make my (writing-)life easier. I’m working on some automation, though.
Hey Erik – thanks for the bundle. We recently need to add a lot of new images to a docbook file, so created a new drag item that allows you to drag an image into a docbook file and create an tag with fileref, contentwidth and contentdepth attributes filled in automatically! Very cool – modified from the similar image drag item for the HTML bundle…
Here’s how you do it (after installing Erik’s DocBook bundle in Textmate)
In Textmate:
- open a docbook file (for practice)
- go to Bundles->Bundle Editor->Show Bundle Editor
- open the ‘Docbook’ bundle in the lefthand window of the editor (select an entry there to be sure)
- click the ‘+’ at the bottom left and choose ‘New Drag Command’
- Type ‘imagedata’ as the name, then go to the righthand side of the editor
- Add file types: png, jpg, gif
- In Command(s), replace the existing text with the following:
img=”$TM_DROPPED_FILE”
echo -n “”
The above can be modified for width, height and other attributes (see http://www.sagehill.net/docbookxsl/ImageSizing.html)
Alan
Hmm…. looks like the code didn’t get published properly:
img=”$TM_DROPPED_FILE”
echo -n “”
Try again:
img=”$TM_DROPPED_FILE”
echo -n “<imagedata fileref=\”$img\” ”
sips -g pixelWidth -g pixelHeight “$img” \
|awk ‘/pixelWidth/ { printf(“contentwidth=\”%d\” “, $2) }
/pixelHeight/ { printf(“contentdepth=\”%d\”", $2) }’
echo -n “/>”
Sorry for the extra comments!
Alan
@Alan: Great. I just tested the code in your third comment. Works like a charm. I’ll have to tinker with it a little to accommodate my special needs, though. (I need relative image-paths or the nice people at the printshop will go bonkers.
)
If you don’t mind, I’ll include the action in the next release of the bundle, containing a reference to you, of course.
Thanks again.
Hey – no problem. Glad it works for you. We need relative links too, and if the folder containing the images is close to the location of the docbook file (i.e. a child or sibling folder) the link should be relative (or it works for me that way, anyway).
I’m hoping ‘contentwidth’ and ‘contentdepth’ will be ok for both PDF and HTML output – we’ll be testing this in a few days.
Previously we used a simple ‘width=”100%”‘, which is fine for PDF (no stretching), but without specific image dimensions, CSS doesn’t work so well for the resulting HTML image elements (e.g. image backgrounds etc.). Anyway, if you come up with anything better, I’ll look forward to getting the updated DocBook bundle
Alan
@Alan: I’ll do my very best to add this function, and a couple of other things, to the bundle as soon as I can (I’m buried in work at the moment).
Thanks again for the tip.
One Trackback
[...] TextMate has a built-in XML bundle; however, if you are using DocBook XML, then you should use one of the free DocBook [...]