HighDots Forums  

Formatting code/scripts/configuration files rendered on a website

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Formatting code/scripts/configuration files rendered on a website in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Formatting code/scripts/configuration files rendered on a website - 06-19-2008 , 01:00 PM






Scripsit Stanimir Stamenkov:

Quote:
If the only reason not use <pre> is it "has no semantic meaning" you
could give it meaning, like:

pre><code>...</code></pre
That does not give any meaning to <pre>. Using semantic markup inside
non-semantic markup does not make the outer markup any more markup. Au
contraire, it empasizes its semantic emptyness.

Yet, <pre> is the only way in HTML to specify that whitespace is
significant, so if your data has "a b" that shall be intepreted as
different from "a b" in meaning, then <pre> is the correct markup.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #12  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Formatting code/scripts/configuration files rendered on a website - 06-19-2008 , 01:07 PM






Scripsit Hendrik Maryns:

Quote:
By HTML specifications, tab stops should appear in a certain way
_and_ authors should not rely on this. Use the safe way: spaces.

Can you explain this further?
Quoting the HTML 4.01 spec (which echoes HTML 2, though with some
obscurity):

"The horizontal tab character [...] is usually interpreted by visual
user agents as the smallest non-zero number of spaces necessary to line
characters up along tab stops that are every 8 characters. We strongly
discourage using horizontal tabs in preformatted text since it is common
practice, when editing, to set the tab-spacing to other values, leading
to misaligned documents."

http://www.w3.org/TR/html4/struct/text.html#h-9.3.4

Well, it doesn't explain much. But tab stop settings may depend on the
environment, so the tab character does not work reliably.

Quote:
I do not want to use spaces there since
that’s not what I use in the original file as well.
Yet, it's the effect that matters, and spaces are the safe way to
achieve that.

I've used the M-x untabify function in Emacs, the text editor, when I
have needed to convert text with tabs to text without them.

Quote:
I could wrap the whole thing in a table, right, but that would make it
more work than it’s worth.
I agree that it's not very practical, and neither is the idea of using
<div> markup with classes and styling - though this would be the way to
achieve indentation that is easily modified just by changing one CSS
rule.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #13  
Old   
Stanimir Stamenkov
 
Posts: n/a

Default Re: Formatting code/scripts/configuration files rendered on a website - 06-19-2008 , 05:17 PM



Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
Quote:
Scripsit Stanimir Stamenkov:

If the only reason not use <pre> is it "has no semantic meaning" you
could give it meaning, like:

pre><code>...</code></pre

That does not give any meaning to <pre>. Using semantic markup inside
non-semantic markup does not make the outer markup any more markup. Au
contraire, it empasizes its semantic emptyness.

Yet, <pre> is the only way in HTML to specify that whitespace is
significant, so if your data has "a b" that shall be intepreted as
different from "a b" in meaning, then <pre> is the correct markup.
So combining "the <pre> meaning is a block where whitespace matters"
further marking the content as <code> seems good way to go, or I'm
missing something?

--
Stanimir


Reply With Quote
  #14  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Formatting code/scripts/configuration files rendered on a website - 06-20-2008 , 08:28 AM



Scripsit Stanimir Stamenkov:

Quote:
So combining "the <pre> meaning is a block where whitespace matters"
further marking the content as <code> seems good way to go, or I'm
missing something?
I think that's the best way for computer code where whitespace matters.

Using <code> is not pragmatically very important, since <pre> markup
already sets the font to monospace, but <code> carries semantic
information, could be used for styling, and it is observed by some
automatic translation software (so that they treat <code> contents as
literal, to be preserved as such).

For example, if you have both blocks of code and some fragments of code
in paragraphs, using <code> for all code is a good idea, for uniform
styling. (Or for non-uniform in a controlled manner, via classes, since
you might wish to make a visual distinction e.g. between source program
code and operating system commands.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
  #15  
Old   
Chris F.A. Johnson
 
Posts: n/a

Default Re: Formatting code/scripts/configuration files rendered on a website - 06-20-2008 , 10:31 PM



On 2008-06-19, Stanimir Stamenkov wrote:
Quote:
Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
Scripsit Stanimir Stamenkov:

If the only reason not use <pre> is it "has no semantic meaning" you
could give it meaning, like:

pre><code>...</code></pre

That does not give any meaning to <pre>. Using semantic markup inside
non-semantic markup does not make the outer markup any more markup. Au
contraire, it empasizes its semantic emptyness.

Yet, <pre> is the only way in HTML to specify that whitespace is
significant, so if your data has "a b" that shall be intepreted as
different from "a b" in meaning, then <pre> is the correct markup.

So combining "the <pre> meaning is a block where whitespace matters"
further marking the content as <code> seems good way to go, or I'm
missing something?
Rather than two nested elements, I'd use a class:

<pre class="code">

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.