hi.
i made a command which converts textile-code to html (duh!). and back (yeah!). well not really. what it does is embedding the textile-content within a html-comment and on revert it ditches all the html and just returns the comment.
i made this command because i think textile is a really fast way of producing formated content (i know you're there, markdown-fans!). but the problem is, the files don't stay editable. with textile, that is. so now i can save an html-file with embedded textile and it is ready for presentation and i can come back at any time and edit the same file without having to keep a copy of the textile-file.
i'm a bad coder. i didn't manage to use the entire document rather than the saved file as input. perhaps s/o else can help.
here's the code:
------------------------------------------------------------- if [[ `head -1 $TM_FILENAME` == '<?xml version="1.0" encoding="utf-8"?
' ]]
then TEXTILEBEGINSAT=`grep "begin textile code" -n $TM_FILEPATH |\ awk -F ":" '{print $1}' ` DOCUMENTHASLINES=`wc -l $TM_FILEPATH | awk '{print $1}'` LINES=`calc $DOCUMENTHASLINES - $TEXTILEBEGINSAT` cat $TM_FILEPATH |\ tail -$LINES |\ grep -v "end textile code-->" | grep -v "</body></html>" else if [[ -z $TM_FILENAME ]] then title="Textile Preview" else title="${TM_FILENAME%.*}" fi { . "$TM_SUPPORT_PATH/lib/html.sh" htmlHeader "$title" '<style type="text/css"> body { background-color: #eee; } .contents { background: white; font-family: Verdena, sans-serif; font-size: 13px; border: 1px #888 solid; padding: 0 1em; } </style>' beginTag div 'contents' cat $TM_FILEPATH | "$TM_SUPPORT_PATH/bin/Textile.rb" endTag
echo "<!-- begin textile code:" cat $TM_FILEPATH echo echo "end textile code-->"
htmlFooter; } fi --------------------------------------------------------
the command uses "input: none" and "output: replace document" and "scope selector: text.html.textile".
it would also be nice, if the command could change the scope to html and back to textile. is this possible?
regards, niko.