Syntax Highlighter aka Highlighted Code Block

0

Modifying the Syntax Highlighter

The out-of-the-box Syntax Highlighter requires scrolling to see all the options when you add the block. If you open the form.php file the second line contains the code controlling the hight of the textarea. Simply change the height of the textarea from 350px to 250px and that will cure that problem. The Syntax Highlighter block below shows the corrected code.

<?php echo t('Code')?><br/>
<textarea name="code" style="width:560px;height:250px;">
<?php echo $code?>
 public function getLanguages() {
    return array(
      ...
      'css" selected="selected' => 'CSS',
      'd' => 'D',
      'dcs' => 'DCS',

Changing the default language

Another change I made is to the controller.php file. the default language for me will be css so I moved the "selected" marker from php to css as shown below. Now when I create and new instance of this block, my default language is css. Again, below is the pertinent code.

Additional Styling with css

Below is the css used to set the yellow background on all the Syntax Highlighter blocks on this site (unless otherwise overridden).

div.ccm-syntax-highlighter {
	padding: 12px;
	background-color: #fdffce;
	border: 1px solid #cbcbcb;
	margin-bottom: 12px;
}

You can download Remo's indispensable Syntax Highlighter aka Highlighted Code Block here.

protected $pkgHandle = 'new_object';
	protected $appVersionRequired = '5.4.0';
	protected $pkgVersion = '1.0';
 
	public function getPackageDescription() {
		return t('Easily add/update objects and connect with them using the c5 API.');
	}
 
	public function getPackageName() {
		return t('New Object Database');
	}
 
	public function install() {
		$pkg = parent::install();
 
		$allowSets = false;
		$akc = AttributeKeyCategory::add('new_object', $allowSets, $pkg);
		for($i=1; $i<9; $i++) {
			$akc->associateAttributeKeyType(AttributeType::getByID($i));
		}