Configuring .hthtml
The .hthtml file should be located at the virtual host root directory if SiteSupra was copied to the server successfully.
The .hthtml file configures user-defined filters for xHTML Editor.
The filters may remove unnecessary tags and attributes after you copied a text from a MS Word or Excel file.
You can use the filters to make replacements in the text, for example, you can remove extra line breaks or replace two   entities with one, and so on.
The filters are working in the following order:
- userFilterInHTML filter runs when text is loaded into the editor.
- userFilterElement filter runs after you clicked Ok in the xHTML Editor window to save the text. In addition, the filter runs every time you switch between HTML and text modes.
- userFilterOutHTML filter runs after userFilterElement only when the editor window is closing.
userFilterInHTML
function userFilterInHTML(html) { html = html.replace((/<a name=("*)([^>"]*)("*)><^/a>/gi, '{AN:$2}'); // replaces anchors <a name="xxx"></a> to {AN:xxx} return html; }
|
userFilterElement
function userFilterElement(el) { switch(el.tagName) { case "DIV": // removes <div> el.removeNode(); break; }
if(el.tagName != 'IMG') el.removeAttribute("style"); // removes style attribute for al tags excepting <img>
el.removeAttribute("className"); // removes class attribute }
|
userFilterOutHTML
function userFilterOutHTML(html) { // Replacing MS Word specific characters html = html.replace(/⬘/gi, "'"); html = html.replace(/â¬Ģ/gi, "'"); html = html.replace(/⬜/gi, '"'); html = html.replace(/â¬/gi, '"'); html = html.replace(/⬞/gi, '"'); html = html.replace(/‑/gi, '–'); html = html.replace(/âÀ"/gi, '–'); html = html.replace(/â¬"/gi, '—'); html = html.replace(/<(/)?strong/gi, '<$1b'); // replaces <strong> to <b> html = html.replace(/<(/)?em/gi, '<$1i'); // replaces <em>to <i> html = html.replace(/( )+/g, ' '); // replaces more than one to one html = html.replace(/ /g, ' '); // replaces and space combination to single space html = html.replace(/ /g, ' '); // replaces two spaces to one space html = html.replace(/ </b>/g, '</b> '); // repalces space</b> to </b>space html = html.replace(/ </i>/g, '</i> '); // replaces space</i> to </i>space html = html.replace(/ </a>/g, '</a> '); // replaces space</a> to </a>space html = html.replace(/{AN:([^}]*)}/g, '<a name="$1"></a>'); // replaces {AN:xxx} to <a name="xxx">...</a> html = html.replace(/href="/#/gi, 'href="#'); return html; }
|
The .hthtml file has another useful option that allows you to add buttons into the XHTML editor window and assign your functions to them.
<? $htmlFilters = Array( 'Bold SiteSupra' => Array( 'func' => 'myF1()', // function to call 'icon' => 1, // number on the button's icon 'key' => 'CTRL+SHIFT+1' // shortcut keys ), 'Insert User Text' => Array( 'func' => 'myF2()', 'icon' => 2, 'key' => 'CTRL+SHIFT+2', ) ); ?>
|
| Please login to add comments. |
|
|