'inline code tag' (just using courier font or something)

We know you have an opinion on how things should be run around here. These are suggestions for the forums, and the website.This forum is not a place to ask for suggestions to your own coding (or otherwise) problems.

Moderator: General Moderators

Post Reply
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

'inline code tag' (just using courier font or something)

Post by Apollo »

Instead of using [code] or [syntax=somelanguage] to include a block of code, it can be very convenient to just include a small piece of code (a single statement or something) 'inline', i.e. in the middle of your text.

No fancy markup required, to distinguish code from regular text it'd be enough if we could just use a courier new font or something. So you can include something Image within a sentence.

(done with an image here to show what I mean, you get the idea)
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: 'inline code tag' (just using courier font or something)

Post by twinedev »

I agree, i end up just using bold to make it stand out, but displaying it as a fixed font would be nicer (especially when it comes to a bit that has a double and a single quote next to each other.)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: 'inline code tag' (just using courier font or something)

Post by pickle »

This should be relatively simple to do with a [c][/c] shortcode.

[Edit] [c] has been added. It wraps the text in <code> tags
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: 'inline code tag' (just using courier font or something)

Post by twinedev »

So this will be a code (testing it on the quick reply area)...[c]$bNiceJob = ($this->works && $im->happy);[/c]

Sweet thanks.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: 'inline code tag' (just using courier font or something)

Post by social_experiment »

What a coincidence, just a few minutes ago i made a post and wondered if the c behind Font colour was there because the page didn't finish loading but now i know :) I agree about its use, sometimes a block of code is just too heavy for a single line within a reply.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: 'inline code tag' (just using courier font or something)

Post by pickle »

I've updated the tag to [inline] as it was getting mixed up with the syntax highlighting plugin. It appears to still be broken if you surround a function name, or more specifically "()" in the tags - so let's consider this a "beta" feature for know.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: 'inline code tag' (just using courier font or something)

Post by Apollo »

Thanks, although it seems to mess up with pretty much any non-alphabetic character between the tags (e.g. this works vs [inline]this doesn't[/inline] because of the single quote). Perhaps some bbcode regexp is a bit too restricted currently? Same happens with : ; " # $ etc, so that makes it kinda useless for any actual code.

I noticed currently the &#91;inline] tag evaluates to <code class="inline">, maybe it could just use <span class="inline"> for the time being, and later on back to <code> once it doesnt interfere with the syntax highlighting anymore? (I'd rather have non-syntax-highlighted inline code than not-working-at-all :)).

One more request: maybe to make the code stand out a bit more, make the background a bit brighter? Currently, the background color appears to be alternating #e1ebf2 and #ecf3f7, perhaps make the .inline css have background-color:#ffffff for example? (or .inlinecode if .inline is also used for other stuff)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: 'inline code tag' (just using courier font or something)

Post by pickle »

I've done no CSS modification for this, so there is certainly room for improvement. Maybe we'll have to find a plugin to do this, or modify the syntax plugin to allow for inline code, as evidently the quick-n-dirty BBCode solution isn't working as we wanted.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply