Which library does GitHub use to beautify JavaScript code? - javascript

Which library does GitHub use to beautify JavaScript code?
I am looking for a good code prettify library.

http://help.github.com/troubleshooting-common-issues/
We use the excellent pygments library for our syntax highlighting. Check their list of supported languages and learn how to specify a lexer for yours. If you contribute a lexer back to pygments, let us know and we’ll make sure it’s made available here on GitHub.

Github do not appear to use any client side library to render code. You can see, using something like Chrome's Net tab, that the HTML views of code arrive from the server prewrapped with vast numbers of span elements.

Related

How to include opensea-js through a script tag in vanilla html/js?

I want to use opensea-js in my html/js project, but their source is published on github and npm only.
https://github.com/ProjectOpenSea/opensea-js
How can I use it in a normal html? (not pages based on node.js)
I found something here
https://www.jsdelivr.com/package/npm/opensea-js
But it doesn't work after I put this code in my html.
<script src="https://cdn.jsdelivr.net/npm/#bthn/opensea-js#4.0.1/lib/index.min.js"></script>
I highly recommend using babel or webpack. There's a steep learning curve to either one, so you should get used to one of them while you're still learning, not when you've gotten into bad habits.
There are a number of advantages of babel/webpack over using CDNs. See this article (it also applies to babel): https://webpack.js.org/concepts/why-webpack/

How to use mathjax from command line?

I was hoping to use Mathjax to render some mathjax snippets into svg files.
At this point I believe that a command in the form
<javascript interpter> <Mathjax jax file> 'mathjax snippet here'
should work, I'm not sure what jax file I'm supposed to pick and how to set the output mode that I want, or how to configure mathjax in general when calling it from the command line.
I need this because I have to render this math expressions offline without a browser.
See this post on the MathJax forum for some code that does this using Phantom.js (there are some subtleties to be considered, so look at the code carefully if you need to modify it). Several others have taken this further. The svgtex project listed in that conversation apparently has been discontinued in favor of the Mathoid project that underlies Wikimedia's latest math support code.
EDIT: there is now the MathJax-node project that uses node.js to run MathJax via the command line or via your own node.js code.
I think you can use nodejs with some wrappers for MathJax - https://www.npmjs.org/search?q=Mathjax
Hey I am not expert in mathjax. but i read have read a article on it. I am passing some links to you. One of which is a documentation of it. Hope it helps you.
documentation pdf. and second one

Break up JavaScript file into more manageable, or using different IDE

I use Dreamweaver for development, mostly PHP, html, css, javascript. Is there anyway to break up JavaScript files? or maybe a better IDE that makes it easier to work with? It just becomes quickly difficult to read and find what I'm looking for.
Thank you!
Intellij and/or Webstorm by Jetbrains has the best JS tools I have found. It has very good (as good as it gets, for JS) intellisense (autocomplete for variables and methods) as well as refactoring for variables and methods. You can cmd+click into method definitions from anywhere, as well. Unfortunately you need to pay for them, but if you are using Dreamweaver you had to pay for that. If you are only doing html/css/javascript Webstorm is the way to go.
Yes, you should break up your javascript files into relevant parts just like you break up your php files into relevant parts. The one key factor here is they should be combined and minified before being served up to the browser so the user does not have to make several network calls to your server for each .js file.
Check out Google Minify for an easy solution to that issue.
Take a look at the JQuery source to see how they divvy up their files. Now look at their combined framework, and of course their minified framework. What is actually served up to the user looks nothing like the source.
Uh, Dreamweaver?
Definitely use a different IDE. Aptana won the poll here :)

How to add Rich Text Editor to display code snippets

Im working on a Rails based application where I have the need to allow the user to format the text he enters and I would also like a way to highlight code snippets the way Stackoverflow does when I enter a code snippet.
Are there any plugins that do this.
And I would also like to know which is the RTE that is recommended and would be unobtrusive.
I see a lot of recommendations for FCKEditor but how do I implement the code snippets?
It seems like you might need something lighterweight than CKeditor. If you do choose to use CKeditor, I would use a rails plugin to install it. I use this one :
http://github.com/galetahub/rails-ckeditor
The directions are very straightforward on the git.
As for Syntax Highlighting , I recommend :
The GitHub crew loves Pygments. They are using it on many different places, including Jekyll and GitHub itself. The downside is that it's a python library so you would need to install python and execute it as a shell task.
Syntax Highlighter, jQuery Library <-- The easiest to implement
http://alexgorbatchev.com/SyntaxHighlighter/
Rails3 has these plugins :
Ruby offers 3 code highlighting Gems: Ultraviolet, Syntax and CodeRay. AFAIK, the last one is the most adopted.

What is a good javascript editor for editing custom DSL code?

I'm looking for a nice / customisable editor to put on a web page for editing scripts for a custom DSL. Ideally with syntax highlighting (and intellisense would be great! )
Anyone know of anything suitable?
For syntax highlighting, look at EditArea. Intellisense could be written as a plugin.
maybe you should have a look at codemirror:
http://codemirror.net/
it's "just" an editor-component and you will probably have to put some work into it. but it's easy to enhance and integrate it.
You should take a look at Bespin. You have a good description here:
http:// mozillalabs.com/bespin/2010/01/15/bespin-embedded-0-6-released-now-in-two-great-flavors/
It has a full support for being embedded. See the embedding doc :
https:// bespin.mozilla.com/docs/embedding/index.html
You can write a custom syntax highlighting plugin pretty easily if needed.
You can probably fork and adapt one of the built-in syntax highlighters.
The editor itself and its plugins are written in Javascript.
The project is aimed at being a complete web-based & collaborative code editor, so intellisense-like features should make their way in soon if they're no alreay present.
The successor of the Mozilla Skywriter (Bespin) project is ACE: http://ace.ajax.org/

Categories