Python script to use HTMLDOC with UTF-8 files

June 27, 2008 by Aurélio

You know, HTMLDOC is a good tool to complement txt2tags features, specially to break an HTML file into multiple pages.

But the current version of HTMLDOC (1.8.x) has no Unicode support.

When you try to use it to convert or split an UTF-8 file, all the special characters (not ASCII) will be incorrect in the resulting HTML.

The Unicode support will be released on the 1.9 version, which is still in beta stage.

If you can’t wait for the stable 1.9 release or are stuck into an old version and just want a quick solution to your messed files, try my Python script:
fix-htmldoc-utf8.py

It restores the original UTF-8 characters that HTMLDOC has messed.

You can use it as a filter (reads STDIN, results to STDOUT):

cat myfile.html | fix-htmldoc-utf8 > myfile-ok.html

You can inform the file and send the results to STDOUT:

fix-htmldoc-utf8 myfile.html > myfile-ok.html

Or you can use the -w option fix the file in place:

fix-htmldoc-utf8 -w myfile.html

Enjoy!

New tool for webmasters: gensite

January 22, 2008 by Aurélio

I know, you have a beautiful website that rocks the neighborhood. The styles are all separated in nice CSS files. The contents are text files that you convert to HTML with txt2tags, of course!

It works just fine.

But everytime you edit some file, you have to remember to convert it to HTML. And maybe you also have to copy this updated file to your web server.

For just a few files you can do it by hand every time. But as the site grows, it’s easy to lose control.

Enter Dave Fancella’s gensite tool. It’s a Python program that detects which files has been modified and automatically converts them with txt2tags. It can also copy the generated HTML files to a new destination. You can use command line options and even create a configuration file to fit your conversion needs.

Go to Dave’s site for detailed information on WHY and HOW. Oh, and yes, his site is txt2tags powered :)

Txt2tags + NanoBlogger

November 11, 2007 by Aurélio

Gabriel Kerneis write me to talk about the NanoBlogger plugin for txt2tags he have written.

If you’re a NanoBlogger addict, don’t miss this plugin so you can use our beloved simple txt2tags markup in your blog posts!

Choose Your Own Adventure (CYOA) with txt2tags

August 11, 2007 by Aurélio

You are in a maze of twisty little passages, all diferent.

If you decide to go left, turn to page 4.
If you decide to go right, turn to page 5.
If you decide to cry, do it ;)

Jokes apart, this the format of the Choose Your Own Adventure books, where the reader can decide the flow (an the end) of the story.

What if you want to make your very own CYOA book?

You could use a PDF file as the book, it has pages. As a bonus, you can also use direct links to the pages on the “turn to page 4″ excerpts, improving the user experience.

Looks cool enough? And what if I say that you can do it all in a single nice flat text file?

Eric Forgeot has written an article teaching how to transform a text file into a full CYOA book, using txt2tags. The article is itself a CYOA, check it out now: txt2CYOA : a “choose your own adventure” easily made with txt2tags.

txt2cyoa castle

I don’t know about you, but I’m amazed to see how creative the txt2tags users are!

User testimonial: Gazeta de Algol

July 11, 2007 by Aurélio

Roberto Bechtlufft wrote me to tell that he moved all his old site about Phantasy Star (remember Sega’s Master System and Mega Drive?) to a PHP plus txt2tags solution.

“It was my first site and it was a mess. Now I’ve migrated everything to PHP and the all the contents are made with txt2tgs. Gee, now it is snappier, thank you, this program is incredible.”

He has documented the process on the site, telling why txt2tags was a great choice. His text is in Portuguese, but you can read the English version translated by Google, which is good enough (for a machine). ;)

New Translation: Manual Page in Chinese

July 11, 2007 by Aurélio

Hey, China! Abby Pan has just translated the Manual Page to your language.

Abby’s work is already online on the documentation page.

Txt2tags Manual Page in Chinese

Txt2tags and gedit

June 19, 2007 by Aurélio

Stefano D’Archino told us about his new creation: the txt2tags language file for gedit.

His instructions follows:

  • Put the file in /usr/share/gtksourceview-1.0/language-spec
  • Adjust the colors for the syntax in Gedit preferences

Zoom.Quiet, a long time txt2tags user, gave us a nice screenshot of his gedit using this file:

txt2tags gedit

FYI: gedit is the official text editor of the GNOME desktop environment. I know you already knew that, but… You know :)

Txt2tags article at Linux Magazine

June 5, 2007 by Aurélio

