Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create a tiny version of TGML?

Status
Not open for further replies.

grtfercho

Programmer
Apr 11, 2003
424
US
We a have a ticketing system that handles requests and follows up on the status of the request. There is a section where one can enter details about the solution.
The problem is that when somebody posts some CFML or HTML code as part of the solution then the page actually renders those comments as part of the underlying CFML/HTML code.

My solution for that using CF would be just to wrap things around a HTMLCodeFormat(). However I would like to go a step further and actually insert metatags just like we do here in Tek-tips with the
Code:
 metatag. 
I came up with some ideas for this but It started to get more complicated than what it needs to be. 

Anybody has any idea on how to create something similar to the TGML we all use here??

There is a small twist. Here in Tek_tips we cannot reopen a post and edit it. So the actual formatting can be saved directly to the tables. This means that the TGML tag "[ code]" once transformed into the following lines
<div id="code">
  <h4>Code</h4>
  <div class="body">
      The code goes here.
  </div>
</div>
can be safely saved as part of the whole post.


In my case the comments can be edited. So I should save the actual metatag [ code] along with the comments, that way next time somebody tries to edit the contents they don't see different code than what they inserted.

I hope that's clear. If not I can always be more descriptive.

Thanks in advance...


[b]grtfercho çB^]\..[/b]
[i]"Imagination is more important than Knowledge"[/i] A. Einstein
-----------------------------------------------
[URL unfurl="true"]www.llajta.com[/URL]
 
This has been an off and on again project of mine for a while.. Its something I want to put on my site but it involves some pretty wicked regex..

You have two options.. The first is probably the simplest..

Code:
<cfset msgcode="My <b>text</b> is [code]<b>bold</b> but not <i>italic</i>[ /code]">
(You'll have to remove the space in the [ /code] above.. and a few lines below)
<cfset msgcode=replacenocase(msgcode,"[code]","<pre>","ALL")>
<cfset msgcode=replacenocase(msgcode,"[ /code]","</pre>","ALL")>

Seems pretty basic..

Your other option is

I will say I've looked pretty in-depth at that and that seems to use a lot of senseless overhead.. So I started writing my own, but while what mine has got so far runs a lot faster.. The one this his has on mine is that.. well.. its complete :)

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks for the link. I'm checking it out right now.
As far as reg expressions and using the ReplaceNocase I've tried initially but then I started adding nested
Code:
 tags and the output was funky. 
For example if one opens a [code] tag but does not close it. or if you close it twice ... since I'm working on a XHTML environment leaving unclosed tags in the code is not an option. 
I was thinking of doing a count of all the places where I find [code] and [ /code] then if things are even  apply the replace function otherwise come up with some smart way of matching opening/closing tags.

Any new ideas, improvements, links, websites or pointers are still welcome...
Thanks..



[b]grtfercho çB^]\..[/b]
[i]"Imagination is more important than Knowledge"[/i] A. Einstein
-----------------------------------------------
[URL unfurl="true"]www.llajta.com[/URL]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top