I am trying to modify a js file (It's the first time I try it) and I got something very difficult to understand for me, a mess of inline code with no breaks.
I need it to be clean to be able to understand it, so I've been looking for a solution to break up the text into lines that represents something. I tried to split the lines where the semicolon are, but it didn't solved much.
I remember there where a program that was able to do something similar with css (I can't remember it's name).
Is it possible to do it with notepad++? if not, do you know which program can actually do it?
Thank you
Try using a code beautifier for your javascript, it is currently in 'minified' version.
Example: https://beautifier.io/
Related
I don't see a way to change indentation unit to two-space or best, make it automatically detect the unit: http://codemirror.net/mode/python/index.html
As you can see, the if showed read since it got cm-error class. It has two-space indent. But the print is fine. Although this code block works fine.
So:
Is there a way to make the code using two-space indentation?
Is it possible to make automatic indentation unit?
I tried to play around with http://codemirror.net/mode/python/python.js and cannot come up with any conclusion.
See the indentUnit option. There's no auto-detection in the library, but you might be able to write a little script that finds the first line that's indented more than the one above it, and take the difference as a likely guess.
I came across the function below in one of the SharePoint system javascript files.
function RTE_InsertImage(strBaseElementID)
{ULS1Lu:;
//A bunch of javascript
}
I have never seen something like ULS1Lu:; in any of the javascript code I have worked with before. Does anyone know what this is doing?
Sorry the weak title on the question. I wasn't sure how else to phrase it.
Its a code label, technically they don't need the semicolon, but in javascript it shouldn't hurt. The label will allow a break or continue statement to jump the code back to it.
Most people consider that instead of labels it is better to use function calls whenever possible.
Seems like they are just creating a Label. Possibly, as a marker or for some infamous use. Of course such labels owe a large part of their fame to goto statements.
I have been looking around for a HTML formatter to incorporate with a project I am doing. I need it to be written in Javascript since I want the formatting done on the client side.
The problem is, the few that I have tried don't work very well... For example:
http://www.davidpirek.com/blog/html-beautifier-jquery-plugin : Has a problem with one of the For loops (in the cleanAsync function). Chrome says "unexpected token ILLEGAL"
JS Beautifier on GitHub : When I have links in the HTML it will put a newline character after it. The problem is, I have a period directly after the link in some cases and it will add a space between the link text and the period in the sentence. I tried poking around to fix it but I could not.
Are there any others, or does anyone have recommendations to fix the above two?
EDIT:
This is for editing code, so I just need something to tab in the lines, etc. The code output will go in a textarea.
A few to look at, all have working demos:
http://alexgorbatchev.com/SyntaxHighlighter/
http://shjs.sourceforge.net/
http://jush.sourceforge.net/
http://dojotoolkit.org/reference-guide/dojox/highlight.html
use https://github.com/beautify-web/js-beautify and pass your code to html_beautify() method.
I want something like a rich-text editor for my website that is for code (should be able to do things like syntax highlight, indent on the fly, show line numbers).
I like Mozilla Bespin, but it is quite unstable right now, and has a little bit TOO much functionality for me.
Anything else out there?
Just two days ago I learned of CodeMirror.
What are the odds?
Something like markItUp?
Vim 7.0.237 is driving me nuts with indentexpr=HtmlIndentGet(v:lnum). When I edit JavaScript in a <script> tag indented to match the surrounding html and press enter, it moves the previous line to column 0. When I autoindent the whole file the script moves back to the right.
Where is vim's non-annoying JavaScript-in-HTML/XHTML indent?
Here is similar question with accepted answer with links to two vim plugins:
html improved indentation : A better indentation for HTML and embedded javascript mentioned by Manni.
OOP javascript indentation : This indentation script for OOP javascript (especially for EXTJS) .
One of them solved my problems with JavaScript scripts indention problems.
Have you tried this plugin?
I recommend installing vim-javascript.
It is an up-to-date plugin that properly indents javascript, including more recent developments like the syntax used in closures such as with jQuery.
Personally I toggle between :set ai and :set noai, but might be too tedious for you.
I have plugins for indenting HTML and JavaScript files. To indent JavaScript inside HTML, I temporarily change the file type, select and indent the lines, and then change the file type back.
:filetype javascript
(select lines)
=
:filetype html
It's a little tedious, but it always produces the results I expect.