diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2015-03-17 19:53:49 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2015-03-17 19:53:49 +0100 |
| commit | 81554f1309cc6a80578100b9583a591012df0d43 (patch) | |
| tree | e02c44cdca8fcf5cb06289ceb0ba20be3ae658f9 /lib | |
| parent | e19fc06310e26dab3ec372fb01676a802fc02234 (diff) | |
| download | grauphel-81554f1309cc6a80578100b9583a591012df0d43.tar.gz grauphel-81554f1309cc6a80578100b9583a591012df0d43.zip | |
standlone HTML output
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/converter/cleanhtml.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/converter/cleanhtml.php b/lib/converter/cleanhtml.php new file mode 100644 index 0000000..6c5dabf --- /dev/null +++ b/lib/converter/cleanhtml.php @@ -0,0 +1,70 @@ +<?php +/** + * Part of grauphel + * + * PHP version 5 + * + * @category Tools + * @package Grauphel + * @author Christian Weiske <cweiske@cweiske.de> + * @copyright 2014 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @link http://cweiske.de/grauphel.htm + */ +namespace OCA\Grauphel\Converter; +use \XMLReader; + +/** + * Convert Tomboy note XML to HTML that can be used (nearly) standalone. + * This means it tries to use as many native tags as possible and + * does not rely on classes so much. + * + * @category Tools + * @package Grauphel + * @author Christian Weiske <cweiske@cweiske.de> + * @copyright 2014 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @version Release: @package_version@ + * @link http://cweiske.de/grauphel.htm + */ +class CleanHtml extends Html +{ + protected static $tagMap = array( + 'list' => 'ul', + 'list-item' => 'li', + 'bold' => 'b', + 'italic' => 'i', + 'monospace' => 'tt', + + 'size:large' => 'h3', + 'size:huge' => 'h2', + + 'strikethrough' => 'del', + 'highlight' => 'ins', + ); + + protected static $styleClassMap = array( + 'size:small' => 'small', + ); + + /** + * Converts the tomboy note XML into HTML. + * Cleans HTML a bit up after it has been generated with the clean tags. + * + * @param string $xmlContent Tomboy note content + * + * @return string HTML + */ + public function convert($xmlContent) + { + $html = parent::convert($xmlContent); + $html = str_replace('</h2><br />', '</h2>', $html); + $html = str_replace('</h3><br />', '</h3>', $html); + $html = str_replace("<br />\n</h2>", "</h2>\n", $html); + $html = str_replace("<br />\n</h3>", "</h3>\n", $html); + $html = str_replace("<br />\n</li>", "</li>\n", $html); + $html = str_replace("<br />\n<ul>", "<ul>\n", $html); + return $html; + } +} +?> |
