Shelton/C# should be able to match my HTM_TXT.EXE .

J

Johannes Bauer

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefan said:
Jeff_Relf wrote:

Freaking Relffeeder. *PLONK*

Greetings,
Johannes

- --
PLEASE verify my signature. Some forging troll is claiming to be me.
My GPG key id is 0xCC727E2E (dated 2004-11-03). You can get it from
wwwkeys.pgp.net or random.sks.keyserver.penguin.de.
Also: Messages from "Comcast Online" are ALWAYS forged.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCZXCfCseFG8xyfi4RAtObAKCf3t+Wq6/cEl3Zw+u2MbM1FLud0QCgl1pu
i2LNKe6YeOcuG1YzUxD75lc=
=rbsL
-----END PGP SIGNATURE-----
 
J

Jeff_Relf

Hi John, Re: My comment that no one produced Results as good as mine,

You told me: <<
And you did not match the results of anyone else's code, either. >>

An' yer saying exactly what... that you prefered their Results,
....or, more likely, that you prefered the inane simplicity of their source ?

I'm glad I'm not working beside you... because your attitude sucks.

P.S. I watched that Veronica_Mars AVI you told me about,
veronica_mars.1x18.weapons_of_class_destruction.hdtv_xvid-fov.[BT].avi.torrent
The penguin was not just the perp... he was also a Whining_Wimp.

The Mac expert was a Sexy_Super_Hero.
The Windows user was a Dumb_Brute.
The FBI investigators were the Keystone_Cops.

Speaking of WiFi illegalities,
I've been benching my free LANs a lot, one is often 3.7/.37 MBps, Comcast,
so my self imposed cap of .13 MBps upstream would not be noticed at all,
neither by me when I'm surfing, nor by the LAN's owner.
 
S

Special Exchange

Jeff_Relf said:
Oops, make that 3.7/.37 Mbps, and .13 Mbps upstream, not MBps.

Yeah, Comcast is even advertising 4M on their flyers ( got one in the
mail today ).

But there's something about cable networks...that makes me prefer dsl
 
J

Jeff_Relf

Hi John, Re: My free LANs, You told me: <<
Yeah, Comcast is even advertising 4M on their flyers
( got one in the mail today ).

But there's something about cable networks
...that makes me prefer dsl >>

I've been benching a lot, the one I just did was 4 Mbps/.36 Mbps !
I think it's the colledge kids next door... they must be asleep.
I need something to download, I hate seeing all that bandwith being unused.
 
S

Stefan Simek

J

Jeff_Relf

Re: http://www.triaxis.sk/temp/AA.TXT
Well, Howdy_Do_Dee, Stefan_Simek... well done !

But you're not preserving whitespace like I do,
you're simply collapsing whitespace,
so it doesn't handle the <pre> tag.

For example, HTM_TXT.EXE handles <pre> by turning this:
http://www.Cotse.NET/users/jeffrelf/index.htm
( View_Source --> File --> Save_Page_As )
into this:
http://www.Cotse.NET/users/jeffrelf/index.TXT

What I do is remove lines that have nothing but whitespace and tags
but leave all lines that had no tags, even if they're just blank lines.
I doubt that your RegEx could do that.

On a much more minor point,
your  » and  © are each using two 7-bit char UTF encoding,
which can be further decoded to single 8-bit chars.

Given that Ch is the name of the first 7-bit char and Ch2 is the second,
UTF decoding goes something like this:
if ( Ch == 194 || Ch == 195 ) && ( Ch2 & 0xC0 ) == 0x80 )
return ( Ch & 3 ) << 6 | Ch2 & 0x3F ;

Re: http://www.triaxis.sk/temp/HTM_TXT.ZIP

That's a lot more files/directories than I showed you,
which, in my opinion, makes your project much less readable/maintainable.

Re: Double_clicking: C:\__\Stefan_Simek\bin\Release\htm_txt.EXE

I got a message saying that I didn't have the .NET's 2.0.5 framework.
I'm running on a Win_XP system I bought about 6 months ago at Office_Depot.
I have MS_Office_XP and Visual_Studio_NET_2003 installed on it,
with whatever the default install did.

Re: C:\__\Stefan_Simek\Program.cs

Although I'm sure it's not true, my copy of Visual_Studio_NET_2003 tells me
there's a bunch of syntax errors in it, including mismatched braces {}.

