josephtklein / jwysiwyg

Automatically exported from code.google.com/p/jwysiwyg
GNU General Public License v2.0
0 stars 0 forks source link

How to replace <b> tags with <strong> tags #165

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've tried everything I can think of to get the Bold and Italic buttons to
return <strong> and <em> tags, respectively.  I've deleted the 'b' and 'i'
tags from the TOOLBAR code, so it now reads:

  bold : { visible : true, tags : ['strong'], tooltip : "Bold" },
  italic : { visible : true, tags : ['em'], tooltip : "Italic" },

Miraculously, this still inserts <b> and <i> tags into my code. Can anyone
tell me where these tags can possibly be coming from?

I'm using version 0.6 on MacOS 10.6.2

Original issue reported on code.google.com by nsfreri...@gmail.com on 25 Feb 2010 at 4:53

GoogleCodeExporter commented 9 years ago
I would also like to know how to make the B and I buttons to return different 
tags,
like [b], [strong] and [i] when posting instead of , <strong> and <i>/<em>.

Original comment by bakke...@gmail.com on 27 Feb 2010 at 7:43

GoogleCodeExporter commented 9 years ago
yeah, I need to change the , <strong>, and <i>, ect to [b], [strong] and [i] to
integrate it to my forum

Original comment by phamluu...@gmail.com on 1 Mar 2010 at 5:32

GoogleCodeExporter commented 9 years ago
I found a solution by adapting the fix for replacing <BR> and <br> tags with the
proper <br /> --- see Issue 53.  Here's my adapted code to get the <strong> and 
<em>
tags working:

Lines 594-596 currently state:

        getContent : function()
        {
            return $( $(this.editor).document() ).find('body').html();

Change them to this:

        getContent : function()
        {
            var markup = $( $(this.editor).document() ).find('body').html();
            return markup.replace('', '<strong>').replace('',
'</strong>').replace('<i>', '<em>').replace('</i>', '</em>').replace(/<br>/g, 
'<br
/>').replace(/<BR>/g, '<br />');

        },

PLEASE NOTE: If you change to the <br /> tags, you will also need to change the 
math
in lines 612-616 to subtract 6 instead of 4, like so:

                if ( this.options.rmUnwantedBr )
        {
                    content = ( content.substr(-6) == '<br />' ) ? content.substr(0,
content.length - 6) : content;
        }

Original comment by nsfreri...@gmail.com on 1 Mar 2010 at 2:37

GoogleCodeExporter commented 9 years ago
Also on lines 612-616, don't forget to change the current <br> to <br />.

Original comment by nsfreri...@gmail.com on 1 Mar 2010 at 2:42

GoogleCodeExporter commented 9 years ago
Unfortunately if you adopt the fix suggested by nsfrerichs and then try to edit 
again the text, you won't be able to remove bold and the italic inserted before.

The quick and dirt solution I use is to replace this tags (before saving 
b->strong and then again before editing strong->b) via php.

Original comment by l.biag...@gmail.com on 17 Aug 2010 at 6:30