[TW5] code and backticks

301 views
Skip to first unread message

ramon

unread,
Oct 27, 2013, 8:32:33 AM10/27/13
to tiddly...@googlegroups.com
Hi,

Random user dropping in with a question.

I read that for code I can either use backticks for in line examples or three back ticks for a code block.

However, what's supposed to happen if the code string contains backticks?

e.g. A="`echo | tr '\012' '\001' `"

At the moment I'm getting bits of this showing as code and bits not, both as an in line example and in a code block.

Is there a way to make it all show as code?

-ramon.

Jeremy Ruston

unread,
Oct 27, 2013, 10:00:02 AM10/27/13
to TiddlyWikiDev
Hi Ramon

The easiest option might be to use the full code block syntax for these situations, rather than the inline syntax, on the basis that your text is less likely to include triple backticks.

The other option is to disable the single back tick parse rule, and then use explicit <code> tags to mark your code runs. For example:

\rules except codeinline
Some text and <code>a code block including `back ticks`</code>

The rules pragma needs to be on the first line of the tiddler.

Does that help?

Best wishes

Jeremy




--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Stephan Hradek

unread,
Oct 27, 2013, 11:42:18 AM10/27/13
to tiddly...@googlegroups.com, jeremy...@gmail.com
Hi Jeremy!

Again a situation where some escaping mechanism seems to be required.

Shouldn't we think about a real general way of escaping and thus making characters literal?

OTOH: For this situation, what about this rule?

` - Standard inline code as you implemented it
``` - Standard block as you implemented it
`` - New inline code, like ` but ending at the next `` So simple ` can be used inside.

Just to drop some unsorted ideas: I pretty much like the Perl way of quoting. In Perl ANY character can be used as a single or double quote like this
qX...X - single quote from X to next X
qqX...X - double quote from X to next X

X could be any character or a set of brackets: (), <>, [], {}.

So qAtestA and q(test) would both quote "test" in single quotes.

Maybe a similar approach could be adopted for TW5?

Jeremy Ruston

unread,
Oct 27, 2013, 1:54:34 PM10/27/13
to Stephan Hradek, TiddlyWikiDev
Hi Stephen

I like the double back tick idea.

That Perl quoting technique might be useful for a typed block syntax. I've also thought of using it in a new .tids file format that allows multiple tiddlers to be defined in a single file.

Best wishes

Jeremy

PMario

unread,
Oct 27, 2013, 2:00:26 PM10/27/13
to tiddly...@googlegroups.com
try:

```

a code block including `back ticks`
```

-m

PMario

unread,
Oct 27, 2013, 2:22:04 PM10/27/13
to tiddly...@googlegroups.com, jeremy...@gmail.com
On Sunday, October 27, 2013 4:42:18 PM UTC+1, Stephan Hradek wrote:
OTOH: For this situation, what about this rule?

` - Standard inline code as you implemented it
``` - Standard block as you implemented it
`` - New inline code, like ` but ending at the next `` So simple ` can be used inside.

+1

-m

ramon

unread,
Oct 28, 2013, 5:45:16 PM10/28/13
to tiddly...@googlegroups.com, jeremy...@gmail.com
Even if I use the code block ticks, it still drops in and out of code, which (to me) is not expected behaviour.
(As a user it looks like TW5 is trying to match ` ` before it matches ``` ```)

The <code> <\code> idea works, though - just somewhat less convenient.

Forgot to say that I've a 5 alpha 10

Stephan Hradek

unread,
Oct 28, 2013, 5:58:44 PM10/28/13
to tiddly...@googlegroups.com, jeremy...@gmail.com
Could it be you stumbled upon this behaviour? https://groups.google.com/forum/#!topic/tiddlywiki/iAz34faoSeI

Jeremy Ruston

unread,
Oct 29, 2013, 4:37:33 AM10/29/13
to ramon, TiddlyWikiDev
Hi Ramon

Can you give an example that shows different results than you expect?

Many thanks,

Jeremy

Ramon Andiñach

unread,
Oct 29, 2013, 6:50:13 AM10/29/13
to TiddlyWikiDev
Ah.

Examples below, but after staring at Stephen's email, the link and your wiki text notes (http://five.tiddlywiki.com/static/WikiText.html) I can see where I went wrong with the code blocks. For some reason I'd latched onto code is pink and was expecting it that way in the code block too, even though the example clearly isn't. I also seem to be guilty of visually editing out white space (see request below).


Examples in attached image. 
If the image comes through, then;
 the first one is with no mark up,
 the second one is with back ticks,
 the third one is with code blocks in a new paragraph but not on a new line,
 and the forth one is correct usage of code blocks - on their own on a new line - which unsurprisingly works.

So, the code blocks are fine. Apologies for noise on that.

Could I make a request, since I'm clearly not the only one that's misread the notes about code blocks?
On the WikiText.html page could it be stated (not just shown) that they need to be in a new paragraph and on their own line?

Thanks everyone for their help.

-ramon.


On 29/10/2013, at 16:37 , Jeremy Ruston wrote:

Hi Ramon

Can you give an example that shows different results than you expect?

Many thanks,

Jeremy

On 29/10/2013, at 05:58 , Stephan Hradek wrote:

Could it be you stumbled upon this behaviour? https://groups.google.com/forum/#!topic/tiddlywiki/iAz34faoSeI

-- 

Jeremy Ruston

unread,
Oct 29, 2013, 9:15:20 AM10/29/13
to TiddlyWikiDev
Hi Ramon

The images came through, and yes, the problem was not having the triple backticks on a line by themselves immediately followed by newline.

I've updated the docs but you won't see the change come through for a couple of days.

Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
backtickCode.tiff
Reply all
Reply to author
Forward
0 new messages