Differences between version 14 and previous revision of CyberLeo/Syntax.
Other diffs: Previous Major Revision, Previous Author
| Newer page: | version 14 | Last edited on Monday, 20 April 2009 13:33:08 | by CyberLeo | Revert |
| Older page: | version 13 | Last edited on Sunday, 19 April 2009 13:31:15 | by CyberLeo | Revert |
@@ -37,6 +37,66 @@
#include <blah.h>
int main (int argc, char **argv) {
return 0
+}
+</code>
+
+Longopt:
+<code brush="php">
+class Block_code extends Block_pre
+{
+ var $_re = '<code';
+
+ var $brushes = Array(
+ "bash", "shell", "c-sharp", "csharp",
+ "cpp", "c", "css", "delphi", "pas",
+ "pascal", "diff", "patch", "groovy",
+ "js", "jscript", "javascript", "java",
+ "perl", "pl", "php", "plain", "text",
+ "py", "python", "rails", "ror", "ruby",
+ "scala", "sql", "vb", "vbnet", "xml",
+ "xhtml", "xslt", "html", "xhtml");
+
+ function _match (&$input, $m) {
+ $endtag = '</code>';
+ $text = array();
+ $pos = $input->getPos();
+
+ $brush = strtolower(trim(rtrim($m->postmatch, ">")));
+ $pat = "/^brush=[\"']{0,1}(.*?)[\"']{0,1}$/";
+ $mat = preg_match($pat, $brush, $match);
+
+ echo "<pre>";
+ printf("Mat: %s\n", print_r($mat, true));
+ printf("Pat: %s\n", print_r($pat, true));
+ printf("Brush: %s\n", print_r($brush, true));
+ printf("Match: %s\n", print_r($match, true));
+ printf("In: %s\n", print_r(in_array($match[1], $this->brushes), true));
+ echo "</pre>";
+
+ if (0 > preg_match($pat, $brush, $match) && $brush = trim($match[1]) && in_array($brush, $this->brushes))
+ $brush = $brush;
+ else if (in_array($brush, $this->brushes))
+ $brush = $brush;
+ else
+ $brush = "plain";
+
+ printf("Brush: %s<br>\n", print_r($brush, true));
+
+ $line = $input->nextLine();
+ while (ltrim($line) != $endtag) {
+ $text[] = $line;
+ if (($line = $input->nextLine()) === false) {
+ $input->setPos($pos);
+ return false;
+ }
+ }
+ $input->advance();
+
+ $text = join("\n", $text);
+
+ $this->_element = new Block_HtmlElement('pre', array('class' => sprintf('brush: %s;', $brush)), $text);
+ return true;
+ }
}
</code>
version 14
Plugin RawHtml disabled. Raw HTML is only allowed in locked pages.
<?plugin RawHtml
<pre class="brush: c-sharp;">
function test() : String
{
return 10;
}
</pre>
?>
This is sum verbatim shiz. [even wiki links don't work|see] <a href="blah">blah</a>
Naked:
This is a test [wiki|link]
Ruby:
class Blah
def meow
puts arf
end
end
[wiki|link]
C:
#include <blah.h>
int main (int argc, char **argv) {
return 0
}
Longopt:
class Block_code extends Block_pre
{
var $_re = '<code';
var $brushes = Array(
"bash", "shell", "c-sharp", "csharp",
"cpp", "c", "css", "delphi", "pas",
"pascal", "diff", "patch", "groovy",
"js", "jscript", "javascript", "java",
"perl", "pl", "php", "plain", "text",
"py", "python", "rails", "ror", "ruby",
"scala", "sql", "vb", "vbnet", "xml",
"xhtml", "xslt", "html", "xhtml");
function _match (&$input, $m) {
$endtag = '</code>';
$text = array();
$pos = $input->getPos();
$brush = strtolower(trim(rtrim($m->postmatch, ">")));
$pat = "/^brush=[\"']{0,1}(.*?)[\"']{0,1}$/";
$mat = preg_match($pat, $brush, $match);
echo "<pre>";
printf("Mat: %s\n", print_r($mat, true));
printf("Pat: %s\n", print_r($pat, true));
printf("Brush: %s\n", print_r($brush, true));
printf("Match: %s\n", print_r($match, true));
printf("In: %s\n", print_r(in_array($match[1], $this->brushes), true));
echo "</pre>";
if (0 > preg_match($pat, $brush, $match) && $brush = trim($match[1]) && in_array($brush, $this->brushes))
$brush = $brush;
else if (in_array($brush, $this->brushes))
$brush = $brush;
else
$brush = "plain";
printf("Brush: %s<br>\n", print_r($brush, true));
$line = $input->nextLine();
while (ltrim($line) != $endtag) {
$text[] = $line;
if (($line = $input->nextLine()) === false) {
$input->setPos($pos);
return false;
}
}
$input->advance();
$text = join("\n", $text);
$this->_element = new Block_HtmlElement('pre', array('class' => sprintf('brush: %s;', $brush)), $text);
return true;
}
}
