PART IV: The Hacking log

In this part, I'll try to give you bits of information that wasn't approperate to put anywhere else, because it dosn't lead to a end result. This information is about how i came to find the results. I present this in order to help you hone your texmacs hacking skills.

First off, I'll present my “color options” that I removed from the main text. They were removed, because they are bad options, but by reading through them, you might get other ideas for things you may like to do... like for example, creating “dynamically created css sheet” which automatically does positioning based on the texmacs positioning commands, instead of using gif “spacers”.

DRAFT COPY - do not slashdot this article

This is a draft version of a upcomming article. It is not yet finished. Please do not slashdot this article untill it is finished, and put under 'realeased articles'

The original color options:

Option 1 was moved here because it's not as general as the other solutions, and it requires going outside of texmacs to complete each page. This is obviously a pain to do. But do note the idea of postprocessing script. At the moment this is a sed script, and these postprocessing scripts are very bad way of doing things.

Even though they are evil, I still use sed postprocessing scripts to do some things, like insert html scripts into my pages. Why do i use them if they are so evil? Because often they can fix a imemdate need quickly. The important thing to do is to realize the ”ethical” way to be writing it, and admit that the postprocessing scripts are evil when your writing them. Then someday when your not in such a hurry, you may be able to create a more ethical version.

Note a slightly better way... it should be possible to write a postprocessing script in texmacs scheme. This would be a little better, since were not going outside of texmacs. I hope to reimplemnt my postprocessing scripts this way, and demonstrate them here someday. But this is still poor, because the right way to implement it, would be to implment a representative of whatever you wanted as a texmacs object, which rendered during the texmacs to html processing.

Option 1:

You can set the color of your text and background by document->color->foreground, document->color->background. This chages it on the screen, but as of 1.0.4.1, the colors get stripepd when you export the html page. There is a workaround for this... create a file called site.css, and enter the color numbers in it (vindable via gimp “color picker”) for the forground and background. It should look something like this: site.css. Then go get postprocess. (ok, this is silly since they are only a couple of lines, but both site.css and postprocess are released under the GPL) “chmod a+x postprocess”, then type “postprocess filename.html > new.filename.html” . Then look at new.filename.html and your colors should be right. You'll need to do this every time, before publishing the page. (remember, i said this option sucks) (and remember to copy the site.css file to your web site)

Option 2 is still a bad option, but better then Option 1. This is because options 2 is all done inside of texmacs. Hopefully reading through it will help you realize how to make all your bad hacks *inside* of texmacs. :)

Option 2:

A more fun option is to go to your texmacs instalation, and find tmhtml.scm, which for me is located in TeXmacs-1.0.4.1-static-gnu-linux/progs/convert/html/tmhtml.scm

find the section that goes:


‘(h:html 
(h:head  
(href \"site.css\")))
(h:title ,@(tmhtml env title)) 
(h:meta (@ (name \"generator\") 
(content ,(string-append \"TeXmacs \" (texmacs-version))))) ,css) (h:body ,@body))))

Add a line right below ”h:head” as follows:

(h:link (@ (rel \"stylesheet\") (type \"text/css\")

it should now look like:

‘(h:html 
(h:head 
(h:link (@ (rel \"stylesheet\") (type \"text/css\") 
(href \"site.css\"))) 
(h:title ,@(tmhtml env title)) 
(h:meta (@ (name \"generator\") 
(content ,(string-append \"TeXmacs \" (texmacs-version))))) ,css) (h:body ,@body))))

save it, and reload texmacs. Now whenever you export to html, it will include the site.css as your style sheet. I.E. only 1 step to make html files now instead of 2.

DRAFT COPY - do not slashdot this article

This is a draft version of a upcomming article. It is not yet finished. Please do not slashdot this article untill it is finished, and put under 'realeased articles'

Composer Probing:

When making html pages, we'll end up editing the tmhtml.scm file alot. We've talked about using the texmacs gui to probe the texmacs functions. Now, how do we know what the html functions are that we want to translate to? Luckily we have composer :)

Load up mozilla composer, create a new document with what you want it to look like inside it, then click the “source“ tab at the bottom, and it'll show you the html version of it. Now all ya gotta do is translate the texmacs constructs to the html constructs via scheme. :)

General resources for working in scheme:

When doing these hacks, knowing scheme could definately help. Scheme a 60 second introduction to scheme could be:

1 - scheme uses prefix notation, not infix notation. i.e. put the operator/function at the front.

so we add 2 and 3 with (+ 2 3) *not* (2 + 3)

2 - scheme uses parenthisis around everything

so (+ 2 (* 3 5)) is 17 as compared to (2 + 3 * 5) which is a error

more about scheme is mentioned in the Languages of suffering.

in paticular, It's reference to the book Structure and Interpetation of Computer Programs (SICP) is great if your a “engeneering type” (of which you probably are if you've read this far through a page tilted “hacking log”)

if for some reason your not, you can check out How to Design Programs, which is substantialyl “lighter”.

After your familiar with scheme, the summary “reference version” of the core languaeg is available as the R5RS.

Future paths for the hacking log to go:

The next major advancement for the hacking log, should probably be descriptions for specific utilities on how to make all sorts of postprocessing hacks internal to texmacs.

Things in this could include:

  • pattern matching in guile
  • regular expressions in guile

That's it for this page, but there's always more to see:

Languages of suffering-Released Articles-Upcomming Articles-Scheme code

Copyright 2004 - Corey Sweeney. All rights reserved.

In the future, the licencing may be changing. See my Future Licencing Ideas