Jump to content

Good way to implement [nocode]?


Azu

Recommended Posts

Hello

I'm working on being my own BBcode parser, but I would like to get this out of the way before continuing.

 

Please can somebody tell me a good way to implement [nocode] tags? The only ways I can think of are very bad/hacky solutions I think and have a chance of getting messed up.

 

 

Hmm I was going to post an example but it seems this forum doesn't support [nocode] :/ but basically if there is an opening element before the nocode, and a closing one INSIDE IT, it would get messed up..

 

The only way around this I can think of is like randomly making a string of random characters and putting the stuff between the nocode tags into a subarray of that and then deleting it from the text and replacing it with the string of random characters, and later putting them back in after all the interpreting is done.. but I think that this is an extremely hacky of doing it and probably not very good performance either.. so I don't want to do it this way so I'm wandering if someone can please tell me a good way to do it..

Link to comment
Share on other sites

You talking about nesting stuff like if you had

[tag ]

  Some text but wait a [tag ] in a tag! [/tag]

  some more text

[/tag]

 

and you don't want that inner tag closer to phrase out the upper one?  your idea sounds like it will work, but that requires you to carry it across, maybe instead of a random character pattern you use a defined one and then do a simple find/replace of the set random string

Link to comment
Share on other sites

Yes like [underlinetag][nocode]This text has been underlined using [underlinetag][/underlinetag][/nocode][/underlinetag]

 

I would really like a less hacky way of getting it to work. If the strings are pre-chosen there will only be so many of them (bug/limitation). And if somebody puts one or more of them in their post it could really mess stuff up (bug/exploit). So I will have to scan all of the text beforehand, for all of these strings to make sure they aren't in it (performance hit).

I was hoping maybe somebody might be able to work some regex magic for me ^^

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.