I have tried adding some anchor tags using the editor and cant work out how to do it.. whenever I put them in, it creates a link with a space in there, eg:
<a name="name-of-link"> </a>
Is there a reason for this or a way to stop it?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I have tried adding some anchor tags using the editor and cant work out how to do it.. whenever I put them in, it creates a link with a space in there, eg:
<a name="name-of-link"> </a>
Is there a reason for this or a way to stop it?
I think this a TinyMCE issue rather then a SilverStripe one. TinyMCE is set to not accept emty tags like that, so it'll add a non-breakable space to it. If you really want it removed you should probably look on the TinyMCE forums...
But on some browsers an empty anchor tag wouldn't even work. Would it be a good idea to move the anchor to a spot where the space doesn't hurt, like at the end of an article title?
I have a similar problem where the anchor tags are showing an underlined space.
html produced by tinymce/ss insert link:
<h2><a name="myanchor"> </a>My heading here</h2>
_My heading here
An anchor tag is just another <a>...</a> tag and by default these appear underlined, even for spaces... So apart from getting rid of the added $nbsp; all together, you'll probably have to handle this in css.
Btw: you can disable the automatic addition of the nonbreakable space from an empty anchor. In cms/config.php:
valid_elements' => "@[id|class|style|title],#a[id|rel|...
becomes
valid_elements' => "@[id|class|style|title],a[id|rel|...
But (some?) browsers will now show the text to the right of the anchor as a link, thinking you must have misplaced the anchor's end tag - all this apart from the discussion that there shouldn't be any empty tags in HTML. Replace the with a <!-- anchor --> will not work: /sapphire/javascript/tinyMCE_improvements.js->sapphiremce_cleanup() will strip them out. So again, wherever possible I just put my anchors to the right of the text...