I have a tiddler and its text field is for example:
[[foo 1 - *]]
* bar
//baz//
{{something}}
each line is wikitext markup.
If I save the tiddler with default content type, each line is rendered accordingly in view mode.
If I save the tiddler as plain text, it is displayed in view mode as it is typed.
What if I wanted my tiddler to get rendered selectively? For example if I wanted to see it as it is typed (plain text), but [[something inside]] parts to get rendered as links to other tiddlers (not necessarily existing ones)? Is it possible? Is it possible without having to write JavaScript? Does the process involve creating a custom content type?
Thatâs a long list and many names there are intuitive. But are they documented? I searched for âprettylinkâ on tiddlywiki.com and got zero results.
Also, I would like to keep the text field of such special tiddler(s) intact. Is it possible to apply this pragma implicitly somehow? Like do it for all tidlers that have a certain tag?
If I understand you correctly you donât want any wiki text rendering except the wiki links inside [[title]]. Perhaps if you step back and tell us why? because it is an unusual request and there may be a another solution if we understood the root cause/need.
My use case is that Iâm investigating storing chess games in PGN format in tiddlers. They also have FEN strings enclosed in [[ ... ]] and I want them to be clickable links to tiddlers, so I could annotate positions identified by those FEN strings, outside of the games, in their own per-position tiddler. The problem is that if I store the PGN game in a tiddler with default content type, TiddlyWiki tries to render parts of PGN as wikitext and it looks ugly. If I save the tiddlers as plain text, FEN strings are not rendering as links.
Not in a user-facing way, to my knowledge. You can use Advanced Search > Shadows to find the relevant JS tiddlers, which typically include some documentation on their use. For instance, searching for prettylink brought me to $:/core/modules/parsers/wikiparser/rules/prettylink.js, which includes the following description:
Wiki text inline rule for pretty links. For example:
[[Introduction]]
[[Link description|TiddlerTitle]]
Hmm, Iâm not sure. Normally Iâd suggest using a custom ViewTemplate, but that gets tricky when, by definition and design, youâre disabling all wikitext parsing other than linksâŚ
If you can list the specific strings that get parsed as wikitext, it may be easier to construct a ViewTemplate that parses all wikitext except those strings, rather than only prettylinks.
So it sounds like itâs really only the transclusions as in {{missing title}} that youâd like to see handled differently. Transclusions are not designed to offer links, at least by default â or even to be recognizable as transclusions in view mode. Theyâll just be empty unless thereâs content there, and will render any existing content (at that tiddler) seamlessly.
Itâs easy enough to build a variation on transclusion that adds a clickable link. Iâm not sure how easy it is to make it work with the shortcut syntax {{title}} though⌠(My understanding is that transclusions play a big role throughout TiddlyWikiâs core, and you might be surprised how an intervention that changes how all transclusions function could pretty quickly trip up the âjust worksâ stuff that youâd otherwise take for granted.)
Edit to add: The best variant on transclusion â for making sure you see links, including links to missing tiddlers â is translink. It can be tweaked in various ways if needed.
Iâm not sure if this is the sort of thing youâre looking for, but we could update the body cascade with a new tiddler that does some simple parsing:
This should do pretty well what youâre asking for. But I personally would go a little further and also parse PNG headers, annotations, and variants. This is a version that does so. You should be able to download the following and drag it onto any wiki:
It is naive and does not handle nested variants â which is a real weakness, because they are fairly common. It uses simple regex-parsing, and therefore cannot handle the full context-free grammar that variants require (arbitrary nesting.) But itâs useful enough for many cases, and it probably wouldnât be too hard to build a more complete parser.
Hereâs one (post this into a body of a new tiddler straight on tiddlywiki.com and save the tiddler; notice that in view mode not all FEN links are rendered)
[Event "?"]
[Site "Riga"]
[Date "1896.??.??"]
[Round "?"]
[White "Nimzowitsch"]
[Black "N.N."]
[Result "1-0"]
[TimeControl "120"]
1. e4 { [[rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1]] }
1... d5 { [[rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2]]
} 2. exd5 { [[rnbqkbnr/ppp1pppp/8/3P4/8/8/PPPP1PPP/RNBQKBNR b KQkq - 0 2]]
} 2... Qxd5 { [[rnb1kbnr/ppp1pppp/8/3q4/8/8/PPPP1PPP/RNBQKBNR w KQkq - 0
3]] } 3. Nc3 { [[rnb1kbnr/ppp1pppp/8/3q4/8/2N5/PPPP1PPP/R1BQKBNR b KQkq - 1
3]] } 3... Qd8 { [[rnbqkbnr/ppp1pppp/8/8/8/2N5/PPPP1PPP/R1BQKBNR w KQkq - 2
4]] } 4. Nf3 { [[rnbqkbnr/ppp1pppp/8/8/8/2N2N2/PPPP1PPP/R1BQKB1R b KQk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1Q3RK1 w
- - 0 18]] } 18. Rxf8# {
[[r1bk1Rnr/p1p1p1p1/4P3/2p3p1/2B5/3Pp3/P1P3PP/1Q4K1 b - - 0 18]] } 1-0
@etardiff if I add \rules only prettylink at the top of this, as you suggested, I still donât see all FEN links rendered.
PS: this is the answer to an early post in this thread, Iâm digesting the help Iâm getting much slower than Iâd like to, my feedback will come with delays.
This is not an option, because this way FEN strings are logically detached from the moves that produce the board positions said FEN strings are describing.
Okay, looking at your data, I donât think the issue is that other wikitext is getting parsed â itâs that the âbrokenâ links contains internal linebreaks, and this seems to prevent them from being parsed as wikitext links.
I assume youâre copy-pasting text from another source, linebreaks included⌠are they important to the content as youâd want to see it? If not, the easiest solution might be to just convert the linebreaks to standard spaces when youâre creating the tiddler. For instance:
(Here, I used \rules except wikilink to prevent âTimeControlâ from being parsed as a link; if youâve turned CamelCase links off in your wiki, you could omit this step.)
If this looks like a workable result, hereâs a custom editor button I made for just this purpose some time ago: linebreak remover.json (1.5 KB)
Simply highlight a chunk of text and press the button to convert any linebreaks in the highlighted text to single spaces.
I also learned how to tune the output of pgn-extract[1] so it puts each halfmove on a new line, which shall prevent FEN splits over multiple lines, so when the PGN source will be from there, additional processing of data should not be needed.