473,466 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Formatting code/scripts/configuration files rendered on a website

Hi,

Since I was so pleased to discover how to enable my keyboard to type
symbols like … directly, I made a howto-page about it:
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml.

I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag, but I
am not satisfied with it, since tabs are not preserved (see bottom
part). This is not essential here, but would be nice. Can I do that
with an addition to the CSS given on the link above? (I removed #
margin: 1px 0; since I don’t like it.)

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #1
14 1425
Hendrik Maryns schreef:
Hi,

Since I was so pleased to discover how to enable my keyboard to type
symbols like … directly, I made a howto-page about it:
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml.

I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag, but I
am not satisfied with it, since tabs are not preserved (see bottom
part). This is not essential here, but would be nice. Can I do that
with an addition to the CSS given on the link above? (I removed #
margin: 1px 0; since I don’t like it.)
Ok, found it already, simply add

white-space: pre;

to ol.code-unnumbered li (note: *not* to ol.code-unnumbered).

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #2
Scripsit Hendrik Maryns:
I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
Why? Their page looks reasonable (at least when viewed text-only, the
usual bogosity check), and they have a superficially good argument
(<precarries no meaning), but what _is_ this xhtml.com? The only
information I found easily is an obfuscated E-mail address:
"For comments about xhtml.com, please contact: feedback [at] xhtml.com"

This gives an initial expectation of credibility around -100.

The argument isn't really that good. What do you use instead? If you
have data where whitespace really matters, like Python code, then why
would you _rely_ on CSS as regards to getting this important _content_
information delivered?

The usual CSS Caveats imply that <pre>, rather than any CSS constructs,
are the right way to go if the data _is_ really preformatted plain text
and preserving that is essential.
but I am not satisfied with it, since tabs are not preserved
By HTML specifications, tab stops should appear in a certain way _and_
authors should not rely on this. Use the safe way: spaces.

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

Jun 27 '08 #3
Jukka K. Korpela wrote:
Scripsit Hendrik Maryns:
>I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,

Why? Their page looks reasonable (at least when viewed text-only, the
usual bogosity check), and they have a superficially good argument
(<precarries no meaning), but what _is_ this xhtml.com? The only
information I found easily is an obfuscated E-mail address:
"For comments about xhtml.com, please contact: feedback [at] xhtml.com"

This gives an initial expectation of credibility around -100.
There are no limits to the irrelevance of the factors on which you base
your credibility assessments, are there? Their credibility on the value
of the PRE tag can be judged by your personal feelings about munged
e-mail addresses? That's like saying that the initial expectation of
credibility of the remainder of your response (which is a great
treatment) is -100% because of your bogus invocation of their approach
to contact information.
Jun 27 '08 #4
Scripsit Harlan Messinger:
Their credibility on
the value of the PRE tag can be judged by your personal feelings
about munged e-mail addresses?
No, their _general_ credibility gets a low initial score due to the
_fact_ that they don't even tell who they are (and don't even tell their
names and real e-mail address).
That's like saying that the initial
expectation of credibility of the remainder of your response (which
is a great treatment) is -100% because of your bogus invocation of
their approach to contact information.
That's like your usual babbling about irrelevant things. I think you
could do better. You might have, for example, made a _single_ reasonable
or reasonable-looking comment on the on-topic issue whether <preshould
really be avoided in favor of CSS (or even on the remotely-on-topic
issue whether xhtml.com should be relied on).

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

Jun 27 '08 #5
Jukka K. Korpela wrote:
Scripsit Harlan Messinger:
>Their credibility on
the value of the PRE tag can be judged by your personal feelings
about munged e-mail addresses?

No, their _general_ credibility gets a low initial score due to the
_fact_ that they don't even tell who they are (and don't even tell their
names and real e-mail address).
?? Most products you buy in the store carry neither the name of the
owner or CEO of either the manufacturer or the store. Why does a website
have to carry the name of its owner?
>
>That's like saying that the initial
expectation of credibility of the remainder of your response (which
is a great treatment) is -100% because of your bogus invocation of
their approach to contact information.

That's like your usual babbling about irrelevant things.
Gee, responding when I call you on your appeal to irrelevant factors by
pretending it's irrelevant. Did you think of that all by yourself?
I think you
could do better. You might have, for example, made a _single_ reasonable
or reasonable-looking comment on the on-topic issue whether <preshould
really be avoided in favor of CSS (or even on the remotely-on-topic
issue whether xhtml.com should be relied on).
Nice job of hand-waving.
Jun 27 '08 #6
Wed, 18 Jun 2008 14:44:14 +0200, /Hendrik Maryns/:
I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,
If the only reason not use <preis it "has no semantic meaning" you
could give it meaning, like:

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

At least I use the above often and there's a <blockcode[1] element
in the XHTML 2 draft which I mimic using that markup. Depending on
the content you could use also:

<pre><samp>...</samp></pre>

I guess one could come up with more examples. I tend to think of
<preas paragraph or generic block (<div>), interchangeably, which
has some predefined styling.

