I am currently starting to write a documentation for one of our projects. For reasons of simplicity we chose to use the Almost Plain Text (APT) Format, see more info here:
http://maven.apache.org/doxia/references/apt-format.html
APT is great documentation format, since it uses a minimal syntax and hence it is very easy to create and make changes to the documentation without knowing a lot about APT.
However, I couldn't find a way to format code in a nice way. Is there a code tag or similar, which can be used to include some source code? I'm aware I could use FML, but this would be less desirable.
Thanks
For those who are still wondering how to make a code snipped in APT:
This is regular text
+---------------------
This is a code snippet
+---------------------
More regular text
Apache Maven Fluido Skin highlights syntax out of the box. Here you can find an example. Information about syntax highlighting in Fluido: "Source code sections are enhanced by Google Code Prettify, users can optionally enable line numbers rendering (disabled by default)" from Fluido website.
The
+---------------------
code
+---------------------
syntax is correct. And Fluido does highlight using Prettify out of the box as others have mentioned.
However, a Doxia change in Site Plugin 3.3 broke Fluido. MSKINS-86 fixes this, but hasn't been released yet.
Workarounds
Use the site.xml workaround
<body>
<head>
<script type="text/javascript">
$(document).ready(function () {
$("div.source pre").addClass("prettyprint");
prettyPrint();
});
</script>
</head>
</body>
Use Site Plugin 3.2
Build the unreleased Fluido 1.4 that contains MSKINS-86 fix and use it instead of 1.3.1
I ended up using the snippet macro from the Doxia Macros Guide: http://maven.apache.org/doxia/macros/index.html#Snippet_Macro
It puts the code from the snippet file in a verbatim box. However it does not provide a syntax highlightning.
Version 1.0 of doxia include macro is not at maven central however the following versions are:
http://mvnrepository.com/artifact/org.tinyjee.dim/doxia-include-macro
Related
I have a small wiki using MediaWiki 1.26.2 for personal use, within in one article with this section of text:
<source enclose=div lang=php>
$wgGroupPermissions['*']['createaccount'] = false;
</source>
And it is showing the next result:
Instead of this:
I mean, is formatted but without coloring at all, my understanding is that it should be colorful regardless the skin the wiki is using, so is there a configuration that I'm missing?
Seems there are still the same problems with SyntaxHighlight_GeSHi on MediaWiki 1.32.
Alternative is: Highlightjs
(it uses js for syntax highlihting)
It works out of box, even not necessary changing previously defining code syntax from SyntaxHighlight_GeSHi.
The syntax highlighter extension is bundled with recent MediaWiki installations, but not installed by default. You need to enable it in your LocalSettings.php, like this (for MediaWiki 1.24 and newer):
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
I was able to solved the problem, I'm posting the solution just in case someone else gets the same issue. I have my Wiki hosted in godaddy.com and as part of the service you can install Application out the box, one of them is MediaWiki, which already has the SyntaxHighlight extension installed.
For some reason I don't have clear enough, this extension was not working properly, so I decided to install the extension by my own from here and this time it worked like a charm.
I have c code and i want it to be on a pdf file for nice viewing, I've looked for scripts/programs(for mac/linux) that can do that but I didn't find any.
Thanks for your help.
You can use the Listings package in LaTeX. There is a thread about that here.
A hack is to run code prettify in an html document on your computer, and then print your html document to pdf from the browser. Along those lines, you could also run pygments and export to HTML, and then to PDF. Or if you write code with sublimetext, you could use this to export the code directly to HTML: https://github.com/joelpt/sublimetext-print-to-html
You can use the minted package. The use is as simple as listings.
There is a useful tutorial:
https://pt.overleaf.com/learn/latex/Code_Highlighting_with_minted
It is necessary to use -shell-escape when compiling
An advantage that i noticed in the use of minted is the accentuation in the comments, for languages like portuguese. The listings require additional packages and create a series of minor difficulties.
I need syntax highlighting of source code from various languages (PHP, C#, VB, etc) within articles I have in Joomla. I have tried enabling the Geshi plugin, updating the language files and putting the code into my Joomla article - however I can't seem to get it to work.
I have also tried CodeCitation from JED but again, the problem seems to be the same - I don't know how to tell Joomla to process it as code. I placed {codecitation} and {/codecitation} around my code (as well as including the brush value) but it doesn't work. I am unsure if these tags should be placed on the source or the wysiwug
Could someone please assist with an alternative method or work out what I am doing wrong?
With CodeCitation: if you already wrote the article using the tags (i.e. {codecitation} code {/codecitation}), it should work. Did you check if you enable the mambot?
As of Joomla 3.4 Geshi has been removed - but you can still get Geshi+ (geshi repackaged with all the additional languages) - & see the tips here on how to configure geshi.
An example of Geshi+ working is here.
There are now Joomla plugins using highlightjs & google's prettify library to highlight syntax but I found geshi+ worked much better
I am not certain if you can use it in Joomla or not. I use the syntax highlighter by Alex Gorbatchev. I have used it in a couple of blogs (wordpress for instance) and in some stand alone web pages. Not hard to intergrate. It uses the 'pre' tags. You need to be sure the code is already escaped. It may be worth a look. Here is a link.
http://alexgorbatchev.com/SyntaxHighlighter/
Hope this helps.
Bob
There are many free etherpad implementations since it went open source. Does etherpad support syntax highlighting or is some kind of add-on available?
I tried
http://typewith.me/
http://sync.in/
http://www.piratenpad.de/
You can install a plugin in Etherpad called "Syntax highlighting".
To install the plugin simple visit /admin/plugins on your Etherpad deployment and then search for "syntax" and click Install.
For details on the plugin see https://npmjs.org/package/ep_syntaxhighlighting
UPDATE: Syntax highlighting is available as a plugin in the current Etherpad -- see John's answer below.
The original etherpad creators were working on highlighting, but complex sync-problems made them abandon that feature -- as documented in a .txt file in the source code.
Many etherpad sites run on a mostly standard etherpad.org release. If highlighting would get added, you'd probably see it quickly adopted at sketchpad.cc. Perhaps watch them and wait? Or if you really want highlighting, a good first attempt/experiment would be the read-only view. Example: http://sketchpad.cc/sp/pad/view/BACfNDybki/latest
Try to use some existing highlighting javascript library to highlight the text inside DIV#padcontent or perhaps $('DIV#padcontent')[0].textContent
The complexity is getting the highlighted text formatting back into the DB. For this you might need to use operational transformations (which is the foundations of etherpad and as of recently also used in the Google Docs word processor). A tutorial: http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation
The etherpad plugin ep_codepad provides syntax highlighting - based on highlight.js - for etherpad.
https://www.npmjs.com/package/ep_codepad
Is there a utility that will generate html or css for blocks of code (.net c#) when you post it on a website?
I have seen several websites with very nicely formatted code and I dont believe they do this manually.
Google prettify -
http://code.google.com/p/google-code-prettify/
I prefer Syntax Highlighter implementations (I'm using Wordpress plugin implementation for my blog).
Advantages
It is based on JavaScript and does
not care about what you have on the
server.
Posts with this formatting display
properly on different RSS feeds and
can be copied to clipboard.
It is trivial to extend syntax
rules. I'm using that to highlight
custom operators in Boo-based DSL (see sample post)
Multiple languages are supported
out-of-the-box
(source: googlecode.com)
You can get JavaScript syntax-highlighting scripts, such as this one by Dean Edwards.
This is also a jQuery version apparently based on it which looks good.
CopySourceAsHtml is an add-in for Microsoft Visual Studio 2005 that allows you to copy source code, syntax highlighting, and line numbers as HTML.
http://copysourceashtml.codeplex.com
It's highly configurable, and works much better than the download page would make you expect! Don't know if there is something similar for VS 2008
If you don't have the ability to add the google prettifier CSS reference, this would be a better way to go, as what you get is a complete HTML with the required style. I use it all the time on our developers wiki, and loving it.
An even better solution, if you don't want to bother installing anything, is to just use the little web app I wrote called BlogTrog CodeWindow:
http://www.blogtrog.com
It's easy to use. Just paste your code and embed the results.