Q:

RTE - wrap link based on condition

My TYPO3 website uses TYPO3 6.1 with the included RTE.  What I want to archive is to wrap links with a DIV when a condition (link has class) it met. 
The editor should only do the following:

Create a new text in the RTE (e.g. "My link")
Create a new link for the new Text in the RTE
Select a class for the link (e.g. "myClass")

This results in the following HTML:
<a href="#" class="myClass" title="sometitle">My Link</a>

In the website frontend, I want the user created link to be wrapped with a DIV - but only, if the link has the class "myClass". 
I have tried the following
tt_content.text.20.parseFunc.tags.link.typolink.wrap = <div class="anotherClass">|</div>

which wraps all links with the DIV.  
Is there a way in TS to only wrap the link, when the editor has selected "myClass" for it? 
If not, is there another (editor friendly) way to archive this? 
I have already looked at custom userElements and blockformats, but both seems to be too complicated for the editors, since they have to do more than one operation to create a single link with a special styling. 
My resulting HTML in the frontend should look like this
<div class="anotherClass">
  <a href="#" class="internal-link" title="sometitle">My Link</a>
</div>

My last choise would be to use JQuery - but actually this is'nt a very clean solution so I would prefer a TYPO3/TS solution. 

A:

After some hours of debugging with Typoscript I finally figured out how to solve this issue.  I used a similar technique as shown here http://wiki.typo3.org/External_links
Generelly, I just create a new register containing the class name of the link and then I use the class name to add the wrap to the link. 
lib.parseFunc.tags.link {
  typolink.parameter.append = LOAD_REGISTER
  typolink.parameter.append {
    linkClass {
      cObject = TEXT
      cObject {
        stdWrap.data = parameters:allParams
      }
      # Split link params by space-char.  3rd value is the link class name
      split {
        token.char = 32
        cObjNum = 1||2||3
        3 = TEXT
        3.current = 1        
      }
    }
  }
  newWrap.cObject = CASE
  newWrap.cObject {
    key.data = register:linkClass
    # Set outer wrap for links depending on class name
    default = TEXT
    default.value = |
    myClass = TEXT
    myClass.value = <div class="anotherClass">|</div>
    internal-link = TEXT
    internal-link.value = <div class="anotherClassForInternalLink">|</div>
  }
}

lib.parseFunc_RTE.tags.link {
  typolink.parameter.append < lib.parseFunc.tags.link.typolink.parameter.append
  wrap < lib.parseFunc.tags.link.newWrap
}

Looks wired, but works perfectly :-)

