jump to navigation

Testing code layout May 18, 2009

Posted by mwidlake in Blogging.
Tags:
4 comments

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? :-)

Follow

Get every new post delivered to your Inbox.

Join 166 other followers