What syntax highlighting is used on GitHub (for HTML, CSS, JavaScript, C#) when viewing source code-file and is it available for the public to use?
It works on the page and it works when embedding on a page (from a Gist), like this:
<script src="https://gist.github.com/1009439.js"></script>
But can I just include their JavaScript-library and let it highlight my code?
Github uses pygments to highlight syntax. Pygments is running on the server, instead of a pure Javascript client solution. If you're looking for a Javascript solution check out this review of the various options.
According to this help page, GitHub currently highlights syntax with the open-source Linguist library for Ruby. Linguist highlights each language using the tmLanguage files linked in vendor/grammars.
Since Linguist is written in Ruby, it can only be used on the server. If you want a client-side JavaScript library that you can just include on a page, you will have to find a different library.
According to this: http://www.infoq.com/news/2008/03/github-git-repository-hosting
they are using Python Pygments
Chris Wanstrath shared some
information about the inner workings
of GitHub with InfoQ:
GitHub is mostly implemented in Rails.
The post-commit integration mini-apps
we're working on are all written in
Merb, we use the Python Pygments for
syntax highlighting, and we use Ara T.
Howard's Bj plus some Ruby scripts for
our queueing system. And, of course,
we use the Ruby Grit library to
interface with Git.
I believe they use their albino gem. It is a Ruby wrapper for the pygments syntax highlighter.
Here is an article of a comparison I read recently on javascript based syntax highlighters (if that is what you need): http://softwaremaniacs.org/blog/2011/05/22/highlighters-comparison/
As others have said previously, GitHub uses Pygments. You can achieve the same effect by using it together with pygments-style-github.
Related
Background:
I have a web app that references many CDN's in my HTML front end. Full disclosure, I am a novice dev at best so very likely that the answer is very simple.
At the time of writing (Oct 2020), I am using, among others, the following CDN:
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-2.0.2.min.css">
Question:
Is there a more dynamic way to link this CDN so that I don't have to manually update the version number (2.0.2) if and when it changes?
If your question is:
How can I ask Bokeh itself for the matching CDN links that correspond to the current installed Python package version?
Then this is the simplest way:
In [1]: from bokeh.resources import CDN
In [2]: CDN.js_files
Out[2]:
['https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js',
'https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js',
'https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js']
Note that that just lists all possible resource URLs. If you aren't using widgets or tables then you don't need those files.
Also note:
The official URL changed to cdn.bokeh.org several years ago. The "pydata" links will continue to work, but everyone should prefer the bokeh.org ones in any new code.
There are not any separate CSS files any more in recent versions of Bokeh, on the JS files.
The above assumes you are using Bokeh from Python, where the Python and JS versions need to be matched. If you are using BokehJS directly (not super common, but it happens) then you should just pick whatever version you intend to use, and update it intentionally/manually, as others have suggested.
A very similar question has been asked before on this subject here
Getting the latest version from cdnjs
and it's generally not a good idea to adopt this practice.
Always using the latest version can expose you to bugs, unwanted behaviour. If the version you are using is stable, then its probably best to stick to it.
I've been using AsciiDocs to write all my documentation, and i was wondering if i could take it a step further and generate the html from my source code, like how JavaDoc does with Java source code.
For example, JavaDoc allows the developer to leave in-line comments that will later be used to generate the html documentation. Is this possible with AsciiDocs? Or do I just need to write the documentation separately?
Javadoc is somewhat modular and extensible: you can use a custom formatting syntax in javadoc comments if you generate the documentation with a custom "doclet".
For AsciiDoc, such a doclet already exists: https://github.com/asciidoctor/asciidoclet
Javadoc is specific to Java, if you use other programming languages there are other tools. Doxygen was created specially for C and C++ but it supports several programming languages and comment styles. For Python, there is pydoc. Whether there's a way to make these support AsciiDoc syntax, you'll have to investigate on your own.
I running a mediawiki and want to use syntax highlighting. I am using the extension https://www.mediawiki.org/wiki/Extension:SyntaxHighlight for that.
That works pretty fine.
Alas I want to highlight a language that is not part of this extension. So I wrote an python egg to extend pygments so it can parse my language (using entry points). This works fine.
Now I am struggling to get both to work together. How do I tell the GeShi Extension of MediaWiki to use my pygments extension? What do I have to do, so that using <syntaxhighlight lang="myLanguage"> will result in using my language lexer and style?
The solution was quite simple. One has to edit the file SyntaxHighlight_GeSHi.lexers.php and add the lexer.
It's important to use only lowercase for the lexer name, otherwise the extension will not find the lexer.
I have been using perltidy and Perl::Critic for checking Perl code before committing. Do we have any tool or module to the similar check for the TCL code?
The usual recommendation in this area is Nagelfar, which is more up to date than most of the other alternatives. There may be other commercial options as well.
tclcheck, which is included in tclsqueak seems decent, is under development and the author is responsive to error reports.
I am creating a MATLAB package using object-oriented programming. I have documented my classes according to a tutorial from MathWorks website. This standard of documentation, however, only works for doc and help commands, but not when I use publish. For example, properties, which have their description written in front of their declaration, don't have said declaration exported to HTML. There is no list of properties or methods at the beginning of the file, so that users can quickly skip to those. Lastly, documentation has to be read directly from the comments in the code, instead of being parsed to HTML.
When I try to add some HTML documentation inside my classes to publish them, the code also appears on doc and help, which is an undesired behavior. Is there a way to create class documentation so that properties and methods can be published to the Web? I've had experience with doc generators like Sphinx (Python) and Doxygen (many languages), in which the descriptions of classes, methods and properties are parsed to HTML so they can be published in places like Read the Docs or GitHub Pages so I am curious to know if MATLAB has something like that.
You can give a try to MTOC++ which uses Doxygen, therefore produces the standard Doxygen HTML documentation.
I have used it already to generate source code documentation for Matlab project containing standard Matlab functions, old class definitions with # notation and classes defined by classdef mixed, and it worked after some tailoring.
This somewhat larger project allows to create documentation for MatLab
files and classes (including packages) using a doxygen filter named
mtoc++. Moreover, a tool/class named MatlabDocMaker allows to create
the documentation from within MatLab. For Windows, Mac and Unix!
You can find it also on Mathworks File Exchange and you can find the documentation here.
One widely-used way to provide HTML documentation for MATLAB functions/class is the M2HTML project. It will automatically generate HTML documentation complete with dependency graphs, source code, and syntax highlighting.