All of geshis' output are block elements and since it takes over the <code> tag which is an inline element it doesn't behave as expected.

The code module used here on drupal is smart enough to know that inline code tags stayed that way. It was only when it contained a line break after <code> did it see it as a block.

Everything else works great. Thanks for picking it up. It's the closest version to being usable.

Comments

dvessel’s picture

Just looked over geshi's documentation. It looks like a limitation of geshi for now.

http://qbnz.com/highlighter/geshi-doc.html#the-code-container

Could you give the option to disable geshi for inline <code> for the time being.?

dvessel’s picture

Category: task » feature

Updating the category since it's a feature request. No rush or anything but please make it happen. It's that's needed to get proper code to display.

pitpit’s picture

GeSHiFilter replace the whole <code> element by the GeSHi highlighted block arounded by the container (pre or div). Basically GeShi doesn't make possible to wrap the code in <code> tags.

I'm not sure to understand your request but are you suggesting GeSHIFilter should keep the <code> element away from the geshi parser when it contains no line break after and should display the element like that (ie without highlight and as an inline code element)?

dvessel’s picture

Yes, that's exactly it. Please excuse the bad grammar.

...keep the <code> element away from the geshi parser when it contains no line break...

This way at least the <code> tag still functions as it was designed. Hopefully Nijel will work on this so geshi knows the difference. I could contacting him on this. He stated it might become an option in future versions.

Codefilter does exactly this right now. Maybe look at their code? Thanks!

pitpit’s picture

we could use another tag than <code> to lets inline code elements still function as there were designed.

dvessel’s picture

Why do you think it should be another tag? In my limited view, keeping <code> intact makes more sense. There are other input filter like textile or markdown for example that use a shorthand for <code> and other various tags. So, if what's entered is standard it's more likely to cooperate in more situations.

pitpit’s picture

Assigned: Unassigned » pitpit

ok
I just had a look on how codefilter deals with inline <code> tags and your request is more clear to me now. I agree with you that this feature is needed in GeSHiFilter.

I'll provide a patch asap. keep in touch.

Dpdev

dvessel’s picture

Excellent! Hope to try it out soon. I shot off an email to Nijel. It's not critical that Geshi supports inline code highlighting although it would be nice. It makes more sense for big blocks of code.

dvessel’s picture

I'm a little late with this but maybe consider using blockcode for geshi instead. It is xhtml2 and won't interfere with code.

http://www.w3.org/TR/xhtml2/mod-structural.html#sec_8.2.

nigel’s picture

Hi guys :)

What you could do instead of using

 or 
is set the header type to GESHI_HEADER_NONE, and manually add the ... tags after highlighting. That way there won't be any
 or 
in the output. Give that a go and see how it works :)
nigel’s picture

grr, there's me forgetting that HTML tags are actually HTML here :(

What I meant to say was...:

What you could do instead of using <div> or <pre> is set the header type to GESHI_HEADER_NONE, and manually add the ... tags after highlighting. That way there won't be any <div> or <pre> in the output.

Give that a go and see how it works :)

dvessel’s picture

Well, duh.. I read you the wrong way.

we could use another tag than

 to lets inline code elements still function as there were designed.
</blockquote>

So, yeah. let geshi take over a different tag like blockcode instead. I'm sorry, I can be an idiot. :)

Another thing is that when we have '<' inside <code><code>

tags it won't be escaped. :( Hopefully Nijels' suggestion takes care of that.

dvessel’s picture

bah! let me repeat that..

Well, duh.. I read you the wrong way.

we could use another tag than <code> to lets inline code elements still function as there were designed.

So, yeah. let geshi take over a different tag like blockcode instead if it makes sense. I'm sorry, I can be an idiot. :)

Another thing is that when we have < inside <code> tags it won't be escaped. :( Hopefully Nijels' suggestion takes care of that.

pitpit’s picture

I committed a new release of geshifilter on cvs.

Now code is highlighted using <blockcode> tags. Inline code tag (<code>) can be enable in input format settings to allow inline code to be hightlighted.

Does it fit your needs?

dvessel’s picture

That's great! I'll give it a thorough workout. Will post back soon. Thanks! :)

dvessel’s picture

I think you nailed it! Works as expected now. I've been waiting for this and it works beautifully. Inline code character escapes work well too when it's enabled.

Superb job! Really appreciate it. Thanks.

My testing wasn't thorough but I'll be sure to let you if I run into a bug. It will be installed on my main site. :)

pitpit’s picture

Status: Active » Fixed

fixed on cvs

Anonymous’s picture

Status: Fixed » Closed (fixed)