|
Archive /
CodeBlockQuestionI already tried Beautifier? to perform syntax highlighting for source code but I want also:
Could you help me? Answer This recipe is obsoleted by the SourceBlock? recipe. --Dfaure
Yes, you'll need:
DiscussionCodeBlock is based on Beautifier? cookbook recipe. Once installed, it adds markup of the form
where optional parameters:
Installation
In your include_once('cookbook/codeblock.php');
There's no need to include the For more control over the appearance of the formatted code (as does the Beautifier? recipe), you may wish to set You may also set MarkupTo enter source code into PmWiki, use the following markup:
The markup don't need to start a new line, and may be appended to list elements without altering their order:
In order to allow the appearance tweaking of the block via a stylesheet, the formatted output of Beautifier is placed into a Here's a nice one: .codeblock {
padding: 0 0.5em;
text-align: center; }
.codeblock pre {
line-height: 1;
border: 1px solid #808080;
background-color: white;
text-align: left;
padding: 0.5em 10px; }
.codeblock pre .codeblock_ln {
color: #808080; }
CaveatFor now, when forcing word-wrapping of syntaxically highlighted code, original line numbers couldn't be preserved as without any language specification. Contributors--Dfaure, and all the previous Beautifier? contributors. DiscussionSandbox(:code=php3 ln:) <?php if (!@$pagename) { $pagename = 'PmWiki.PmWiki'; if (substr($_SERVER['HTTP_HOST'],-11,11) == 'michaud.com') $pagename = 'Pm.HomePage'; } include_once('scripts/compat1x.php'); #ConvertV1WikiD("wiki-1.d"); UseV1WikiD("wiki-1.d"); $ScriptUrl = "http://{$_SERVER['HTTP_HOST']}/wiki"; $PubDirUrl = '/pmwiki/pub'; include_once('scripts/urlapprove.php'); $UnapprovedLinkFmt = "\$LinkText<a class='apprlink' href='\$PageUrl?action=approvesites'>$[(approve links)]</a>"; ?> (:code=cpp ln:) #include "somefile.h" if (p == 2) { int a = 4; } Problems with colour codingI downloaded all the neccessary Beautifier & CodeBook files and had eventually got some nice colour coding of some C++ code I had been writing. When I uploaded all the files to my web site I no longer got colour coding. If this happens to you then change the line in codeblock.php Category: Superceded |