Re: [WSG] Style PRE with word wrap?

2005-06-01 Thread Vaska . WSG
It's a pretty solution, but it doesn't word-wrap...at least not in 
Safari.  Make your browser window thinner and see what happens?


What I'm doing is no different except that I'm going through the 
trouble of having php count the number of tabs and then using that 
information to insert the correct class.  If there are more than 5 \t's 
I just stop it there.  This information is coming out of a database so 
it's no trouble going this route...


Oh, I'm not using pre either...v


On Jun 1, 2005, at 1:08 AM, Lachlan Hardy wrote:


Vaska.WSG wrote:
I've been reading around (via Google) and I find others with similar 
problems but no solution.  Is there a solution to this?


Whenever I present code in a page, I use something similar to the 
method Simon Willison put forward by in July 2002: 
http://development.incutio.com/simon/numbered-code-experiment.html


Works for me. I've yet to find a better method (although if someone 
has one...)


Cheers
Lachlan
**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
**





**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ben
Ahh, cool. Looks like the white-space property is supported well enough.

http://www.westciv.com/style_master/academy/browser_support/element_type.html

I'll go back to using  for code blocks then. :)

Thanks for pointing out the property, Martin.

BenOn 5/31/05, Martin J. Lambert <[EMAIL PROTECTED]> wrote:
> From: Ben>> After some testing, I think it's best to stick to using  for> blocks of code.  won't preserve whitespace, so your code's> not going to have any indenting unless you use a lot of non-breaking
> spaces which will inflate the size of your file and not to mention> a real be a pain in the butt to add.How about using the  element (since it IS code), and usingthe following styles:
code {display: block;white-space: pre;}In my very quick test just now it seems to work in Firefox and IE,so I'd assume it works pretty much anywhere. This gets you the best
of both worlds - the semantics of  and the presentation of.--Martin Lambert[EMAIL PROTECTED]**
The discussion list for  http://webstandardsgroup.org/ See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help**


Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Lachlan Hardy

Vaska.WSG wrote:
I've been reading around (via Google) and I find others with similar 
problems but no solution.  Is there a solution to this?


Whenever I present code in a page, I use something similar to the method 
Simon Willison put forward by in July 2002: 
http://development.incutio.com/simon/numbered-code-experiment.html


Works for me. I've yet to find a better method (although if someone has 
one...)


Cheers
Lachlan
**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread designer
Hi Patrick,

- Original Message - 
From: "Patrick Lauke" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, May 31, 2005 1:43 PM
Subject: RE: [WSG] Style PRE with word wrap?

But to reiterate:  has semantic connotations - the content it
marks up is a heading. , on the other hand, does not provide
any indication of what's inside, only how it's displayed.

--

Yes, absolutely. BUT what I'm harping on about here is that if you set your
basic font in the body (or somewhere up there :-) you could then use  in
the html without qualifying it in any way with CSS, so long as you are happy
with the way the browser displays it. (and it's not IE, of course!).  You
probably wouldn't do this, but it illustrates the point.

The   says 'this is a heading' no more, no less, and  the  says
'this is some preformatted text', no more, no less. Neither really tells you
'exactly' what it's going to look like. OK, you 'expect' the  stuff to
be larger (which it isn't always) and you 'expect' the  to appear in
Courier font with white space etc, but you personally haven't defined
either.  The 'formatting' is done elsewhere (in this case, by the browser's
interpretation, NOT in the html markup, nor indeed in the CSS in this
example.  So I can't see the difference.

OK, I'm not going to labour this or do it to death, but I can't grasp this.

:-)

Bob McClelland,
Cornwall (U.K.)
www.gwelanmor-internet.co.uk




**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Vaska . WSG
I think this will do the trick.  It's a little odd, and I'll have to  
test this out more, doing a preg_match_all to determine how many \t's  
there are (so we know what class='tab$number' to use), but I think in  
most instances this will suffice.


Thanks for pointing this solution out...v


On May 31, 2005, at 4:41 PM, Ingo Chao wrote:


Vaska.WSG schrieb:

Actually, because I can't really find a way to get by on the  
word-wrap  issue and also the use of indents (as they appear in the  
code) I've  done all of this in php without code or pre.  It uses  
 's for the  tabs (preg_replace("/\t/"...).  ...

If you are curious this is what an output looks like ...
1 

Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ingo Chao

Vaska.WSG schrieb:

Actually, because I can't really find a way to get by on the word-wrap  
issue and also the use of indents (as they appear in the code) I've  
done all of this in php without code or pre.  It uses  's for the  
tabs (preg_replace("/\t/"...).  
...

If you are curious this is what an output looks like ...

1 

RE: [WSG] Style PRE with word wrap?

2005-05-31 Thread Martin J. Lambert
> From: Ben
> 
> After some testing, I think it's best to stick to using  for
> blocks of code.  won't preserve whitespace, so your code's
> not going to have any indenting unless you use a lot of non-breaking
> spaces which will inflate the size of your file and not to mention
> a real be a pain in the butt to add.


How about using the  element (since it IS code), and using
the following styles:

code {
display: block;
white-space: pre;
}

In my very quick test just now it seems to work in Firefox and IE,
so I'd assume it works pretty much anywhere. This gets you the best
of both worlds - the semantics of  and the presentation of
.


--
Martin Lambert
[EMAIL PROTECTED]

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



RE: [WSG] Style PRE with word wrap?

2005-05-31 Thread Patrick Lauke
> Vaska.WSG

> I've  
> done all of this in php without code or pre.

CODE is still the semantically correct element to wrap around this
type of content, though...

> What I'm doing is meant purely for presentation...it's a fast 
> way for a  
> person to view a script and try to determine where a bug might live  
> (via the line number).

> 1  2 
> 3 function  
> rowNumber($i)

Presentational, indeed...why not something like (provided your
code always starts from line 1, as support for CSS driven
OL numbering other than the default seems a bit flaky, still)


 

Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Vaska . WSG

Thanks for the discussion folks...

Actually, because I can't really find a way to get by on the word-wrap  
issue and also the use of indents (as they appear in the code) I've  
done all of this in php without code or pre.  It uses  's for the  
tabs (preg_replace("/\t/"...).  Aside from creating a few more regex  
rules to deal with inputting slashes and the like, it seems to work  
well enough.


What I'm doing is meant purely for presentation...it's a fast way for a  
person to view a script and try to determine where a bug might live  
(via the line number).


If you are curious this is what an output looks like (I'm not sure if  
the  's will encode when I send this email).  If there is time I  
might add some simple syntax highlighting rules to the script...


1 $i    
  ";
7 
 } elseif (($i >= 10) && ($i <= 999)) {
8 
 return  
"$i    
 ";
9 
 } else {
10 
return  
"$i    
";
11}/>

12}
13/>

14?>




On May 31, 2005, at 2:43 PM, Patrick Lauke wrote:


designer



Surely, the fact that  denotes 'preformatting' means that the
formatting has occurred 'somewhere else' and not in the body
of the html.
So, in that sense, in what way is   'presentational' any
more than all
CSS is 'presentational?


Aeh...I'm not quite following your reasoning here. But to pick up
just on the last bit: CSS is *meant* for presentation, while HTML
should only mark up *content*. That's where I see the problem:
 denotes how something looks, rather than what it is (which
is the whole idea of "semantic" markup).


To take a simple example, if I set
CSS rules in
defining   characteristics, is using that  tag in the
html 'purely
presentational' or is it different to ?


You'd use  only if the text you're marking up is an actual
heading (unless you use  to mark up "oh, i want that text nice
and big", in which case you're abusing  for presentational
purposes).

But to reiterate:  has semantic connotations - the content it
marks up is a heading. , on the other hand, does not provide
any indication of what's inside, only how it's displayed.



Sometimes,  strikes me just like a css declaration,
except that you
don't have to declare what the formatting is in the header :-)


And that's a bad thing; we want separation of content and presentation.

Patrick

Patrick H. Lauke
Webmaster / University of Salford
http://www.salford.ac.uk
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**





**
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
**



RE: [WSG] Style PRE with word wrap?

2005-05-31 Thread Patrick Lauke
> designer

> Surely, the fact that  denotes 'preformatting' means that the
> formatting has occurred 'somewhere else' and not in the body 
> of the html.
> So, in that sense, in what way is   'presentational' any 
> more than all
> CSS is 'presentational?

Aeh...I'm not quite following your reasoning here. But to pick up
just on the last bit: CSS is *meant* for presentation, while HTML
should only mark up *content*. That's where I see the problem:
 denotes how something looks, rather than what it is (which
is the whole idea of "semantic" markup).

> To take a simple example, if I set 
> CSS rules in
> defining   characteristics, is using that  tag in the 
> html 'purely
> presentational' or is it different to ?

You'd use  only if the text you're marking up is an actual
heading (unless you use  to mark up "oh, i want that text nice
and big", in which case you're abusing  for presentational
purposes).

But to reiterate:  has semantic connotations - the content it
marks up is a heading. , on the other hand, does not provide
any indication of what's inside, only how it's displayed.


> Sometimes,  strikes me just like a css declaration, 
> except that you
> don't have to declare what the formatting is in the header :-)

And that's a bad thing; we want separation of content and presentation.

Patrick

Patrick H. Lauke
Webmaster / University of Salford
http://www.salford.ac.uk
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ben
After some testing, I think it's best to stick to using  for
blocks of code.  won't preserve whitespace, so your code's
not going to have any indenting unless you use a lot of non-breaking
spaces which will inflate the size of your file and not to mention a
real be a pain in the butt to add.


Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread designer

- Original Message - 
From: "Patrick Lauke" <[EMAIL PROTECTED]>

To split hairs, though, the problem with  seems to be that it
appears very much like a presentational, rather than a semantic element.
Any semantics seem to be inferred by the fact that the content is
preformatted, which is a rather weak argument...by the same rationale,
one might as well say that , ,  etc are semantic.

Heck, even the spec's definition

'The PRE element tells visual user agents that the enclosed text is
"preformatted".'
http://www.w3.org/TR/html4/struct/text.html#edef-PRE

strikes me as purely presentational.

Patrick
---

Patrick,

Surely, the fact that  denotes 'preformatting' means that the
formatting has occurred 'somewhere else' and not in the body of the html.
So, in that sense, in what way is   'presentational' any more than all
CSS is 'presentational?  To take a simple example, if I set CSS rules in
defining   characteristics, is using that  tag in the html 'purely
presentational' or is it different to ?  If so, why is that?  Why is
one 'semantic', and not the other?

Sometimes,  strikes me just like a css declaration, except that you
don't have to declare what the formatting is in the header :-)

N.B. I'm not arguing here, I'm asking the question!

Bob McClelland,
Cornwall (U.K.)
www.gwelanmor-internet.co.uk


**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ben
On 5/31/05, Prabhath Sirisena <[EMAIL PROTECTED]> wrote:
I would do it this way:int foo (int a, int b) {   /* do stuff here */   } And use the css:code.codeblock
 {  display: block;}Is this OK, or do you find anything unacceptably wrong here? Looksbetter than a PRE to me.
Looks ok, but I'd probably just create a generic .block style that could be used for any tag.

.block {display: block}




Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ben Ward
Fair point,  was indented purely for presentation. However, it
does have a small bit of semantic significance, insofaras it says
"whitespace is important". Sure, it indents that in terms of
presentation but the implied meaning is not irrelevent (especially in
the context of languages where the whitespace is important (Pyton?
Possibly). This is the way in which I think of it at the moment, until
XHTML2's  element gains support.  replaces 
for code and effectively 'fixes' the problem.

Although, all that said, does the  tag apply default white-space
formatting in the major browsers? If so, wrapping it in a  would
be ample. I seem to remember that for some reason  didn't format
the whitespace without CSS, though.

Ben

On 5/31/05, Patrick Lauke <[EMAIL PROTECTED]> wrote:
> > Ben Ward
> 
>   is semantically pretty sound
> > for this, since code is pre-formatted and some languages are
> > white-space sensitive, for example.
> 
> To split hairs, though, the problem with  seems to be that it
> appears very much like a presentational, rather than a semantic element.
> Any semantics seem to be inferred by the fact that the content is
> preformatted, which is a rather weak argument...by the same rationale,
> one might as well say that , ,  etc are semantic.
> 
> Heck, even the spec's definition
> 
> 'The PRE element tells visual user agents that the enclosed text is
> "preformatted".'
> http://www.w3.org/TR/html4/struct/text.html#edef-PRE
> 
> strikes me as purely presentational.
> 
> Patrick
> 
> Patrick H. Lauke
> Webmaster / University of Salford
> http://www.salford.ac.uk
> 
> **
> The discussion list for  http://webstandardsgroup.org/
> 
>  See http://webstandardsgroup.org/mail/guidelines.cfm
>  for some hints on posting to the list & getting help
> **
> 
> 


-- 
http://www.ben-ward.co.uk
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Prabhath Sirisena
I would do it this way:


int foo (int a, int b) { 
  /* do stuff here */   
} 


And use the css:

code.codeblock {
  display: block;
}

Is this OK, or do you find anything unacceptably wrong here? Looks
better than a PRE to me.

Prabhath
http://nidahas.com
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



RE: [WSG] Style PRE with word wrap?

2005-05-31 Thread Patrick Lauke
> Ben Ward

  is semantically pretty sound
> for this, since code is pre-formatted and some languages are
> white-space sensitive, for example.

To split hairs, though, the problem with  seems to be that it
appears very much like a presentational, rather than a semantic element.
Any semantics seem to be inferred by the fact that the content is
preformatted, which is a rather weak argument...by the same rationale,
one might as well say that , ,  etc are semantic.

Heck, even the spec's definition

'The PRE element tells visual user agents that the enclosed text is
"preformatted".'
http://www.w3.org/TR/html4/struct/text.html#edef-PRE

strikes me as purely presentational.

Patrick

Patrick H. Lauke
Webmaster / University of Salford
http://www.salford.ac.uk

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Ben Ward
Prabhath -  is an inline element, so while is should probably be
included somewhere in marking up code, you need something else on the
outside of it to create the block.  is semantically pretty sound
for this, since code is pre-formatted and some languages are
white-space sensitive, for example.

Vaska - Unfortunately there's nothing in the CSS2 spec that I know of
to do what you want (see:
http://www.w3.org/TR/REC-CSS2/text.html#white-space-prop). You can
either obey the white-space in the source code or automatically wrap
to the box, but not both.

The equivalent part of the CSS Level 3 spec is massively improved
though; providing additional white-space values and additional
properties for controlling individual parts of white-space handling.
"white-space" itself now effectively sets different combinations of
values for these new properties. I have no idea what
Opera/Firefox/Safari/K support is like for this yet, but I believe
that the text module is pretty stable spec wise, so expect some
implementations sooner rather than later, if not already. See:
http://www.w3.org/TR/css3-text/#white-space

If implementations do exist, you might be able to compromise your
design by using a CSS2 compatible white-space setting and overflow
scrolling for any long lines, then set the CSS3 value afterwards for
better handling in newer browsers as and when they support it.

Cheers,
Ben

On 5/31/05, Prabhath Sirisena <[EMAIL PROTECTED]> wrote:
> > I'm trying to make a page that will display some source code.  The PRE
> > tag works very will with retaining \t and \n but I can not find a way
> > to make it wrap words.  Words fly off the monitor...
> 
> Shouldn't you be using the code tag instead? It's a semantically better 
> option.
> 
> However, the problem will still remain.
> 
> Prabhath
> http://nidahas.com
> **
> The discussion list for  http://webstandardsgroup.org/
> 
>  See http://webstandardsgroup.org/mail/guidelines.cfm
>  for some hints on posting to the list & getting help
> **
> 
> 


-- 
http://www.ben-ward.co.uk
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**



Re: [WSG] Style PRE with word wrap?

2005-05-31 Thread Prabhath Sirisena
> I'm trying to make a page that will display some source code.  The PRE
> tag works very will with retaining \t and \n but I can not find a way
> to make it wrap words.  Words fly off the monitor...

Shouldn't you be using the code tag instead? It's a semantically better option. 

However, the problem will still remain.

Prabhath
http://nidahas.com
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
**