How do I get <code> to show up in an indented, colored

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
davef
Posts: 2
Joined: Wed Jun 06, 2007 12:44 am
Location: Hagerstown, Md

How do I get <code> to show up in an indented, colored

Post by davef »

I looked for themes that will do this, but if there are any, I missed them. I want it to show blocks that I denote with <code>text</code> or something similar to show up in a box that is bordered and colored different from the rest of the text. Bonus if the box can be made to only go so wide, and show a horizontal scroll bar if the text gets too big, rather than rapping it.

Can anyone help me, or point me toward some documentation?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: How do I get <code> to show up in an indented, col

Post by garvinhicking »

Hi!

There are several markup plugins that deal with displaying that:

1. BBCode
2. Textile
3. GeSHI

The first two are bundled with s9y and can be installed through the plugin manager. For BBCode you need to use "[ code ]" tags, for textile I don't know. GeShi also works a bit like that, it has some instructions you can find when searching this forum for geshi.

Geshi can be found via spartacus or on http://spartacus.s9y.org/

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
davef
Posts: 2
Joined: Wed Jun 06, 2007 12:44 am
Location: Hagerstown, Md

Post by davef »

Thank you, that is helping me.
I tried all three, and the BBCode is closest to what I want. I learned the NL2BR needs to go after the BBCode in the list, or maybe you can edit it's properties. Easiest to make sure it's after BBCode in the list.
I got the colors and the box with horizontal scrollbar by editing plugins/serendipity_event_bbcode/serendipity_event_bbcode.php and inserting:

Code: Select all

border: 1px inset;
width: 800px;
overflow: auto;
in the .bb-code, .bb-php section.

Yeay!

Only 2 more things and I'll be all set.

Is there any way to make the title for the code block say anything other than "CODE:"? I tried

Code: Select all

, but that doesn't do it, and I can't even find the word in the bbcode.php file.

Is there any way to get [b] to work in a code segment? If I use <b> it leaves it alone, but in brackets bbcode actually replaces it, but then doesn't display it as bold, it puts a <span> statement in there.  I'm looking at the serendipity_event_bbcode.php, but I don't see where html stuff gets turned off.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
Is there any way to make the title for the code block say anything other than "CODE:"? I tried

Code: Select all

, but that doesn't do it, and I can't even find the word in the bbcode.php file.[/quote]

That's a bit tricky, sadly. The current plugin doesn't allow any custom titling.

The place where "CODE:" is emitted is a bit hidden inside the plugin. It can be found in the 'bbcode_callback' method of the file, at this line:

[code]
      $input = "<div class=\"bb-$type-title\">" . strtoupper($type) . ":</div>"
                . "<div class=\"bb-$type\">$input</div>";
So you'd need to replace the "strtoupper($type)" with the word you actually want to get there. But it will be the same for all bbcodes.

Code: Select all

Is there any way to get [b] to work in a code segment? If I use <b> it leaves it alone, but in brackets bbcode actually replaces it, but then doesn't display it as bold, it puts a <span> statement in there.  I'm looking at the serendipity_event_bbcode.php, but I don't see where html stuff gets turned off.[/quote]

Sadly not. Everything inside a CODE block is meant to be interpreted as code. It's a conceptual problem, because CODE is especially meant to interpret nothing.

You can't do this, I'm afraid. Either you use markup, or you use code, but you can't combine it. How would the plugin decide when to interpret a <b> and when it is code and be emitted as such? :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply