5

The question pretty much says it all. Im using hallo.js and it seems to use <b> and <i> for bold and italic. Some of my markup currently requires strong and em in order to have certain CSS rules apply. I also prefer strong and em in general to b and i so Id like to configure this.

There doesnt seem to be any documentation on this directly - can it be done?

prodigitalson
  • 60,050
  • 10
  • 100
  • 114

2 Answers2

4

In case it might help somebody:

I wanted to achieve the same and I've ended up pre-processing the content before saving it. Example of replacing tags for in Python:

content.replace('<b>', '<strong>').replace.('</b>', '</strong>')    

You could use the same technique for any other tags or substrings you might wanna replace.

Jordi
  • 886
  • 11
  • 11
3

This can't be done as the markup is not up to hallo.js or any other rich text editor. They just trigger inserting markup, but the inserting is done by the browser. You will get slightly different results from different browsers. A workaround is possible only by changing the markup at the end.

Edit for point to docs on comment question: The problem is that this is behavior of browsers since IE invented design mode without being a standard. The whatwg wrote it in the standard for HTML5. To get more information on the topic itself read
http://www.quirksmode.org/dom/execCommand.html
http://dev.opera.com/articles/view/rich-html-editing-in-the-browser-part-1/
http://www.thismuchiknow.co.uk/?p=64
http://www.whatwg.org/specs/web-apps/2007-10-26/multipage/section-contenteditable.html
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
http://www.w3.org/wiki/Web_Editing_APIs
http://annevankesteren.nl/2005/07/contenteditable
http://www.sitepoint.com/the-tragic-comedy-that-is-rich-text-editing-on-the-web/

Andreas
  • 1,220
  • 8
  • 21
  • Can you point me to some docs that make this clear? I didnt realize the actual markup was an internal operation of the browser, i thought only the editing facility was. – prodigitalson Apr 04 '13 at 17:20
  • It can be done if you manipulate the DOM yourself rather than relying on `document.execCommand()`. CKEditor does that, for example. – Tim Down Apr 08 '13 at 16:42
  • @Tim Down: No, it can't be done, because the question wasn't on programming an own rich text editor but using hallo.js and that uses execCommand. Your are right that mentioning "any other rich text editor" is not correct for those manipulating the DOM directly. – Andreas Apr 09 '13 at 06:48