If the Linux Magazine lands at your country, you’re a lucky guy. Check out the new Issue 80 from July 2007 to find a nice article fully devoted to txt2tags!

Linux Magazine Cover #80

LinuxUser: Workspace: txt2tags – Write once and publish anywhere with this handy document generator.

Note: There isn’t a link for the online version of the article, so I guess only the printed magazine will have it.

The man who made the article is our old time friend Dmitri Popov, who already wrote “Minimalist tools for writers” and created the excellent QuasiWiki (Txt2tags extension for OpenOffice.org).

Thanks again Dmitri!

Guide: Static sites with txt2tags

May 1, 2007 by Aurélio

Demian Neidetcher wrote on the txt2tags site to tell us about a nice guide he has made:

I love what you guys have done. I decided to re-do my site and came across this. I did a write-up on my site that explains the process I used with txt2tags.

Check out his Static Site Creation Guide, featuring detailed tips on how to use txt2tags, m4 and make to create and maintain a full website.

Excerpts:

I have developed websites in Python (CGI and Django), PHP, Perl, .NET, Java (Struts, WebWork, Java Server Faces) and finally Ruby on Rails. However, I don’t always have the need to do a full-blown, database backed website that uses a complicated framework. Sometimes simple HTML will suffice.

Finally I can focus on content without having to resort to a WYSIWYG tool and still get nicely formatted pages.

Enjoy!

Update: Check out David’s Spanish translation for this guide.

TextMate Txt2tags Bundle

March 30, 2007 by Aurélio

If you’re one lucky guy/girl that owns a copy of the excellent TextMate text editor, listen on and prepare the “Hooray!”.

I’m a recently converted TextMate user and as you may wonder, to edit txt2tags files is part of my everyday routine. Websites, articles and books, everything is t2t-marked.

For a few days I’ve used TextMate on the “black & white mode” and that was real unsexy. A decade of Vim hardcore use told me that syntax highlight is a Good Thing.

I’m the Great Cornholio! I need some T.P. for my Bundle!

For my total surprise, the making of the TextMate Txt2tags Bundle was a breeze. It’s damn easy to add the syntax rules and as the regexes format are similar to Python’s, it was a copy & paste dream.

t2tmate Syntax Highlight

Since I was there, I just couldn’t stop.

Besides the colors for the txt2tags markup, we also have:

  • Tab Triggers for all the marks

    Just type the mark’s character and hit Tab. For example, to start a bold sentence, hit “*” followed by a Tab. It will expand to “****“, with the cursor right at the middle, waiting for your words to be inserted. Very handy!

  • Keyboard Shortcuts

    Still on the bold example, you can select your words and press Command-B. They’ll be surrounded by the “**” marks. Quick comment/uncomment a block of lines with Command-/ and move quotation in and out with Command-] and Command-[.

    To type a link, it’s even cooler. First, copy the desired URL to the clipboard (Command-C, you know). Then type Control-Shift-L and the link mark will appear, with the URL already filled. Type the link name and press Tab to leave the mark. Killer!

    You can also select some already-typed text, press Control-Shift-L and see it being linked without any typing. The same works for titles, images and even tables (just Tab-delimit your data and press Control-Shift-|).

    Press Command-Esc at any time to get the key listing:
    t2tmate Keyboard Shortcuts

    Tip: Use keyboard shortcuts for selected text, use tab triggers for to-be-typed text.

  • Tab Triggers for all settings and macros

    Never read the Txt2tags User Guide anymore. Just type the setting name followed by a Tab to have all it’s arguments shown. And what about those funky “%Y %m” for the %%date macro? No problem, type “date” and hit Tab.

  • Drag’n'drop support

    Images, other txt2tags files and HTML files. Just drag them to the editor and watch the magic happening!

  • Ready-to-use template for UNIX man pages

    Load the template, fill your program’s data and there it is: you have a full featured man page. To start, choose File > New From Template > Txt2tags > Manual Page (man).

  • Painless conversion process

    There are several shortcuts to automate the conversion process and see the results. 

    • Under the “Convert to…” menu you can convert your document to any txt2tags-supported format with a single click.
    • Press Control-Option-Command-P (Wow, that hurts to type, but it’s easy to press) to get an instant clear text-only version of your document, just in case the markup is stealing your attention.
    • My favorite: press Control-Command-P to convert the file to HTML and open it in Safari (or your other default browser). It avoids the boring save-convert-switch-reload every time you’re editing your site pages.

Check out the full bundle menu expanded to finally shout your Hooray!:

t2tmate Menu

That’s it! Download and double click to install.