Hello Everyone,
Continuing on from my Notepad++ tips and tricks discussion, here is how you can perform language syntax highlighting within CA Communities for Perl and many other languages which don't have built in Communities (Jive) "syntax highlighting." Once again, Notepad++ steps in.
The Problem - Not all syntaxes are covered
First, see this thread () which highlights the issue. (Thanks Stuart_Weenig for asking the question.)
Here is our sample Perl script. When Pasted in as plain text, it has none of the Perl syntax highlighted:
------------------------------------
#!/usr/local/bin/perl
$count = 0;
while (<stdin>) {
@w = split;
$count++;
for ($i=0; $i<=$#w; $i++) {
$s[$i] += $w[$i];
}
}
for ($i=0; $i<=$#w; $i++) {
print $s[$i]/$count, "\t";
}
print "\n";
------------------------------------
Our Advanced Editor, Syntax Highlighting (From ">>") doesn't contain "Perl" as an option:
and using a different language type leads to mixed results. Here C++ syntax is used as an example:
------------------------------------
#!/usr/local/bin/perl
$count = 0;
while (<stdin>) {
@w = split;
$count++;
for ($i=0; $i<=$#w; $i++) {
$s[$i] += $w[$i];
}
}
for ($i=0; $i<=$#w; $i++) {
print $s[$i]/$count, "\t";
}
print "\n";
------------------------------------
The Solution - Use Notepad++ "NppExport"
Notepad++ has a built-in (no download required) plugin called "NppExport."
1. Paste your file into Notepad++
2. From Language, pick Perl.
Note that there is a large selection to choose from.
Your text is now highlighted in Perl format.
4. Choose Notepad++ "Plugins", "NppExport" and "Copy RTF to clipboard."
5. Copy and Paste this text into a third application (Sorry!), such as MS Outlook or MS Word.
This will keep the formatting from Notepad++.
6. Copy and paste this text as is, into your CA Communities post.
And here it is!:
------------------------------------
#!/usr/local/bin/perl
$count = 0;
while (<stdin>) {
@w = split;
$count++;
for ($i=0; $i<=$#w; $i++) {
$s[$i] += $w[$i];
}
}
for ($i=0; $i<=$#w; $i++) {
print $s[$i]/$count, "\t";
}
print "\n";
------------------------------------
(I added an "indent.")
So there you have it - a way to maintain code syntax highlighting from many different languages, into Communities.
Yes, it does involve bouncing around between two applications and Communities, but it has the advantage of massively extending the languages that you can display syntax for in Communities, without needing to convert it to a screenshot.
It is also a lot quicker to work in action than this big post would suggest! So give it a go.
Don't forget to check my "Notepad++" link above for more tips.
Thanks, Kyle_R.