TW5 How to save code? TW5

109 views
Skip to first unread message

Jørn Madsen

unread,
Aug 12, 2015, 11:49:17 AM8/12/15
to TiddlyWiki
Hi

I've been using TW5 for a year now, mostly for notes concerning Network configuration and Python programming.

I haven't been able to find a workaround to save code I can save directly. A simple example:

def factorial(n):
    result = n
    for i in range(1,n):
        result *= i
    return result

When saving the tiddler, the indentation and new lines is often lost,- I've tried the tripple quotes to "freeze" the text without any luck.

Any advise?

B.R.
Jørn 

Andreas Hahn

unread,
Aug 12, 2015, 12:25:37 PM8/12/15
to tiddl...@googlegroups.com
Am 12.08.2015 um 17:49 schrieb Jørn Madsen:

When saving the tiddler, the indentation and new lines is often lost,- I've tried the tripple quotes to "freeze" the text without any luck.

You can always change the type of the tiddler to either "text/plain" or "application/x-python", so that the content isn't run through the wikitext parser.
You can also use the highlight plugin to get nice syntax highlighting as well.

/Andreas

Jørn Madsen

unread,
Aug 12, 2015, 12:50:38 PM8/12/15
to TiddlyWiki
THANKS !! :-)

I've been struggling with this ... reading about plugins and different advanced stuff ...

This was a wonderful perfect simple solution.

Thanks mate :)

Jørn 
 

Greg Davis

unread,
Aug 12, 2015, 1:53:28 PM8/12/15
to TiddlyWiki
As Andreas said, you could change the tiddler type. Though if you are adding descriptions or annotating, your short example seems to work with the back-ticks. Did you try HTML pre or code tags? Test sample attached.
Greg


Ways-to-Code.tid

Jørn Madsen

unread,
Aug 12, 2015, 2:13:24 PM8/12/15
to TiddlyWiki


Den onsdag den 12. august 2015 kl. 17.49.17 UTC+2 skrev Jørn Madsen:
Thanks again

I'm trying and testing, I was stuck,-  you're really been helpfull :)

B.R.
Jørn

 

PMario

unread,
Aug 12, 2015, 3:57:41 PM8/12/15
to TiddlyWiki
Hi Jørn ,

try this

```
def factorial(n):
    result = n
    for i in range(1,n):
        result *= i

Jørn Madsen

unread,
Aug 13, 2015, 7:55:56 AM8/13/15
to TiddlyWiki


Den onsdag den 12. august 2015 kl. 17.49.17 UTC+2 skrev Jørn Madsen:

Hi Mario

Thanks,- I've tried that,- but it did not "freeze" the text.

But now I have imported HighLight and uses the text conversion,- so far this seems to work perfectly.
Also for very large configurations with hundreds of lines :)

Thanks for your answer :)
Jørn
Reply all
Reply to author
Forward
0 new messages