[1]
http://www.w3.org/TR/xhtml2/mod-stru...ural_blockcode

--
Stanimir
Jun 27 '08 #7
On 18 Jun, 20:19, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
No, their _general_ credibility gets a low initial score due to the
_fact_ that they don't even tell who they are (and don't even tell their
names and real e-mail address).
The problem with that logic is that it describes Richard Bullis as
credible,
because his self-evident stupidity is such a strong authentication of
his identity.
Jun 27 '08 #8
Jukka K. Korpela schreef:
Scripsit Hendrik Maryns:
>I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,

Why? Their page looks reasonable (at least when viewed text-only, the
usual bogosity check), and they have a superficially good argument
(<precarries no meaning), but what _is_ this xhtml.com? The only
information I found easily is an obfuscated E-mail address:
"For comments about xhtml.com, please contact: feedback [at] xhtml.com"

This gives an initial expectation of credibility around -100.
Notwithstanding your objections, I found the site very helpful,
containing nice suggestions to format <codeand <kbd>.
The argument isn't really that good. What do you use instead? If you
have data where whitespace really matters, like Python code, then why
would you _rely_ on CSS as regards to getting this important _content_
information delivered?

The usual CSS Caveats imply that <pre>, rather than any CSS constructs,
are the right way to go if the data _is_ really preformatted plain text
and preserving that is essential.
>but I am not satisfied with it, since tabs are not preserved

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? I do not want to use spaces there since
that’s not what I use in the original file as well. Tabs are meant for
aligning, right, well, that’s just what I want to happen there.

I could wrap the whole thing in a table, right, but that would make it
more work than it’s worth.

Cheers, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #9
Stanimir Stamenkov schreef:
Wed, 18 Jun 2008 14:44:14 +0200, /Hendrik Maryns/:
>I tried to follow the advice from
http://xhtml.com/en/xhtml/reference/pre/ to not use the <pretag,

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

<pre><code>...</code></pre>
Hm, but what with the example from the site I gave? It is not really
code, but rather some configuration information in a file.
<pre><samp>...</samp></pre>
This seems more appropriate, but maybe just <preseems the right way to
go, really, as Jukka suggested.

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #10
Scripsit Stanimir Stamenkov:
If the only reason not use <preis 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, <preis 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 <preis the correct markup.

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

Jun 27 '08 #11
Scripsit Hendrik Maryns:
>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.
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.
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
<divmarkup 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/

Jun 27 '08 #12
Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
Scripsit Stanimir Stamenkov:
>If the only reason not use <preis 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, <preis 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 <preis the correct markup.
So combining "the <premeaning is a block where whitespace matters"
further marking the content as <codeseems good way to go, or I'm
missing something?

--
Stanimir
Jun 27 '08 #13
Scripsit Stanimir Stamenkov:
So combining "the <premeaning is a block where whitespace matters"
further marking the content as <codeseems good way to go, or I'm
missing something?
I think that's the best way for computer code where whitespace matters.

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

For example, if you have both blocks of code and some fragments of code
in paragraphs, using <codefor 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/

Jun 27 '08 #14
On 2008-06-19, Stanimir Stamenkov wrote:
Thu, 19 Jun 2008 20:00:52 +0300, /Jukka K. Korpela/:
>Scripsit Stanimir Stamenkov:
>>If the only reason not use <preis 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, <preis 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 <preis the correct markup.

So combining "the <premeaning is a block where whitespace matters"
further marking the content as <codeseems 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)
Jun 27 '08 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bruce W...1 | last post by:
I've been learning about PHP for a couple of weeks. With includes, PHP scripts, and HTML I can see where a large and complex website could easily turn in to a big hairy mess with files all over...
9
by: Jeff Wagner | last post by:
I have a project of converting numerous DOS cmd shell scripts to Python. Is there a tutorial to getting started? Thanks, Jeff
3
by: Sravani | last post by:
Hi, I am setting up a new server for an already running website. The problem is the person before me ran ASP scripts on .html extension pages (The old machine is a windows 2000 server with IIS...
1
by: Ryan Ternier | last post by:
While working on .NET I've had this error pop up on every Solution. Usually I'll just re-build the project and it works, but now it has started doing this to components we've purchased. I can't...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
5
by: NoNickname | last post by:
Basically, how do I know that the release versions of all components are being published? The Build | Configuration Manager is confusing me a little in VS2005. I have three projects in my...
0
by: tanske | last post by:
Hi, Here's the error I received after browsing the ASMX file from IIS. Server Error in '/ABC' Application. --------------------------------------------------------------------------------...
8
by: Alan Isaac | last post by:
Suppose I have a directory `scripts`. I'd like the scripts to have access to a package that is not "installed", i.e., it is not on sys.path. On this list, various people have described a variety...
10
by: sara | last post by:
Hi - I have a report that is 14 columnar sub-reports (Line up: Position- holders in each of our 14 locations - Manager, Assistant Manager, Receiving, Office, etc). I output directly to PDF...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.