Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-09 20:44:16

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Entering code examples

I hope this type of question is appropriate here.

I had a time entering some code examples in a reply I just made. Is there some trick to entering code snippets? It seems to me that the parser in this forum behaves very differently from a normal PunBB forum.

I made a reply on this forum and made a similar test reply at PunBB.

On this forum, what I cut and pasted had problems rendering line breaks using the code tag, if I added pre, it stripped away anything between ‘<’ and ‘>’ from the sample code. I had to physically remove any extra characters from the beginning and end of the pasted code lines. In the PunBB forum, it rendered just fine wrapped with bbcode.

Also notice the last line of ‘Hope that helps’, no matter how many blank lines I put between that line and the code, it still displayed it bumped up to the code.

Thanks.

Last edited by hcgtv (2006-03-09 20:45:11)

Offline

#2 2006-03-09 21:49:07

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Entering code examples

You have to start the the blocks with a p. to force it to create a new paragraph.

Pre and Code definitely don’t seem to play well together though

as an example, without pre

<code>
<strong> some text</strong>
<em> second line </em>
</code>

Code block wrapped in pre

<pre>
<code>
<strong> some text</strong>
<em> second line </em>
</code>
</pre>

nesting code inside pre seems to cancel out code.

Last edited by hakjoon (2006-03-09 21:50:16)


Shoving is the answer – pusher robot

Offline

#3 2006-03-09 22:34:55

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Entering code examples

It’s adding the extra line breaks that creates the problem. This is how I do it (use Quote to see how):

First some text.
<code>
<here your code>
<some more code>
</code>
Hope that helps.

Offline

#4 2006-03-09 23:06:00

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Entering code examples

Cool, Els!

Didnt know that trick!!!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2006-03-09 23:46:08

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Entering code examples

Thanks for the examples, that helps me out in understanding how the forum parses code blocks.

Experience does seem to pay off,
<code>
<docs>http://backend.userland.com/rss</docs>
<image>
<url><%blogsetting(url)%>nucleus/nucleus2.gif</url>
<title><%blogsetting(name)%></title>
<link><%blogsetting(url)%></link>
</image>
</code>
around here ;)

Offline

#6 2006-03-10 06:16:14

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Entering code examples

This forum is using a different version of Textile, which contains bc (block code) syntax

<docs>http://backend.userland.com/rss</docs>

<image>
    <url><%blogsetting(url)%>nucleus/nucleus2.gif</url>
    <title><%blogsetting(name)%></title>
    <link><%blogsetting(url)%></link>
</image>

(Hit “quote” to see what I did.)

Offline

#7 2006-03-10 08:29:34

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Entering code examples

Mary,

So it’s bc with two periods after it, then a p with a period to end it and start a new paragraph.

Very interesting, like a foreign language of sorts, I’ll get the hang of it.

Thanks.

Offline

Board footer

Powered by FluxBB