diff --git a/tools/website/drupal/fromfile.module b/tools/website/drupal/fromfile.module index db904e18..e1e571c5 100644 --- a/tools/website/drupal/fromfile.module +++ b/tools/website/drupal/fromfile.module @@ -105,9 +105,18 @@ function fromfile_page() { } // done - drupal_set_title($title); drupal_set_breadcrumb($breadcrumbs); - return $content; + // view as a node + $node = array( + 'title' => $title, + 'body' => $content, + 'created' => 0, + 'links' => FALSE, + 'name' => '', + 'nid' => '' + ); + //return node_view((object)$node, FALSE, TRUE); + return theme('node', (object)$node, FALSE, TRUE); } diff --git a/tools/website/drupal/mse-drupal-modules/autoformat.inc b/tools/website/drupal/mse-drupal-modules/autoformat.inc index 524bbb24..adba00ac 100644 --- a/tools/website/drupal/mse-drupal-modules/autoformat.inc +++ b/tools/website/drupal/mse-drupal-modules/autoformat.inc @@ -53,9 +53,12 @@ function autoformat__handle(&$i, $prefix, $first, $fail_same = false) { $current_prefix .= ' '; } + //$line = $line . '{' . $current_prefix . '|' . strlen($prefix) . substr($oldline, 0, strlen($prefix)) . '}'; + // Determine line type if (strlen($oldline) < strlen($prefix)) { // empty line => break out of this level + $i--; if ($state == '|') $text .= autoformat__table($table); return $text; } else if ($line == '') { @@ -128,7 +131,15 @@ function autoformat__handle(&$i, $prefix, $first, $fail_same = false) { // source code if ($state == '>') $text = substr($text,0,-6); else $text .= '
';
- $text .= syntax_highlight(htmlspecialchars(substr($line, 1)));
+ if (substr($line,0,4)=='>>>>') { // always code, not escaped
+ $text .= highlight_script(substr($line, 4));
+ } else if (substr($line,0,3)=='>>>') { // not escaped
+ $text .= syntax_highlight(substr($line, 3));
+ } else if (substr($line,0,2)=='>>') { // always code
+ $text .= highlight_script(htmlspecialchars(substr($line, 2)));
+ } else {
+ $text .= syntax_highlight(htmlspecialchars(substr($line, 1)));
+ }
$text .= "\n";
$state = '>';
} elseif ($line{0} == ']') {
@@ -142,7 +153,7 @@ function autoformat__handle(&$i, $prefix, $first, $fail_same = false) {
// Html
} elseif (preg_match("@^?(pre|ul|ol|li|div|blockquote|>)@", $line)) {
$line = preg_replace("@^<>@","",$line);
- $text .= $line;
+ $text .= $line . "\n";
$state = '';
// Just text
diff --git a/tools/website/drupal/mse-drupal-modules/highlight.inc b/tools/website/drupal/mse-drupal-modules/highlight.inc
index 80fef453..d8e4e972 100644
--- a/tools/website/drupal/mse-drupal-modules/highlight.inc
+++ b/tools/website/drupal/mse-drupal-modules/highlight.inc
@@ -54,21 +54,35 @@ function highlight_reader($code) {
function highlight_script($code) {
$ret = '';
+ $string = '';
while(strlen($code)) {
- if (preg_match("@^(if|then|else|for|in|do|and|or|xor|not|rgb)\b@",$code, $matches)) {
+ if (preg_match("@^<[^>]+>@",$code, $matches)) {
+ $ret .= $matches[0]; // plain tag
+ } else if (preg_match("@^(if|then|else|for|in|do|and|or|xor|not|rgb)\b@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
} else if (preg_match("@^(include file:)(.*)@",$code, $matches)) {
$ret .= "" . $matches[1] . "" . $matches[2];
} else if (preg_match("@^([0-9][0-9.]*|true|false)@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
- } else if (preg_match("@^(\"|")(\\\\.|[^\\\\])*?(\"|")@",$code, $matches)) {
- $ret .= "" . $matches[0] . "";
+// } else if (preg_match("@^(\"|")(\\\\.|[^\\\\])*?(\"|")@",$code, $matches)) {
+// $ret .= "" . $matches[0] . "";
+ } else if (preg_match("@^(\"|")(\\\\.|[^\\\\{])*?(\"|"|{)@",$code, $matches)) {
+ $ret .= "" . highlight_script_string($matches[0]) . "";
+ if ($matches[3] == '{') $string .= 's';
+ } else if ($string != '' && $string{strlen($string)-1}=='s' &&
+ preg_match("@^}(\\\\.|[^\\\\{])*?(\"|"|{)@",$code, $matches)) {
+ // return from string quote
+ $ret .= "" . highlight_script_string($matches[0]) . "";
+ $string = substr($string,0,-1);
+ if ($matches[3] == '{') $string .= 's';
} else if (preg_match("@^\\#.*@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
} else if (preg_match("@^([-+*/=!.]|<|>)+|^:=@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
- } else if (preg_match("@^[\\(\\)\\[\\]{},]+@",$code, $matches)) {
+ } else if (preg_match("@^([}]|[\\(\\)\\[\\]{,]+)@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
+ if ($matches[0] == '{') $string .= 'p';
+ elseif ($matches[0] == '}') $string = substr($string,0,-1);
} else if (preg_match("@^[a-zA-Z_][a-zA-Z0-9_]*:@",$code, $matches)) {
$ret .= "" . $matches[0] . "";
} else if (preg_match("@^([a-zA-Z0-9_]+\s*|\s+|?[a-zA-Z0-9]+;)@",$code, $matches)) {
@@ -84,5 +98,9 @@ function highlight_script($code) {
}
return $ret;
}
+function highlight_script_string($code) {
+ $code = preg_replace("@<.*?(>|>)@", "\\0", $code);
+ return $code;
+}
?>
\ No newline at end of file