Syntax mark-up for documenting code?

Everything else that doesn't fall into one of the other PB categories.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Syntax mark-up for documenting code?

Post by dmoc »

I'm looking for a util that can take PB source and produce xml for syntax highlighting. I'd like then to import sections into an OpenOffice doc and also into html. I'd like to do this without wasting significant portion of my life :P All suggestions welcome!
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

What exactly should this xml output look like ?
quidquid Latine dictum sit altum videtur
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

I imagine it would just enclose each chunk according to type, ie, "comment", "PB-keyword", "constant", "variable", etc. For inclusion in a web page it would be nice to preserve tabs. The tool-chain (if that's the right way to describe it) would be:

PB-Source -> PARSE-TO-XML -> [PARSE-TO-HTML | PARSE-TO-OODOC]

First requirement is a way to tokenise PB src and I though there may already be a way to do this. I'm pretty sure someone has already done something similar. Wasn't there a web site for PB source that featured syntax highlighting and preserved spacing?

FYI - I have a large amount of PB source that I want to document so I can dump some on my web site and also include in a pdf (via OpenOfficeDoc).
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

We have decided to provide the syntax coloring engine of the PureBasic IDE as
a separate dll with the library sdk, to ease tasks like this one.

I have put it up for download here if you want to try it:
http://freak.purearea.net/v4/SyntaxHighlightning.zip

Should be very easy to do the stuff you want with that.
quidquid Latine dictum sit altum videtur
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

very nice freak - thank you.

and if it's possible, can you provide the .lib, please ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

@freak
thx Image
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Freak u r freaking great! :D
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

Hi Freak,

1
the SyntaxHighlightning DLL doesn't work when in UNICODE mode. :(

Maybe you can provide 2 internals functions :

SyntaxHighlightA(*hBuf.l, lBuf.l, type.l, *userData)
SyntaxHighlightW(*hBuf.l, lBuf.l, type.l, *userData)

2
And it would be very handy to let the user specify
a *userData field in order to NOT deal with global vars.

Cheers.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Yes, unicode input is not supported, but utf8 input is. So you can convert the whole
buffer to utf8, then use the dll and convert the result back to unicode.
I can add a wrapper to do that automatically though.

For the userdata field: Yes, i can add that as well.
But keep in mind, that the dll is not threadsafe, so you can process only one
source at a time anyway, so you may just as well use global variables.
quidquid Latine dictum sit altum videtur
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

thank you freak for the answer.

about userdata, yes, it would be nice. even if it's not threadsafe (not a problem in my case).

and about unicode, no problem, i will convert to utf8 myself.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Freak, this is a fantastic tool to release - thank you.

:D
I may look like a mule, but I'm not a complete ass.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

btw: broken link.
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

The files are included in the PureBasic package (LibrarySDK folder) since v4.
quidquid Latine dictum sit altum videtur
Post Reply