Syntax Highlighter Deneme
Birincil sekmeler
Aktif forum konuları
Popüler içerik
Güncel içerik
Kimler yeni
- Alper BALCI
Kimler çevrimiçi
There are currently 0 users online.
Aylık arşiv
- Ocak 2012 (1)
Bugünün gözde içeriği
Buraya link verenler
Ana menü
This module integrates the SyntaxHighlighter Javascript Library into Drupal for source code list syntax highlighting within any Drupal contents.
Note: the Javascript Library is not included and must be downloaded and installed in
sites/all/libraries
. See README.txt for more details. This module is compatible with both the 2.x and 3.x versions of the Javascript library.
To markup your code, you can use this native <pre> tag format:
<pre class="SYNTAXHIGHLIGHTER-OPTIONS"><br> program code<br> ...<br></pre>
<pre class="SYNTAXHIGHLIGHTER-OPTIONS"><br> program code<br> ...<br></pre>
<pre class="SYNTAXHIGHLIGHTER-OPTIONS"><br> program code<br> ...<br></pre>
<pre class="SYNTAXHIGHLIGHTER-OPTIONS">
program code
...
</pre>
<pre class="SYNTAXHIGHLIGHTER-OPTIONS"><br> program code<br> ...<br></pre>
The native <pre> tag format is only suitable for the Full HTML format. This is because of the unusual class string format (i.e.
class="brush:php;gutter:false"
), both the HTML filter and the WYSIWYG Filter filter out the class string as something illegal and not allowed. The final output end up with no class attribute. The solution this problem is to enable the Syntaxhighlighter filter and use the filter format for markup:
{syntaxhighlighter SYNTAXHIGHLIGHTER-OPTIONS}<br> program code<br> ...<br>{/syntaxhighlighter}{syntaxhighlighter SYNTAXHIGHLIGHTER-OPTIONS}
program code
...
{/syntaxhighlighter}
{syntaxhighlighter SYNTAXHIGHLIGHTER-OPTIONS}<br> program code<br> ...<br>{/syntaxhighlighter}If you use the 3.x library, you can make use of the optional title attribute using the full attribute assignment:
{syntaxhighlighter class="SYNTAXHIGHLIGHTER-OPTIONS" [title="title"]}
program code
...
{/syntaxhighlighter}
{syntaxhighlighter class="SYNTAXHIGHLIGHTER-OPTIONS" [title="title"]}<br> program code<br> ...<br>{/syntaxhighlighter} This filter format makes things compatible with the built-in HTML filter and the WYSIWYG Filter.
Very important!!!: ordered the input format filters as follow:
- HTML filter or Wysiwyg filter or whatever HTML filter you use
- Syntax highlighter
- Line break converter
Note: using the filter format, you do not need to convert the < and > characters to HTML entity encoding as required by the JS lib. Just paste the code verbatim, the filter will take care of the conversion. However, with the <pre> raw tag format, you still have to do this.
<pre class="brush: php; highlight: [5, 15]; html-script: true">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SyntaxHighlighter Demo Page - <?= htmlspecialchars($title) ?></title>
</head>
<body>
<?
/***********************************
** Multiline block comments
**********************************/
$stringWithUrl = "http://alexgorbatchev.com";
$stringWithOutUrl = 'hello world';
ob_start("parseOutputBuffer"); // Start Code Buffering
session_start();
function parseOutputBuffer($buf) {
global $portal_small_code, $portal_gzcompress;
global $PHP_SELF, $HTTP_ACCEPT_ENCODING;
// cleaning out the code.
if($portal_small_code && !$portal_gzcompress) {
$buf = str_replace(" ", "", $buf);
$buf = str_replace("\n", "", $buf);
$buf = str_replace(chr(13), "", $buf);
}
}
?>
<!-- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. -->
</body>
</html>
</pre>
- Yorum yapmak için Giriş Yapın ya da Üye olun.
