Edit - History - Recent changes

The txt2tags "tips" section is for sharing ideas (pre or postproc for example).

Rework in progress. The previous tips are included in the txt2tags handbook. Feed free to add new tips if you feel so!

Regex (Edit)

You can use (.*?) or (.*) to search and replace parts of your document. (.*) is for searching thought the whole line, while (.*?) will search until the first occurence.

For ex: TODO

Txt2tags on nokia E61 (Edit)

This telephon can only run python 1.4.5

So you can try txt2tags version 2.4, which is the last compatible with Python 1.x. You may try older versions as well.

Without a command line, you can have access to the Python interactive shell anyway.

Rename the txt2tags script to txt2tags.py, so you can import it as a module. There's a handy function exec_command_line() that you can use. It expects to receive the full command line as a list of tokens, except the very first item. Examples:

txt2tags --help  —>  '--help'

txt2tags -t html -i sample.t2t  —>  '-t', 'html', '-i', 'sample.t2t'

To make things easier, you can use split to create the list:

   '-t html -i sample.t2t'.split()

So, just enter in Python shell, import txt2tags and have fun:

>>> import txt2tags
>>> txt2tags.exec_command_line( '-t html -i samples/sample.t2t'.split() )
txt2tags wrote samples/sample.html
>>> 

Addendum:

Nokia E61 uses the S60v3 platform on Symbian 9.1 but if you can manage to get Python and the Python Shell Script on your Symbian phone then this should work on those phones as well.

Python PyS60 1.4.5 is easiest to run on an e61, PyS60 2.0.0 is difficult to load (I could never get it to run). PyS60 1.4.5 is based on Python 2.2--txt2tags v2.5 compatible.

Instructions: Install PyS60 Python 1.4.5 and Python Script Shell 1.4.5 http://www.developer.nokia.com/Community/Wiki/Archived:PyS60_1.4.5_Quick_Start

Download from the web a Python 2.2 version of getopt.py and txt2tags-2.5

Rename the txt2tags script to txt2tags.py, so you can import it as a module. There's a handy function exec_command_line() that you can use.

import sys #will allow you to load your getopt.py script and load txt2tags.py module from somewhere else other than "c:
resource", this folder is off-limits in the e61 and is where the python modules are stored when PyS60 is installed to the phone.

sys.path.append("c:
Python") #please note incorrectly written as "e:
Python" in the list message above as the Python folder is on the c:
drive when installed to the phone

import getopt   #needed to run txt2tags
import txt2tags #now you can run txt2tags commands on *.t2t files

The txt2tags built-in command-line expects to receive the full command line as a list of tokens, except the very first item. Examples:

    txt2tags --help  —>  '--help'

    txt2tags -t html -i sample.t2t  —>  '-t', 'html', '-i', 'sample.t2t'

To make things easier, you can use split to create the list:

    '-t html -i sample.t2t'.split()

So, just enter in Python shell, import txt2tags and have fun:

>>> import txt2tags
>>> txt2tags.exec_command_line( '-t html -i e:
samples/sample.t2t'.split() ) txt2tags wrote samples/sample.html #"e:
" for minisd card on the e61 "c:
" for phone memory >>>

Txt2tags will write the converted file in the same folder as the *.t2t file.

You can get wiki style links for other .t2t files in the same directory using

%!preproc: '\(\w+)\' ' .html'

This way you can write links like this instead of this

Convert from markdown to txt2tags (Edit)

You can use this script:

#!/bin/sh

# This markdown2txt2tags.sh script converts from markdown to the txt2tags format.
# It requires:
#   - Pandoc (to convert from markdown to html) see http://johnmacfarlane.net/pandoc
#   - html2wiki http://search.cpan.org/~diberri/HTML-WikiConverter-0.68/bin/html2wiki
#   - txt2tags export for html2wiki http://wiki.txt2tags.org/index.php/Main/Html2wiki

case $1 in
        "")
        echo -e "Usage: markdown2txt2tags.sh file_in_markdown_format.md"
        ;;
        *)
        echo -e "\n\n\n" > $1.t2t && pandoc -f markdown -t html $1 | html2wiki --dialect Txt2tags |sed -r -e "[email protected]^[email protected]\[email protected]" >> $1.t2t
        ;;
esac

It can be found in the "extra" folder :