Skip Navigation
Expand
Modifications to the HTML source of documents
Answer ID 2673   |   Last Review Date 02/27/2019

Why does the HTML source of my document get reformatted when I save or toggle between source and design modes?

Environment:

HTML Document Editor
Answers, Mailings, Documents, All versions

Resolution:

The reason you may see changes in html formatting is due to the use of a utility called Tidy.  It is not possible to disable Tidy in the Oracle B2C Service application.

In versions 18A+ HTML is able to be saved directly from Source mode in the answer editor. In these versions Tidy is still used however when toggling between Design and Source mode. For example when an agent switches modes from Source -> Design -> Source, Tidy will perform the reformatting. 

Documents in Oracle B2C Service are stored as XHTML, which is an HTML/XML (“eXtensible Markup Language”) hybrid. The HTML heritage of XHTML documents allows the use of standard markup tags to specify how documents should be presented in an end-user’s browser. Its XML heritage affords the ability to define the custom tags from which Outreach and Feedback derive most of their power and utility. Reliably storing and processing these documents is much more straightforward with XHTML as opposed to using plain HTML.

As an XML document, an XHTML document must meet a stricter set of requirements than HTML documents do. The way we ensure that documents are XML-compliant is by running them through the utility Tidy, a de facto industry standard software tool that cleans up HTML and offers a conversion into XHTML. A partial list of modifications that Tidy makes in the HTML-to-XHTML conversion process follows:

1.  It adds a DOCTYPE declaration, which indicates which XHTML specification the document uses. Three XHTML specifications are available: strict, transitional, and frameset. When a fresh document is created from the HTML editor, the DOCTYPE defaults to XHTML strict. If HTML is copied-and-pasted into the HTML editor's source mode, the DOCTYPE defaults to XHTML transitional. Oracle B2C Service does not use the frameset DOCTYPE.

2.  It makes sure that tags are properly closed, when necessary. For example, when a new paragraph is opened with the <p>, it must be closed with </p>.  Web browsers are forgiving when closing tags are omitted, and will make best guesses as to what the document author intended. XML, on the other hand, is more stringent by requiring that all tags be closed.

3.  It forces all tags into lower case. HTML is case-insensitive and treats <p> and <P> as the same tag. Alternatively, XML is case sensitive and will not allow a <p> tag used with </P>.

There are three times that Oracle B2C Service runs Tidy on a document: when the user switches from design to source mode (or vice-versa), when a document is saved, and when a parse error is detected.

In the case of parse errors, the editor brings up a dialog window that highlights any problem:

Clicking on the “Close” button simply dismisses the dialog. Clicking the “Repair” button runs Tidy on the XHTML source code so that it parses successfully. In this case, repairing the document will change the erroneous </P> tag to </p> so that it correctly closes the opening <p>. 


NOTE: If a particular Message Template does not use the Global Template, when the user switches from source mode to design mode and back, the following code will be added and wrapped arround the existing source code of the message template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rn="http://schemas.rightnow.com/crm/document" lang="en">
<head>
<title></title>
<meta content="text/html; charset=UTF-8" />
</head>
<body style="background-color: #FFF;">

Existing source code of the message template

</body>
</html>


To apply or remove the global template to a specific message template, toggle the Template button on the ribbon while the particular Message Template is open for editing. If the Global Template is applied to the Message template, the above piece of code is removed, because the code is already included in the Global Template.

There are times when Tidy will not be able to repair a document. For example, Tidy is generally unable to insert namespace declarations that support custom tags. Names of Oracle B2C Service custom tags are prefixed with “rn:”, and are supported by the namespace declaration
xmlns:rn="http://schemas.rightnow.com/crm/document”.

This declaration is an attribute of the <html> element, and tells the parser that tags bearing an “rn” prefix need to meet the requirements found at http://schemas.rightnow.com/crm/document. If it’s missing, an XML parse error will result.

In this case, asking Tidy to repair the document is ineffective, since it has no idea how to resolve an “rn”-prefixed tag. Missing namespace declarations need to be fixed manually, in this case by changing the <html> declaration to read

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:rn="http://schemas.rightnow.com/crm/document">


Related Configuration Settings

HTML_TIDY_BLOCK_TAGS - Specifies new block-level tags. This option takes a space or comma separated list of tag names. Unless new tags are declared, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note: The content model for elements such as <TABLE>, <UL>, <OL> and <DL> cannot be changed. Default is blank.


HTML_TIDY_EMPTY_TAGS - Specifies new empty inline tags. This option takes a space or comma separated list of tag names. Unless new tags are declared, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Empty tags must also be declared as either inline or block-level. Default is blank.


HTML_TIDY_ENFORCE_XHTML - Specifies whether content in HTML editors must meet XHTML compliance.  If enabled, the editor will clean HTML code to meet the specification.  This also results in adding XHTML doctype declarations to the resulting documents.  If disabled, any content that is valid XML will not be cleaned upon saving the content.  Default is enabled (Yes).


HTML_TIDY_INLINE_TAGS - Specifies new non-empty inline tags. This option takes a space or comma separated list of tag names. Unless new tags are declared, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Default is blank.

Path to setting(s): Select Configuration from the navigation area > Site Configuration > Configuration Settings > and search by Key.