jump to navigation

Testing code layout May 18, 2009

Posted by mwidlake in Blogging.
Tags:
trackback

Well, as a new blogger, I am having the usual issues everyone does – with layout. Specifically, code. Code takes up space and it looks best if it is in a fixed font. I can’t see an option to set the font for specific parts of the text, so I need to use tags I guess. So let us try.

Piet de Visser gave me a couple of hints

First, I shall use the code tag

 test102>select a.result-b.result
  2  from (select max(pers_id)+1 result,1 eric from person) a
  3  ,(select min(pers_id) result,1 eric from person) b
  4  where a.eric=b.eric
  5  /

Hmm, it looks fine in the box I enter my text in, a nice small courier font. But now you are looking at it on the published page, it is in larger text and in a shaded box. The shaded box is nice, the large text is a pain. Code tend to be long, based on 80 characters per line or more.

Let’s try sourcode with language=’sql’ (sourcecode uses square brackets not angle brackets)

  test102>select a.result-b.result
  2  from (select max(pers_id)+1 result,1 eric from person) a
  3  ,(select min(pers_id) result,1 eric from person) b
  4  where a.eric=b.eric
  5  /

Now, that is more like it but the addition of the line numbers is a duplication, I will have to edit all my sql*plus output to get rid of it. Can I just have the layout with the code structure highlighting?…

  test102>select a.result-b.result
  2  from (select max(pers_id)+1 result,1 eric from person) a
  3  ,(select min(pers_id) result,1 eric from person) b
  4  where a.eric=b.eric
  5  /

Whoops, it demands a language, so that it can parse out and highlight the syntax. At least you can see the kind of syntax used though. Check out This note by wordpress on what they suggest. This link here says something about the underlying javascript but I guess wordpress have wrapped this feature as they don’t support javascript (as otherwise some swine would abuse it to damage the site). A shame as I would like to turn off the line numbering. Hmmm, I tried a few things like the below but no luck:

test102>select a.result-b.result
2 from (select max(pers_id)+1 result,1 eric from person) a
3 ,(select min(pers_id) result,1 eric from person) b
4 where a.eric=b.eric
5 /

I’ll see if using the direct syntax works, I expect not…

<pre name=”code” class=”sql”
test102>select a.result-b.result
2 from (select max(pers_id)+1 result,1 eric from person) a
3 ,(select min(pers_id) result,1 eric from person) b
4 where a.eric=b.eric
5 /</code>

No.

So, if I edit my text a little and use the sourcecode language=’sql’ tag…

select a.result-b.result
from (select max(pers_id)+1 result,1 eric from person) a
     ,(select min(pers_id) result,1 eric from person) b
where a.eric=b.eric
/

Well, it is OK but it does not show it in fixed font in the post but you can click on the option to do so. It is a shame that it is not possible to set the simple (what looks like courier) text to be used in the formatted box via a flag or something.

I could pay for the CSS feature, that would probably make all of this easier.

What can I achieve with changing font size? I Looked here for some instructions.
In the below I try and use font size=n tags…

eric eric eric
eric eric eric
eric eric eric

but it does not work.
How about span? font is, after all, depricated…

eric eric eric

No. No luck. Span is not working for me either. Maybe it is my theme that does not allow it.

OK, enough on that and back to the day job. I now know I can improve the layout but I’d like to be able to do more… I guess I could sell the cat to science and buy the upgrade? :-)

About these ads

Comments»

1. PdV - May 18, 2009

hi again Martin.

In blogger/blogspot, I’ve used the code + small tags to get a better, but still unsatisfactory result. google might help if I search further.

I will most likely resort to storing my files as demo.sql files on some host, and ask ppl to click to them or run them straight from the net:


SQL> @www.myhost.com/demo.sql

That seems to work rather nicely, for those who trust my code... ;-) .
And it forces me to write very clear demos.

Regards,
PdV

2. PdV - May 18, 2009

apologies, using tags in comments really messes things up…

3. mwidlake - May 18, 2009

Haha! Are you trying to mess up my blog then Piet :-)

I need to set up somewhere where I can put my scripts on the Web and just reference them, I thought wordpress would have an area for that but I have not found it as yet.

4. John Hallas - April 12, 2010

Interesting post and I have blogged before about the difficulty of posting code in a wordpress blog <a href=http://jhdba.wordpress.com/2009/05/06/how-to-format-a-wordpress-blog-question/ Formatting post


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 170 other followers

%d bloggers like this: