Syntax highlighting

C

Chupo

@j33g2000yqn.googlegroups.com>, Nick Keighley
so as to avoid it?

:))

ConTEXT as in the Windows based text editor?

Yes, ConTEXT by Eden Kirin who helped me a lot of times (on
hr.comp.programiranje (programiranje --> programming) and similar
newsgroups).
I use that, how do you
get it to save the formatting in html? If I save it as html I lose all
the formatting. Have I misunderstood what you're saying?

Sorry, my mistake, I meant *export* to HTML. And there is an option to
export to RTF too.
 
C

Chupo

Keith Thompson <kst- said:
To retain any pasted highlighting information, the
editor would have to store that information in addition to the text;
to be a programming editor, it would have to save the file in a
format acceptable to a compiler.

ConTEXT, (very good) Windows programming editor I mentioned before has
the option to export the highlighted text to .rtf file format so
afterwards (upon opening it in some text editor (Wordpad, Word)) the
text can be copy/pasted with syntax highlighting between the comaptible
editors.

I suppose the whole chain (export to reach text format+copy to
clipboard) could be done in RAM and on-the-fly. It may be a good idea
to even assign a new shortcut similar to Ctrl-C for such 'copy'. Or
even not for pasting into a programming editor would strip the
highlighting information.

I know this would be very specific 'copy' to paste only in a few text
editors (doesn't work with my mail client - Eudora) but would be good
enough (at least for me).

Besides, sintax highlighted text can be copy/pasted from some HTML
pages directly even into Eudora, the task (generally) can be easily
done in a few steps manually and I believe everything that can be
described must be possible to program (even if 'copy' routine would
have to OCR the selected text to put the data on the clipboard).
 
R

Rui Maciel

Chupo said:
I stumbled upon an old (abandoned) site:

http://users.powernet.co.uk/eton/kandr2/

and would like to know what program/method was used for syntax
highlighting. I see there is now a new page:

http://clc-wiki.net/wiki/K&R2_solutions

where GeSHi C has been used to highlight the code but I am examining
the other methods as well. For example, I sometimes use ConTEXT to save
highlighted code in .html file so I can paste the highlighted code
where I need.

I've tried to reach Richard Heathfield to ask him a question but
could't find any valid mail address.

ps
I often use to paste the *highlighted* ) articles from my newsreader
(Microplanet Gravity) into the M$ Word, is there any way to paste
highlighted C code from somewhere into a Word document?

If you happen to use linux then you only need to open your source file with Kate[1] and use the
Exporter plugin to export a code selection to HTML.


Hope this helps,
Rui Maciel


[1] http://www.kde.org/applications/utilities/kate/
 
J

James Dow Allen

.
in the very first solution I don't see any reason to use the variable
'firstletter'? Maybe I am wrong but I think everything would work
perfectly well even after removing every occurrence of it :-/

No one else semes to have commented on this.

Outputs of getchar() have only three classes: EOF, space,
non-space. And if the program is viewed as a transition machine,
it has only 3 states: done, in spaces, in a word. Rather than
using *THREE* boolean variables, it would have seemed more
straightforward to use 2, 1, or even zero.

It might be wrong to criticize a completely useless boolean
variable: it might come in handy if the program needs to be
revised for added functionality. Still I'd be doubtful ...
and would avoid publishing code with useless variable(s).
(By the way, "firstletter" might not be completely useless
if the redundant initialization of wordlen were removed.)

In another recent thread, goto's are discussed.
I'd be curious what those opposed to goto's think about
unnecessary flags and variables. Personally I find
useless (and therefore misleading) variables to be a greater sin.

By the way, I am absolutely sure that I am not the only
one *astounded* by comments from the page like
"...a Vertical-Histogram is a mind-bending exercise."
The program logic here is trivial. To imagine it as
"mind-bending" gives credence to the belief that some
participants in debates here are experienced only
with trivial code.

James Dow Allen
 
N

Nick Keighley

@j33g2000yqn.googlegroups.com>, Nick Keighley
<[email protected]> says...

[saving highlighted code in HTML from the ConTEXT editor]
Yes, ConTEXT by Eden Kirin who helped me a lot of times (on
hr.comp.programiranje (programiranje --> programming) and similar
newsgroups).

I like it a lot.
Sorry, my mistake, I meant *export* to HTML. And there is an option to
export to RTF too.

well b***r me. I never knew *that* was there. How cool. I'll
definitely renew my subscription to CLC after that!
Uses style sheets to boot.
 
C

Chupo

(e-mail address removed)>, James Dow Allen
(By the way, "firstletter" might not be completely useless
if the redundant initialization of wordlen were removed.)

Then 'inspace' might be initialized to 1 instead to 0 so we need
neither 'firstletter' nor initialization of 'wordlen'. In fact, seems
to me that in that case we could even remove

if(wordlen > 0)

condition check because it is not possible to reach that statement
before passing thru

wordlen = 0;
..
..
++wordlen;
By the way, I am absolutely sure that I am not the only
one *astounded* by comments from the page like
"...a Vertical-Histogram is a mind-bending exercise."
The program logic here is trivial.

Yes, it shouldn't be considered complicated as I recall we had to
'draw' similar ASCII graph (in Fortran) during one of the beginning
classes in the 1st year of high school (20+ years ago).
 
C

Chupo

Rui Maciel said:
If you happen to use linux then you only need to open your source file with Kate[1] and use the
Exporter plugin to export a code selection to HTML.

Unfortunately I am not using Linux (at least not at the moment) but is
good to know just in case, thank you for the information!
 
C

Chupo

Richard said:
It should be easy enough to decode my sigblock - but of course now you
don't have to, since you did manage to find my address eventually.

I've 'found' it after reading Keith Thompson's answer about your
signature. I saw the old page is not maintainded anymore, there wasn't
your mail address on clc-wiki but there was a reference to this
newsgroup so I asked here but forgot to search the archive (this was my
very first visit to comp.lang.c). I probably (wrongly) assumed since I
couldn't find your email address by your articles on CLC-wiki, I
wouldn't find it here either.
You already know the answer to your question (in fact, /you/ told /me/
the answer!),

Yes, after Nisse told me the answer :)
but I'll answer it here anyway - the syntax highlighting
for code published on my old site was performed by a program written by
Bryan Williams (the same guy that hosts the DS-9000 1/4 spoof).

Thank you again for answering me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top