Click here to get back home

Displaying code with

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Displaying code with
Eric Lindsay 12-30-2005
Posted by Eric Lindsay on December 30, 2005, 8:55 pm
Please log in for more thread options


I can't figure how to best display little snippets of shell script using
<pre>. I just got around to organising to bulk validate some of my web
pages, and one of the problems occurs with Bash shell pieces like this:

<pre><code>
#!/bin/sh
ftp -i -n ftp.server.com&lt; &lt;EOF
user username password
epsv4
cd /
lcd ~/Documents/web101
put test.htm
quit
EOF
</code></pre>
</p>

If I leave the << to indicate I am using a Here document, then the WDG
validator complains about all sorts of stuff.

If I use adjoining &lt;&lt; with no space, then the first < displays,
but the rest of the code example disappears.

If I add a space between the two &lt; &lt; the code shows, but the use
of the double << for a Here document isn't clearly shown.

Live page is at http://ericlindsay.com/blog/200508.htm#5 and will show
one of the three problems.

Can anyone straighten out my thinking on this?

--
http://www.ericlindsay.com

Posted by Leonard Blaisdell on December 30, 2005, 4:10 am
Please log in for more thread options



> I can't figure how to best display little snippets of shell script using
> <pre>. I just got around to organising to bulk validate some of my web
> pages, and one of the problems occurs with Bash shell pieces like this:
>
> <pre><code>
> #!/bin/sh
> ftp -i -n ftp.server.com&lt; &lt;EOF
> user username password
> epsv4
> cd /
> lcd ~/Documents/web101
> put test.htm
> quit
> EOF
> </code></pre>
> </p>

This displays fine in Safari and validates by BBEdit:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title></title></head>
<body>
<pre>
<code>
#!/bin/sh
ftp -i -n ftp.server.com&lt;&lt;EOF
user username password
epsv4
cd /
lcd ~/Documents/web101
put test.htm
quit
EOF
</code>
</pre>
</body>
</html>

It didn't work worth a damn when I wrapped it in a <p> element which I
assume you did judging by the </p> at the end of your example. And I
know that there is a reason for it, but it's 4 AM and I'm sleepy. Note
that I eliminated the extra space between the &lt; entities.
Hope this works for you, and I know you will be told definitively why
your original example didn't work.

leo

--
<http://web0.greatbasin.net/~leo/>

Posted by Stan Brown on December 30, 2005, 11:26 am
Please log in for more thread options


Fri, 30 Dec 2005 20:55:36 +1000 from Eric Lindsay <NOSPAmar2005
@ericlindsay.com>:
> If I use adjoining &lt;&lt; with no space, then the first < displays,
> but the rest of the code example disappears.

I do see that problem with Mozilla 1.7x under Windows XP. But when I
look at source this is what I see:

<pre><code>
#!/bin/sh
ftp -i -n ftp.server.com &lt;<eof user="" username="" password=""
epsv4="" cd="" lcd="" ~/documents/web101="" put="" test.htm=""
quit="" eof=""></eof></code></pre>

I have no idea what <eof> is supposed to be, but it's certainly not a
valid tag.

It's not just Mozilla; lynx shows me a variation on the same thing
(with line breaks between the attributes).

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you

Posted by mbstevens on December 30, 2005, 2:44 pm
Please log in for more thread options


Eric Lindsay wrote:
> I can't figure how to best display little snippets of shell script using
> <pre>. I just got around to organising to bulk validate some of my web
> pages, and one of the problems occurs with Bash shell pieces like this:
>
> <pre><code>
> #!/bin/sh
> ftp -i -n ftp.server.com&lt; &lt;EOF
> user username password
> epsv4
> cd /
> lcd ~/Documents/web101
> put test.htm
> quit
> EOF
> </code></pre>
> </p>
>
> If I leave the << to indicate I am using a Here document, then the WDG
> validator complains about all sorts of stuff.
>
> If I use adjoining &lt;&lt; with no space, then the first < displays,
> but the rest of the code example disappears.
>
> If I add a space between the two &lt; &lt; the code shows, but the use
> of the double << for a Here document isn't clearly shown.
>
> Live page is at http://ericlindsay.com/blog/200508.htm#5 and will show
> one of the three problems.
>
> Can anyone straighten out my thinking on this?
>
Yes, it truncates to this on Mozilla in Slackware:
#!/bin/sh
ftp -i -n ftp.server.com <

