From: <var...@us...> - 2014-11-08 16:20:08
|
Revision: 9288 http://sourceforge.net/p/phpwiki/code/9288 Author: vargenau Date: 2014-11-08 16:20:04 +0000 (Sat, 08 Nov 2014) Log Message: ----------- Only one dialect: Phpwiki; PHP Doc Modified Paths: -------------- trunk/lib/HtmlParser.php Modified: trunk/lib/HtmlParser.php =================================================================== --- trunk/lib/HtmlParser.php 2014-11-08 16:15:14 UTC (rev 9287) +++ trunk/lib/HtmlParser.php 2014-11-08 16:20:04 UTC (rev 9288) @@ -45,18 +45,9 @@ { public $dialect, $_handlers, $root; - /** - * dialect: "PhpWiki2", "PhpWiki" - * possible more dialects: MediaWiki, kwiki, c2 - */ - function __construct($dialect = "PhpWiki2", $encoding = '') + function __construct($dialect, $encoding = '') { - $classname = "HtmlParser_" . $dialect; - if (class_exists($classname)) - $this->dialect = new $classname; - else { - trigger_error(sprintf("unknown HtmlParser dialect %s", $dialect), E_USER_ERROR); - } + $this->dialect = new HtmlParser_PhpWiki(); $this->_handlers =& $this->dialect->_handlers; $this->XmlParser($encoding); xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0); @@ -83,6 +74,11 @@ return $output; } + /** + * @param HtmlElement $node + * @param HtmlElement $parent + * @return string + */ function wikify($node, $parent = null) { $output = ''; @@ -116,12 +112,15 @@ return $output; } - /** elem_contents() + /** * $output = $parser->elem_contents( $elem ); * Returns a wikified version of the contents of the specified * HTML element. This is done by passing each element of this * element's content list through the C<wikify()> method, and * returning the concatenated result. + * + * @param HtmlElement $node + * @return string */ function elem_contents($node) { @@ -185,6 +184,10 @@ // contained within a sole A tag (not counting child elements with // whitespace text only). // + /** + * @param HtmlElement $node + * @return bool + */ function _elem_is_image_div($node) { // Return false if node is undefined or isn't a DIV at all @@ -203,14 +206,22 @@ return false; } - /** preserves tags and content + /** + * preserves tags and content + * + * @param HtmlElement $node + * @return mixed */ function wikify_default($node) { return $this->wikify_preserve($node); } - /** preserves tags and content + /* + * preserves tags and content + * + * @param HtmlElement $node + * @return mixed */ function wikify_preserve($node) { @@ -222,9 +233,11 @@ } } -class HtmlParser_PhpWiki2 +class HtmlParser_PhpWiki extends HtmlParser { + public $ident; + function __construct() { $this->_handlers = @@ -281,17 +294,29 @@ ); } + /** + * @param HtmlElement $node + * @return string + */ function wikify_table($node) { $this->ident = ''; return "| \n" . $this->elem_contents($node) . "|\n\n"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_tr($node) { return "\n| " . $this->elem_contents($node); } + /** + * @param HtmlElement $node + * @return string + */ function wikify_th($node) { $ident = empty($this->ident) ? '' : $this->ident; @@ -303,11 +328,19 @@ return "$output |\n"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_list_item($node) { return ($this->_elem_has_ancestor($node, 'ol') ? '*' : '#') . " " . trim($this->elem_contents($node)) . "\n"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_link($node) { $url = $this->absolute_url($node->getAttr('href')); @@ -331,6 +364,10 @@ return "[ $url | $title ]"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_h($node) { $level = substr($node->_tag, 1); @@ -342,17 +379,29 @@ return $markup . ' ' . trim($this->elem_contents($node)) . "\n\n"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_verbatim($node) { $contents = $this->elem_contents($node); - return "\n<verbatim>\n$contents\n</verbatim>"; + return "\n<".'verbatim'.">\n$contents\n</"."verbatim>"; } + /** + * @param HtmlElement $node + * @return string + */ function wikify_noinclude($node) { return $this->elem_contents($node); } + /** + * @param HtmlElement $node + * @return string + */ function wikify_img($node) { $image_url = $this->absolute_url($node->getAttr('src')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2021-09-20 10:13:25
|
Revision: 10584 http://sourceforge.net/p/phpwiki/code/10584 Author: vargenau Date: 2021-09-20 10:13:23 +0000 (Mon, 20 Sep 2021) Log Message: ----------- Remove useless local variable Modified Paths: -------------- trunk/lib/HtmlParser.php Modified: trunk/lib/HtmlParser.php =================================================================== --- trunk/lib/HtmlParser.php 2021-09-20 10:11:20 UTC (rev 10583) +++ trunk/lib/HtmlParser.php 2021-09-20 10:13:23 UTC (rev 10584) @@ -72,8 +72,7 @@ { if (is_null($this->root)) $this->root = $GLOBALS['xml_parser_root']; - $output = $this->wikify($this->root); - return $output; + return $this->wikify($this->root); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-01-19 14:40:38
|
Revision: 10909 http://sourceforge.net/p/phpwiki/code/10909 Author: vargenau Date: 2022-01-19 14:40:36 +0000 (Wed, 19 Jan 2022) Log Message: ----------- lib/HtmlParser.php: oups, wrong semi-colon Modified Paths: -------------- trunk/lib/HtmlParser.php Modified: trunk/lib/HtmlParser.php =================================================================== --- trunk/lib/HtmlParser.php 2022-01-18 17:01:26 UTC (rev 10908) +++ trunk/lib/HtmlParser.php 2022-01-19 14:40:36 UTC (rev 10909) @@ -426,8 +426,8 @@ // then we'll add it to the [Image] syntax if (!$alignment and preg_match("/float\:\s*(right|left)/i", $css_style, $m)) $alignment = $m[1]; - if (!$alignment and preg_match("/float(right|left)/i", $css_class, $m)) ; - $alignment = $m[1]; + if (!$alignment and preg_match("/float(right|left)/i", $css_class, $m)) + $alignment = $m[1]; if ($alignment) { $attrs[] = "class=align-$alignment"; $this->log(" Image is contained within a DIV that specifies $alignment alignment"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |