protected static function build($filename, HTML_Builder $builder)
 {
     $pconf = new Project_Config();
     if (isset($pconf->templates['remote_parser']) && $pconf->templates['remote_parser']) {
         $parser = new Remote_HTML_Parser($pconf->templates['remote_parser'], $builder);
     } else {
         $parser = new HTML_Parser($builder);
     }
     $parser->parse($filename);
     return $parser->build();
 }
Ejemplo n.º 2
0
 function HtmlToMarkdown($Html, $FormatHtml = False)
 {
     if (!class_exists('HTML_Parser', False)) {
         define('HTML2MD_HEADER_STYLE', 'ATX');
         define('HTML2MD_SUPPRESS_ERRORS', True);
         define('HTML2MD_NEWLINE', "\n");
         require_once USEFULFUNCTIONS_VENDORS . '/html2markdown.php';
     }
     if ($FormatHtml) {
         $HtmlFormatter = Gdn::Factory('HtmlFormatter');
         if ($HtmlFormatter) {
             $Html = $HtmlFormatter->Format($Html);
         }
     }
     $HtmlParser = new HTML_Parser($Html);
     $Result = $HtmlParser->get_markdown();
     return $Result;
 }
Ejemplo n.º 3
0
 function _process_tag(&$content, $tag_html)
 {
     // Parse tag
     $parser = new HTML_Parser();
     $output = $parser->parse($tag_html);
     // XML Error?
     if ($parser->xml_error == true) {
         $error = 'XML Error: ' . $parser->xml_error_string . ' on line ' . $parser->xml_error_line_number;
         $content = str_replace($html, $error, $content);
         return false;
     }
     // Get tag structure and innerHTML
     $tag = $output['0'];
     $innerHTML = $tag['innerhtml'];
     // Check array attribute
     if (empty($tag['attr']['ARRAY'])) {
         // No array, return error
         $error = 'Array attribute not set - unable to use Repeater Control';
         $content = str_replace($tag_html, $error, $content);
         return false;
     }
     $array = $tag['attr']['ARRAY'];
     // Check if array exists
     if (!isset($this->_arrays[$array]) or !is_array($this->_arrays[$array])) {
         // No array, return error
         $error = 'Invalid array, not binded - unable to use Repeater Control';
         $content = str_replace($tag_html, $error, $content);
         return false;
     }
     // Loop through array
     $new_html = '';
     foreach ($this->_arrays[$array] as $key => $value) {
         // Copy innerHTML
         $html = $innerHTML;
         // Parse children
         $html = $this->_parse_subtags($html, $tag, $key, $value);
         $new_html .= $html;
     }
     // Replace custom tag with new HTML
     $content = str_replace($tag_html, $new_html, $content);
 }
Ejemplo n.º 4
0
 protected function parse_hierarchy($self_close = null)
 {
     $tag_curr = strtolower($this->status['tag_name']);
     if ($self_close === null) {
         $this->status['self_close'] = $self_close = isset($this->tags_selfclose[$tag_curr]);
     }
     if (!($self_close || $this->status['closing_tag'])) {
         $tag_prev = strtolower($this->hierarchy[count($this->hierarchy) - 1]->tag);
         if (isset($this->tags_optional_close[$tag_curr], $this->tags_optional_close[$tag_curr][$tag_prev])) {
             array_pop($this->hierarchy);
         }
     }
     parent::parse_hierarchy($self_close);
 }
Ejemplo n.º 5
0
 function html2markdown($html)
 {
     $parser = new HTML_Parser($html);
     return $parser->get_markdown();
 }