...truncating after that first <.

Since Spartanicus and L. Blaisdell can't see it,
I think it's something specific to browser decoding.
I use <pre> a lot, and that's something I havn't run into
before.

I downloaded it and played with it a bit. The thing that
brings it back under Moz/Slack is using &lt;&lt;, as you
predicted. I suspect you'll just have to live with WGD's
complaint, but both > characters display under Moz. What
browser are you using that displays it only as a single >?

The other problem is that under Moz/Linux, the newlines you are
using inside the <pre> do not show up in the Moz display.
I had to go in with vim and add the newlines myself to get
the lines to display in the <pre> correctly.
--
mbstevens
http://www.mbstevens.com/howtothumb





Posted by Eric Kenneth Bustad on December 30, 2005, 4:29 pm
Please log in for more thread options


>Eric Lindsay wrote:
>> I can't figure how to best display little snippets of shell script using
>> <pre>. I just got around to organising to bulk validate some of my web
>> pages, and one of the problems occurs with Bash shell pieces like this:
>>
>> <pre><code>
>> #!/bin/sh
>> ftp -i -n ftp.server.com&lt; &lt;EOF
>> user username password
>> epsv4
>> cd /
>> lcd ~/Documents/web101
>> put test.htm
>> quit
>> EOF
>> </code></pre>
>> </p>
>>
>> If I leave the << to indicate I am using a Here document, then the WDG
>> validator complains about all sorts of stuff.
>>
>> If I use adjoining &lt;&lt; with no space, then the first < displays,
>> but the rest of the code example disappears.
>>
>> If I add a space between the two &lt; &lt; the code shows, but the use
>> of the double << for a Here document isn't clearly shown.
>>
>> Live page is at http://ericlindsay.com/blog/200508.htm#5 and will show
>> one of the three problems.
>>
>> Can anyone straighten out my thinking on this?
>>
>Yes, it truncates to this on Mozilla in Slackware:
>#!/bin/sh
>ftp -i -n ftp.server.com <
>
>...truncating after that first <.
>
>Since Spartanicus and L. Blaisdell can't see it,
>I think it's something specific to browser decoding.
>I use <pre> a lot, and that's something I havn't run into
>before.
>
>I downloaded it and played with it a bit. The thing that
>brings it back under Moz/Slack is using &lt;&lt;, as you
>predicted. I suspect you'll just have to live with WGD's
>complaint, but both > characters display under Moz. What
>browser are you using that displays it only as a single >?
>
>The other problem is that under Moz/Linux, the newlines you are
>using inside the <pre> do not show up in the Moz display.
>I had to go in with vim and add the newlines myself to get
>the lines to display in the <pre> correctly.

I can see the problem when I view it in Firefox. But when I
view the page source, I am not seeing any &lt;s, only <'s:

        <pre><code>
        #!/bin/sh
        ftp -i -n ftp.server.com <<EOF
        user username password
        epsv4
        cd /
        lcd ~/Documents/web101
        put test.htm
        quit
        EOF
        ></code></pre>

Lynx -source shows pretty much the same thing, but without the
">" before the </code>. So Firefox is interpreting everything
from the <EOF to that > an unrecognized tag.

--
= Eric Bustad, Norwegian Bachelor Programmer

Similar ThreadsPosted
better/easy way to displaying c source code in html July 18, 2006, 5:44 am
Can't locate problem in HTML code IE ignores but Firefox is displaying. November 29, 2004, 2:01 pm
Why IE7 not displaying picture? November 11, 2006, 9:46 pm
Pictures not displaying May 9, 2008, 4:56 pm
Linked images not displaying October 21, 2005, 6:48 am
Mac IE not displaying background-image June 20, 2006, 6:39 am
Help! Background image not displaying... February 8, 2008, 6:11 pm
Displaying Text As Rollover with Tables March 20, 2005, 3:46 am
pages not displaying properly in safari March 18, 2006, 5:18 pm
Image Not Displaying for Some Firefox Users May 31, 2007, 11:21 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap