Closed Thread Icon

Topic awaiting preservation: UBB Code for my site (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=13032" title="Pages that link to Topic awaiting preservation: UBB Code for my site (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: UBB Code for my site <span class="small">(Page 1 of 1)</span>\

 
Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 01-09-2004 07:34

Hello,
I'm interested in implementing UBB code for the online content that my users can edit. How do I go about this? What parses the UBB code... or do I have to write my own parser? I'm quite familiar with XSLT, can XSLT parse the UBB code?
Karl

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 01-09-2004 09:31

Heigh Ho, Heigh Ho...it's over to Server side this goes.

*wanders off whistling*

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-09-2004 12:24

ubb code is usually 'parsed' badly via regular expressions.
the grail (=the new asylum) has the only ubb code 'parser' that actually is a parser.

For regexp examples, see the phpbb source code (GPL),
if you want to use the grail's parser, that can be done ,but us coders have to agree on a license first... could take a couple of days.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 01-09-2004 17:24

I might be interested in writing my own parser. I have a *parser* of sorts that I use to transform ASP pages/ADO XML Data from Table into HTML pages. It relies mostly on XSLT, but all of the server side logic is wrapped up in an asp Class - as in: what data to grab, what to do when user clicks edit, and so on... I could include a USB Regexp function at this level of my processing...
Is there a library or resource of all the standard UBB codes in use?

[edited]
Oh, and I'd be interested in implementing your parser (if it fits)... sounds like it would need an ASP version written though.

Karl

[This message has been edited by Karl (edited 01-09-2004).]

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-09-2004 18:15

ok... I never had to do this in ASP.
Are we talking .net or 'plain' ASP here?
It should be fairly simple in .net, don't ask me about the old asp, vbscript is one horrible language to work with in my experience.

Basic idea is: You scan for [, see if you can find a matching ] (ie. which is only seperated from the [ by valid chars), add the tag to a list.
Later you match opening and closing tags [ubb] [/ubb], and replace them with the appropriate html.
Advantage over regexps: you can nest tags, and do other cool stuff like treading namespaces (example c2->WelcomeVisitors) via neraly the same mechanisms.

so long,

Tyberius Prime

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 01-09-2004 19:22

Yes, classic ASP.
I opted to avoid the entire DOT NET surge, because I favored XML and XSLT parsing over any sort of server drag&drop object onto a web form.
So far, I have not regreted this.
Now, agreed the DOT NET environment is a much more robust and stable system, I've been in there and can testify to that. But really, how complex a language and *design tool* is required to say "Welcome to my web page".... and so on.
So we are search for an opening bracket "["... then finding the next immediate clossing "]". You say you run through the entire document this way first? Second to this you determine the tag within and match with the next occurence of a matching tag. I suppose at this point you could replace the UBB with HTML tags, sort of *eliminate* the work as you go.
Any more tips? I'm starting to get a feal for this.
Karl

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-09-2004 23:57

well, no, you first find everything between [] that looks like a tag (contains no invalid characters).
You match them later on, and filter out those that are not tags.
That way you can also have 'simple' tags that don't have a closing partner, and nested tags which may contain other tags, even of the same kind, within them.
Then you replace them... keeping count of the characters you inserted and removed because you'll have to adjust the store tag locations.
(I actually build up a list of 'replacements' to do, sort it by position (lowest first), and then replace 'em.)

good luck doing this in vbscript.

Karl
Bipolar (III) Inmate

From: Phoenix
Insane since: Jul 2001

posted posted 01-10-2004 16:03

Tyberius:
What do you think of this guy's ubb parser: http://www.firegemsoftware.com/other/tutorials/ubb.php


Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 01-10-2004 16:06

usually, I just write long regexps to turn [-b-] into <b> and [url-=-http://www.blah.com] into <a href="http://www.blah.com">


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 01-10-2004 17:07

Petskull: Don't you have some difficulties do deal with wrong UBB codes, or badly nested ones ?

I've often thought to use UBB codes for some administrations modules, but it suppose that the end user have a brain and know how to use it, which was not the case of the target audience ( people in their mid-age, not willing to learn, stuck in their habits to use a "Word toolbar", strongly believing that an Excel sheet is a database ... ) in my ex-company. But I'll certainly reconsider this for a personnal project.

I think, I'll go for something a little more oldschool, and parse recursively the [ and ]. It'll probably more complex than a set of REGEX but it'll take all the cases into account.

Karl: The UBB parser you gave is nice but it accepts badly nested UBB codes.



[This message has been edited by poi (edited 01-21-2004).]

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-10-2004 20:34

A simple regexps parser,
and a pretty good start if you want to go down that route.
But be aware:
Regexps don't count.

Ie. if you have '(b) Hello (i)(b)world(/b)(/i). How are you?(/b)'
A regexps will never return the 'correct' answer of one (b) from the start to the end, and the other surrounding world.
It will at best return (b) from start to end of world.

Now, this often isn't a requirement, and this very ubb lives fine without that capablitity,
and it's the fastest way to develop something that handles most ubb, provided you have rexeps support.
(I'm not certain that ASP does, but I never dug that deep into it)

So long,
TP
-the who basically had to write his own regular expression machine for some very insane project last night.

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 01-13-2004 20:35

poi: actually, I do have trouble with incorrect UBB... but it ends up just sitting there as a glaring mistake...

...most of the UBB I'll be parsing is just simple text THAT I HAVE WRITTEN and not forums or anything like that... so, if my UBB is wrong, I'd just rewrite the file and re-upload it..


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 01-14-2004 00:33

Petskull: If a recursive check of the UBB codes could insert a subtle ** WARNING * ORPHAN UBB CODE * [ img ] ** or ** WARNING * UNAUTHORIZED PROTOCOL * javascript:alert('kwak! kwak!'); ** in white over a red background ( and eventually try to generate a version with the problem fixed ), it would be easier to spot than a little problem of font-weight or who knows what. But, indeed if you're the main user, the things shouldn't go crazy.



[This message has been edited by poi (edited 01-14-2004).]

[This message has been edited by poi (edited 01-21-2004).]

« BackwardsOnwards »

Show Forum Drop Down Menu