CogNovo SMF v.2.0.14
Category => General discussion => Topic started by: admin on 28. December 2018, 08:32:54
-
This script highlights syntax in code examples on the forum. It i based on "highlight.js" - see https://highlightjs.org/ (https://highlightjs.org/)
The script works automatically, i.e., it finds blocks of code, detects the programming language, highlights it accordingly.
Supported languages include: HTML/XML, Javascript, CSS, PHP, Ruby, Perl, Python, C++, C#, Java, SQL, Bash, etc. pp.
<?php
if ( isset( $_FILES['fupload'] ) ) {
print "name: ". $_FILES['fupload']['name'] ."<br />";
print "size: ". $_FILES['fupload']['size'] ." bytes<br />";
print "temp name: ".$_FILES['fupload']['tmp_name'] ."<br />";
print "type: ". $_FILES['fupload']['type'] ."<br />";
print "error: ". $_FILES['fupload']['error'] ."<br />";
if ( $_FILES['fupload']['type'] == "image/gif" ) {
$source = $_FILES['fupload']['tmp_name'];
$target = "upload/".$_FILES['fupload']['name'];
move_uploaded_file( $source, $target );// or die ("Couldn't copy");
$size = getImageSize( $target );
$imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" ";
$imgstr .= "src=\"$target\" alt=\"uploaded image\" /></p>";
print $imgstr;
}
}
?>
Features:
You can choose code formatting scheme
You can choose font size within code blocks
Highlighting works automatically: finds blocks of code, detects a language, highlights it — you don't need specify any language
URL: https://github.com/dragomano/Code-Highlighting