Re:
Regex.Replace( input
, @"(?'entity'&((\w+)|(#[0-9]+)|(#x[0-9a-fA-F]+));?)|
(?'tag'<[/?]?\w+(([^\][^""])|(\""[^\][^""]*?\""))*?>)
|(?'comment'<!--.*?-->)",
delegate ( Match m ) { // convert entities
if ( m.Groups["entity"].Success ) {
if ( m.Value == "&nbsp;") return " ";
return System.Web.HttpUtility.HtmlDecode( m.Value ); }
if ( m.Groups[ "tag" ].Success && m.Value.ToLower() == "<br>" )
return "\n";
// clear the rest
return ""; }, RegexOptions.Singleline );

Hmm... return System.Web.HttpUtility.HtmlDecode( m.Value ); ?
That's quite bizarre, nothing like C... but it works, I see.
 
S

Stefan Simek

Jeff_Relf said:
Re: http://www.triaxis.sk/temp/AA.TXT
Well, Howdy_Do_Dee, Stefan_Simek... well done !

Thx ;)
But you're not preserving whitespace like I do,
you're simply collapsing whitespace,
so it doesn't handle the <pre> tag.
??


For example, HTM_TXT.EXE handles <pre> by turning this:
http://www.Cotse.NET/users/jeffrelf/index.htm
( View_Source --> File --> Save_Page_As )
into this:
http://www.Cotse.NET/users/jeffrelf/index.TXT

What I do is remove lines that have nothing but whitespace and tags
but leave all lines that had no tags, even if they're just blank lines.
I doubt that your RegEx could do that.

Well, my conversion of your index.htm is byte-to-byte equivalent except
for two empty lines at the end of the document. And I see no special
treatment of the said:
On a much more minor point,
your  » and  © are each using two 7-bit char UTF encoding,
which can be further decoded to single 8-bit chars.

The output encoding is UTF-8 by default in .NET. You can change it to
anything else by changing the line

using (StreamWriter sw = new StreamWriter(args[1]))

to

using (StreamWriter sw = new StreamWriter(args[1], false,
Encoding.GetEncoding(1250_or_whatever)))
Given that Ch is the name of the first 7-bit char and Ch2 is the second,
UTF decoding goes something like this:
if ( Ch == 194 || Ch == 195 ) && ( Ch2 & 0xC0 ) == 0x80 )
return ( Ch & 3 ) << 6 | Ch2 & 0x3F ;

Re: http://www.triaxis.sk/temp/HTM_TXT.ZIP

That's a lot more files/directories than I showed you,
which, in my opinion, makes your project much less readable/maintainable.

???
I thought that VS6.0 for example generated .dsw, .dsp, .ncb and more
files as well. The *only* file required is the Program.cs. I've provided
a link to the .NET 1.1 source, build command and exe at the end.
Re: Double_clicking: C:\__\Stefan_Simek\bin\Release\htm_txt.EXE

I got a message saying that I didn't have the .NET's 2.0.5 framework.
I'm running on a Win_XP system I bought about 6 months ago at Office_Depot.
I have MS_Office_XP and Visual_Studio_NET_2003 installed on it,
with whatever the default install did.

Well, as the error message says, it requires the .NET framework 2.0.5
(beta2).
Re: C:\__\Stefan_Simek\Program.cs

Although I'm sure it's not true, my copy of Visual_Studio_NET_2003 tells me
there's a bunch of syntax errors in it, including mismatched braces {}.

Because anonymous delegates were not supported back in 1.1.
Re:
Regex.Replace( input
, @"(?'entity'&((\w+)|(#[0-9]+)|(#x[0-9a-fA-F]+));?)|
(?'tag'<[/?]?\w+(([^\][^""])|(\""[^\][^""]*?\""))*?>)
|(?'comment'<!--.*?-->)",
delegate ( Match m ) { // convert entities
if ( m.Groups["entity"].Success ) {
if ( m.Value == "&nbsp;") return " ";
return System.Web.HttpUtility.HtmlDecode( m.Value ); }
if ( m.Groups[ "tag" ].Success && m.Value.ToLower() == "<br>" )
return "\n";
// clear the rest
return ""; }, RegexOptions.Singleline );

Hmm... return System.Web.HttpUtility.HtmlDecode( m.Value ); ?

I see no reason for writing my own entity parser as long as there's one
provided by the framework.
That's quite bizarre, nothing like C... but it works, I see.

Sure it's not like C. It's been a few years since 1978, and the ways of
programing have evolved by now...
See the following for a .NET 1.1 version, whith added command line
checking and exception handling:
http://www.kascomp.sk/tmp/htm_txt.cs
http://www.kascomp.sk/tmp/htm_txt.exe
http://www.kascomp.sk/tmp/build.bat
 
J

Jeff_Relf

Hi Stefan_Simek,

Your HTM_TXT.EXE preserves whitespace reasonably well,
as your Index.TXT was exactly the same, byte for byte, as mine.
As I tried to say before, my code does not look for the <pre> tag,
it just always preserves whitespace.

Re: using (StreamWriter sw = new StreamWriter(args[1], false
, Encoding.GetEncoding(1250))) sw.Write(output);

Well done !

Re: This .NET 1.1 stuff:
http://www.kascomp.sk/tmp/htm_txt.cs
http://www.kascomp.sk/tmp/htm_txt.exe
http://www.kascomp.sk/tmp/build.bat

Now that's much more like it, well done,
I liked that much more than the .ZIP you showed before.

Re: Your .NET framework 2.0.5 ( beta2 ) code with anonymous delegates,

That was very interesting, but it complicated the installation.

Re: System.Web.HttpUtility.HtmlDecode( m.Value );,

You wrote: << I see no reason for writing my own entity parser
as long as there's one provided by the framework. >>

You have a point there, but I like playing with the lower_level stuff.

You wrote: << Sure it's not like C. It's been a few years since 1978,
and the ways of programing have evolved by now... >>

C# is a mutation, and a rather recent one at that,
it doesn't meet my needs... no #define.
 
E

Exciting Possibility

Jeff_Relf said:
Hi Stefan_Simek,

Your HTM_TXT.EXE preserves whitespace reasonably well,

Am I missing something here?

As a test I saved this page:

http://www.howstuffworks.com/search.php

as a text file.

I compiled htm_txt.cs in mono and ran it against search.php.html, it
produced a text file search.php.txt This output file has only one line
in it -- what appears to be the title.

Both the html source and txt output are attached.




as your Index.TXT was exactly the same, byte for byte, as mine.
As I tried to say before, my code does not look for the <pre> tag,
it just always preserves whitespace.

Re: using (StreamWriter sw = new StreamWriter(args[1], false
, Encoding.GetEncoding(1250))) sw.Write(output);

Well done !

Re: This .NET 1.1 stuff:
http://www.kascomp.sk/tmp/htm_txt.cs
http://www.kascomp.sk/tmp/htm_txt.exe
http://www.kascomp.sk/tmp/build.bat

Now that's much more like it, well done,
I liked that much more than the .ZIP you showed before.

Re: Your .NET framework 2.0.5 ( beta2 ) code with anonymous delegates,

That was very interesting, but it complicated the installation.

Re: System.Web.HttpUtility.HtmlDecode( m.Value );,

You wrote: << I see no reason for writing my own entity parser
as long as there's one provided by the framework. >>

You have a point there, but I like playing with the lower_level stuff.

You wrote: << Sure it's not like C. It's been a few years since 1978,
and the ways of programing have evolved by now... >>

C# is a mutation, and a rather recent one at that,
it doesn't meet my needs... no #define.


HowStuffWorks - Search
 
J

Jeff_Relf

Hi John, Re: Your attempt to convert
http://www.howstuffworks.com/search.php

You can't just do a Save_Page_As, you Must do a View_Source first.

This is what the .HTM file should look like:
http://www.Cotse.NET/users/jeffrelf/BB.HTM
and my HTM_TXT.EXE translates it to this:
http://www.Cotse.NET/users/jeffrelf/BB.TXT

Notice that my HTM_TXT is faithful to the raw whitespace and the <BR> tag,
leaving/printing as many as was called for,
while Stefan_Simek's HTM_TXT won't allow more than two blank lines in a row.

But I had to radically modify my HTM_TXT to properly handle multilined tags:
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.EXE
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.CPP
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.VCPROJ

And, because HTM_TXT is merely a demo of code from X.CPP
( my custom e-mail client and newsreader ) these files were also affected:
http://www.Cotse.NET/users/jeffrelf/X.EXE
http://www.Cotse.NET/users/jeffrelf/X.CPP
http://www.Cotse.NET/users/jeffrelf/X.VCPROJ
 
J

Journey To The Center of The Earth

Jeff_Relf said:
Any code that does useful work is going to take time to understand.

Very true...which is why you should not dismiss all .NET code as being
written by "script kiddies".
 
J

Journey To The Center of The Earth

Jeff_Relf said:
But I had to radically modify my HTM_TXT to properly handle multilined tags:
And, because HTM_TXT is merely a demo of code from X.CPP

I see, so you admit that all you do is write sample code...but
completely unextensible.

The c# folks just proved how inflexible c++ code is because you have to
set up a static starting point and then produce a result.

Whereas us c# people have been able to dynamically change our code very
quickly as you move the goal posts around to suit yourself.
 
T

Tom Shelton

I see, so you admit that all you do is write sample code...but
completely unextensible.

The c# folks just proved how inflexible c++ code is because you have to
set up a static starting point and then produce a result.

Whereas us c# people have been able to dynamically change our code very
quickly as you move the goal posts around to suit yourself.

That's why I gave up... Relf will never be satisfied. My attempt met
every one of the criteria that he laid out in the original post - except
for entity translation, and the only reason I didn't handle that was
because I was unclear on what he wanted to have happen (and I did ask
for clarification, but never did see a response). But, when he saw that
I did it in like 3-4 lines of code - suddenly, several more criteria are
added.

It was the same thing with the phone number parsing... With every post
of an answer he had to change the format.

Relf doesn't want to use C#. That's fine, we all make choices and he
has made his. I have no intention of producing another line of code for
him.
 
J

Jeff_Relf

Hi Tom_Shelton ( and Bellow ),
Re: The Piss_Poor job you did of converting HTML to plain text,

You thought you could match my HTM_TXT.CPP while your dishes dryed,
....how naive !

Not even Stefan_Simek could faithfully perserve blank lines
or honor all <br> tags.

Try converting BB.HTM Tom:
http://www.Cotse.NET/users/jeffrelf/BB.HTM
Make it look like this:
http://www.Cotse.NET/users/jeffrelf/BB.TXT

http://www.Cotse.NET/users/jeffrelf/HTM_TXT.EXE
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.CPP
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.VCPROJ

The best Simek could do was
to leave a lot of blank lines where the tags used to be
and then consolidate mulitple blank lines into one.

i.e. Simek's htm_txt.cs produces blank lines where I do Not want them,
and omits blank lines where I Do want them.

Does it surprize you that I didn't give you my full specs at first ?
It shouldn't... I didn't want to overwhelm you any more than I already was.

You told Bailo: << That's why I gave up... Relf will never be satisfied.
My attempt met every one of the criteria that he laid out
in the original post - except for entity translation... >>

Unlike Kelsey and Simek, you never figured out how to download an HTML page
( you must do a View_Source before the Save_Page_As ).

You wrote: << It was the same thing with the phone number parsing,
...With every post of an answer he had to change the format. >>

Right... you couldn't understand what my code was doing,
and, therefore, what I required of it.
Nor did you have the patience to have me explain it.
....No surprises there... huh ?

You concluded: << Relf doesn't want to use C#.
That's fine, we all make choices and he has made his.
I have no intention of producing another line of code for him. >>

Using COM and other bloatware is fine in a pinch ( ¡ ¡ ¡ Slo-o-ow ),
but it's not the hallmark of a serious coder.
....You're a Half_Assed coder, Shelton... end of story.

#define is too dangerous for C# kiddies such as you.

#define LOOP while ( 1 )

#define Loop( N ) int J = - 1, LLL = N ; while ( ++ J < LLL )

#define LoopTo( StopCond ) \
while ( Ch && ( Ch = ( uchar ) * ++ P ) \
&& ! ( Ch2 = ( uchar ) P [ 1 ], StopCond ) )

#define LoopXx( Xx ) Xx##P P = 0, B ; int J = -1 ; \
Xx##A BB = Xx.BB, EE = Xx.PP + 1, PP = BB - 1 ; \
if ( BB ) while ( ++ J, B = P = * ++ PP, PP < EE )
 
J

Jeff_Relf

Hi Bellow, You told me: <<
I see, so you admit that all you do is write sample code
...but completely unextensible. >>

HTM_TXT.EXE demonstrates 47 lines of code from X.CPP,
and X is used daily be me, as it's the best e-mail client newsreader
I've never known... by miles.

And you know it's totally flexible, as you see how I change it all the time.
 
Top