Hello world!
time-savers code beautifier and formatter 8211 smashing magazine
format and beautify the code some of them can remove redundant elements knows php java c c perl javascript css

- Details
- Written by Administrator
- Category: Html online
format and beautify the code some of them can remove redundant elements knows php java c c perl javascript css What is Minification ? Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments, and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute.
format and beautify the code some of them can remove redundant elements knows php java c c perl javascript css
format and beautify the code some of them can remove redundant elements knows php java c c perl javascript css
http://html-online.softbaba.com/56-time-savers-code-beautifier-and-formatter-2#htmlonline
http://html-online.softbaba.com/56-time-savers-code-beautifier-and-formatter-2#htmlonline
Minified source code is especially useful for interpreted languages deployed and transmitted on the Internet (such as JavaScript), because it reduces the amount of data that needs to be transferred. Minified source code may also be used as a kind of obfuscation, though the term obfuscation may be distinguished as a form of false cryptography while a minified code instance may be reversed using a pretty-printer. In programmer culture, aiming at extremely minified source code is the purpose of recreational code golf competitions.
Minification can be distinguished from the more general concept of data compression in that the minified source can be interpreted immediately without the need for an uncompression step: the same interpreter can work with both the original as well as with the minified source.
In 2003 Douglas Crockford introduced tool JSMin, which only removed comments and whitespace. It was followed by YUI Compressor shortly thereafter. In 2009, Google opened up its Closure toolkit, including Closure Compiler which contained a source mapping feature together with a Firefox extension called Closure Inspector. In 2010, Mihai Bazon introduced UglifyJS, which was superseded by UglifyJS2 in 2012; the rewrite was to allow for source map support.
Source maps allow tools to display unminified code from minified code with an optimized "mapping" between them. The original format was created by Joseph Schorr as part of the Closure Inspector minification project. Updates as versions 2 and 3 reduced the size of the map files.
Components and libraries for Web applications and websites have been developed to optimize file requests and quicken page load times by reducing the size of various files. JavaScript and CSS resources may be minified, preserving their behavior while considerably reducing their file size. The Closure Tools project is an effort by Google engineers to open source the tools used in many of Google's sites and web applications for use by the wider Web development community. Closure Compiler compiles JavaScript into compact, high-performance code, and can perform aggressive global transformations in order to achieve high compression and advanced optimization. Other libraries available online are also capable of minification and optimization to varying degrees.
Some libraries also merge multiple script files into a single file for client download. This fosters a modular approach to development. A novel approach to server-side minification is taken by Ziproxy, a forwarding, non-caching, compressing HTTP proxy targeted for traffic optimization. It minifies and optimizes HTML, CSS, and JavaScript resources and, in addition, re-compresses pictures. Content encoding is an approach taken by compatible web servers and modern web browsers to compress HTML and related textual content, often in the gzip format. An alternative to content encoding in the server-client layer is given by the off-line CrunchMe tool, which can create self extracting JavaScript programs using the DEFLATE compression algorithm. JavaScript source maps can make code readable and more importantly debuggable even after it has been combined and minified
I prefer using one of the native XML extensions since they come bundled with PHP, are usually faster than all the 3rd party libs and give me all the control I need over the markup.
The DOM extension allows you to operate on XML documents through the DOM API with PHP 5. It is an implementation of the W3C's Document Object Model Core Level 3, a platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure and style of documents.
DOM is capable of parsing and modifying real world (broken) HTML and it can do XPath queries. It is based on libxml.
It takes some time to get productive with DOM, but that time is well worth it IMO. Since DOM is a language-agnostic interface, you'll find implementations in many languages, so if you need to change your programming language, chances are you will already know how to use that language's DOM API then.
A basic usage example can be found in Grabbing the href attribute of an A element and a general conceptual overview can be found at DOMDocument in php
How to use the DOM extension has been covered extensively on StackOverflow, so if you choose to use it, you can be sure most of the issues you run into can be solved by searching/browsing Stack Overflow.
The XMLReader extension is an XML pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way.
XMLReader, like DOM, is based on libxml. I am not aware of how to trigger the HTML Parser Module, so chances are using XMLReader for parsing broken HTML might be less robust than using DOM where you can explicitly tell it to use libxml's HTML Parser Module.
A basic usage example can be found at getting all values from h1 tags using php
This extension lets you create XML parsers and then define handlers for different XML events. Each XML parser also has a few parameters you can adjust.
The XML Parser library is also based on libxml, and implements a SAX style XML push parser. It may be a better choice for memory management than DOM or SimpleXML, but will be more difficult to work with than the pull parser implemented by XMLReader.
The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators.
SimpleXML is an option when you know the HTML is valid XHTML. If you need to parse broken HTML, don't even consider SimpleXml because it will choke.
A basic usage example can be found at A simple program to CRUD node and node values of xml file and there is lots of additional examples in the PHP Manual.
If you prefer to use a 3rd-party lib, I'd suggest using a lib that actually uses DOM/libxml underneath instead of string parsing.
FluentDOM provides a jQuery-like fluent XML interface for the DOMDocument in PHP. Selectors are written in XPath or CSS (using a CSS to XPath converter). Current versions extend the DOM implementing standard interfaces and add features from the DOM Living Standard. FluentDOM can load formats like JSON, CSV, JsonML, RabbitFish and others. Can be installed via Composer.
Wa72\HtmlPageDom` is a PHP library for easy manipulation of HTML documents using It requires DomCrawler from Symfony2 components for traversing the DOM tree and extends it by adding methods for manipulating the DOM tree of HTML documents.
phpQuery is a server-side, chainable, CSS3 selector driven Document Object Model (DOM) API based on jQuery JavaScript Library written in PHP5 and provides additional Command Line Interface (CLI).
Also see: https://github.com/electrolinux/phpquery
Zend_Dom provides tools for working with DOM documents and structures. Currently, we offer Zend_Dom_Query, which provides a unified interface for querying DOM documents utilizing both XPath and CSS selectors.
QueryPath is a PHP library for manipulating XML and HTML. It is designed to work not only with local files, but also with web services and database resources. It implements much of the jQuery interface (including CSS-style selectors), but it is heavily tuned for server-side use. Can be installed via Composer.
fDOMDocument extends the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.
sabre/xml is a library that wraps and extends the XMLReader and XMLWriter classes to create a simple "xml to object/array" mapping system and design pattern. Writing and reading XML is single-pass and can therefore be fast and require low memory on large xml files.
FluidXML is a PHP library for manipulating XML with a concise and fluent API. It leverages XPath and the fluent programming pattern to be fun and effective.
The benefit of building upon DOM/libxml is that you get good performance out of the box because you are based on a native extension. However, not all 3rd-party libs go down this route. Some of them listed below
- An HTML DOM parser written in PHP5+ lets you manipulate HTML in a very easy way!
- Require PHP 5+.
- Supports invalid HTML.
- Find tags on an HTML page with selectors just like jQuery.
- Extract contents from HTML in a single line.
I generally do not recommend this parser. The codebase is horrible and the parser itself is rather slow and memory hungry. Not all jQuery Selectors (such as child selectors) are possible. Any of the libxml based libraries should outperform this easily.
PHPHtmlParser is a simple, flexible, html parser which allows you to select tags using any css selector, like jQuery. The goal is to assiste in the development of tools which require a quick, easy way to scrap html, whether it's valid or not! This project was original supported by sunra/php-simple-html-dom-parser but the support seems to have stopped so this project is my adaptation of his previous work.
Again, I would not recommend this parser. It is rather slow with high CPU usage. There is also no function to clear memory of created DOM objects. These problems scale particularly with nested loops. The documentation itself is inaccurate and misspelled, with no responses to fixes since 14 Apr 16.
- A universal tokenizer and HTML/XML/RSS DOM Parser
- Ability to manipulate elements and their attributes
- Supports invalid HTML and UTF8
- Can perform advanced CSS3-like queries on elements (like jQuery -- namespaces supported)
- A HTML beautifier (like HTML Tidy)
- Minify CSS and Javascript
- Sort attributes, change character case, correct indentation, etc.
- Extensible
- Parsing documents using callbacks based on current character/token
- Operations separated in smaller functions for easy overriding
- Fast and Easy
Never used it. Can't tell if it's any good.
You can use the above for parsing HTML5, but there can be quirks due to the markup HTML5 allows. So for HTML5 you want to consider using a dedicated parser, like
html5lib
A Python and PHP implementations of a HTML parser based on the WHATWG HTML5 specification for maximum compatibility with major desktop web browsers.
We might see more dedicated parsers once HTML5 is finalized. There is also a blogpost by the W3's titled How-To for html 5 parsing that is worth checking out.
If you don't feel like programming PHP, you can also use web services. In general, I found very little utility for these, but that's just me and my use cases.
The YQL Web Service enables applications to query, filter, and combine data from different sources across the Internet. YQL statements have a SQL-like syntax, familiar to any developer with database experience.
ScraperWiki's external interface allows you to extract data in the form you want for use on the web or in your own applications. You can also extract information about the state of any scraper.
Last and least recommended, you can extract data from HTML with regular expressions. In general using Regular Expressions on HTML is discouraged.
Most of the snippets you will find on the web to match markup are brittle. In most cases they are only working for a very particular piece of HTML. Tiny markup changes, like adding whitespace somewhere, or adding or changing attributes in a tag, can make the regex fails when it's not properly written. You should know what you are doing before using regex on HTML.
HTML parsers already know the syntactical rules of HTML. Regular expressions have to be taught for each new regex you write. Regex are fine in some cases, but it really depends on your use-case.
You can write more reliable parsers, but writing a complete and reliable custom parser with regular expressions is a waste of time when the aforementioned libraries already exist and do a much better job on this.
Also see Parsing Html The Cthulhu Way
This is a very good question. Everywhere I look, CSS files tend to get out of control after a while - especially, but not only, when working in a team.
The following are the rules I am myself trying to adhere to (not that I always manage to.)
Refactor early, refactor often. Frequently clean up CSS files, fuse together multiple definitions of the same class. Remove obsolete definitions immediately.
When adding CSS during fixing bugs, leave a comment as to what the change does ("This is to make sure the box is left aligned in IE < 7")
Avoid redundancies, e.g. defining the same thing in .classname
and .classname:hover
.
Use comments /** Head **/
to build a clear structure.
Use a prettifier tool that helps maintain a constant style. I use Polystyle, with which I'm quite happy (costs $15 but is money well spent). I'm sure there are free ones around as well (Update: like for example Code Beautifier based on CSS Tidy, an open-source tool I've not used myself yet but looks very interesting.)
Build sensible classes. See below for a few notes on this.
Use semantics, avoid DIV soup - use <ul>
s for menus, for example.
Define everything on as low a level as possible (e.g. a default font family, colour and size in the body
) and use inherit
where possible
If you have very complex CSS, maybe a CSS pre-compiler helps. I'm planning to look into xCSS for the very same reason soon. There are several others around.
If working in a team, highlight the necessity of quality and standards for CSS files as well. Everybody's big on coding standards in their programming language(s), but there is little awareness that this is necessary for CSS too.
If working in a team, do consider using Version Control. It makes things that much easier to track, and editing conflicts that much easier to solve. It's really worth it, even if you're "just" into HTML and CSS.
Do not work with !important
. Not only because IE =< 7 can't deal with it. In a complex structure, the use of !important is often tempting to change a behaviour whose source can't be found, but it's poison for long-term maintenance.
Building sensible classes
This is how I like to build sensible classes.
I apply global settings first:
body { font-family: .... font-size ... color ... }
a { text-decoration: none; }
Then, I identify the main sections of the page's layout - e.g. the top area, the menu, the content, and the footer. If I wrote good markup, these areas will be identical with the HTML structure.
Then, I start building CSS classes, specifying as much ancestry as possible and sensible, and grouping related classes as closely as possible.
div.content ul.table_of_contents
div.content ul.table_of_contents li
div.content ul.table_of_contents li h1
div.content ul.table_of_contents li h2
div.content ul.table_of_contents li span.pagenumber
Think of the whole CSS structure as a tree with increasingly specific definitions the further away from the root you are. You want to keep the number of classes as low as possible, and you want to repeat yourself as seldom as possible.
For example, let's say you have three levels of navigational menus. These three menus look different, but they also share certain characteristics. For example, they are all <ul>
, they all have the same font size, and the items are all next to each other (as opposed to the default rendering of an ul
). Also, none of the menus has any bullet points (list-style-type
).
First, define the common characteristics into a class named menu
:
div.navi ul.menu { display: ...; list-style-type: none; list-style-image: none; }
div.navi ul.menu li { float: left }
then, define the specific characteristics of each of the three menus. Level 1 is 40 pixels tall; levels 2 and 3 20 pixels.
Note: you could also use multiple classes for this but Internet Explorer 6 has problems with multiple classes, so this example uses id
s.
div.navi ul.menu#level1 { height: 40px; }
div.navi ul.menu#level2 { height: 20px; }
div.navi ul.menu#level3 { height: 16px; }
The markup for the menu will look like this:
<ul id="level1" class="menu"><li> ...... </li></ul>
<ul id="level2" class="menu"><li> ...... </li></ul>
<ul id="level3" class="menu"><li> ...... </li></ul>
If you have semantically similar elements on the page - like these three menus - try to work out the commonalities first and put them into a class; then, work out the specific properties and apply them to classes or, if you have to support Internet Explorer 6, ID's.
Miscellaneous HTML tips
If you add these semantics into your HTML output, designers can later customize the look of web sites and/or apps using pure CSS, which is a great advantage and time-saver.
If possible, give every page's body a unique class: <body class='contactpage'>
this makes it very easy to add page-specific tweaks to the style sheet:
body.contactpage div.container ul.mainmenu li { color: green }
When building menus automatically, add as much CSS context as possible to allow extensive styling later. For example:
<ul class="mainmenu">
<li class="item_first item_active item_1"> First item </li>
<li class="item_2"> Second item </li>
<li class="item_3"> Third item </li>
<li class="item_last item_4"> Fourth item </li>
</ul>
This way, every menu item can be accessed for styling according to its semantic context: Whether it's the first or last item in the list; Whether it's the currently active item; and by number.
Note that this assigning of multiple classes as outlined in the example above does not work properly in IE6. There is a workaround to make IE6 able to deal with multiple classes; I haven't tried it yet but looks very promising, coming from Dean Edwards. Until then, you will have to set the class that is most important to you (item number, active or first/last) or resort to using IDs. (booo IE6!)
CSS: code beautifier
HTML: HTML Tidy, CleanUp HTML or the general purpose Pretty Diff
Javascript: http://jsbeautifier.org/
PHP: http://beta.phpformatter.com/
SQL: http://dpriver.com/pp/sqlformat.htm
Online SQL Formatter: Online SQL Formatter
XML: http://chris.photobooks.com/xml/default.htm
Colour all: http://quickhighlighter.com/
I'm trying to find any information I can on the PastryKit Javascript Framework. It appears to be in use on the iPhone User Guide that is displayed on the iPhone itself in Mobile Safari, but I cannot find any documentation or API. If you want to see it in action, open Safari 4, set your user agent to iPhone 3 (In the Develop menu) and check out the guide.
Overall, it seems to be a way to write an HTML/CSS/Javascript application that acts like a native iPhone app.
When it comes to Javascript, I used the JS Beautifier on (what I assume to be) the framework fileand it was over 3,400 lines! Beautified, (again what I assume to be) their implementation of it was over 1,200 lines.
On the CSS side, I used Clean CSS on (again what I assume to be) the framework CSS, and it came out to over 700 lines. Their implementation was shy of 500.
Does anybody have, or know where to find, any information, documentation, or APIs on PastryKit? Or, can anybody figure out how to implement it?
I recommend using UglifyJS which is a JavaScript parser / mangler / compressor / beautifier library for NodeJS.
If you are interested in automation tools that do more than simply concatenate and minify files, there are the following solutions:
GruntJS is a task-based command line build tool for JavaScript projects. The current version has the following built-in tasks:
Besides this tasks there's a lot of plugins available.
Gulp is a toolkit that will help you automate painful or time-consuming tasks in your development workflow. For web development (if that's your thing) it can help you by doing CSS preprocessing, JS transpiling, minification, live reloading, and much more. Integrations are built into all major IDEs and people are loving gulp across PHP, .NET, Node.js, Java, and more. With over 1700 plugins (and plenty you can do without plugins), gulp let's you quit messing with build systems and get back to work.
Yeoman is a robust and opinionated set of tools, libraries, and a workflow that can help developers quickly build beautiful, compelling web apps.
How can I format/tidy/beautify HTML in JavaScript? I have tried doing a search/replace for angle brackets (<
, >
) and indenting accordingly. But of course it does not take into account when the is JS or CSS etc inside the HTML.
The reason I want to do this is I have made a content editor (CMS) which has both WYSIWYG and source code views. The problem the code written by the WYSIWYG editor is normally a single line. So I would like a JavaScript that could format this into a more readable form on demand.
npm install grunt-newer --save-dev
Then in your Gruntfile (after loading the task in grunt):
watch:
coffeescript:
files: 'assets/javascript/**/*.coffee'
tasks: ["newer:coffee"]
And that's it! The Awesome grunt-newer is awesome!
CSS is already beautified in Firebug, as clearly seen by comparing the CSS tab or CSS pane with the raw source.
JavaScript, alas, is not. The best you can do, for now, is to paste the code into something like
However, if you write a Firebug extension that does this, you will have all of our gratitude. ;-)
Paste your CSS
/SCSS
/LESS
into dirtystylesheet.com and hit Clean
Via command line you can re-format CSS
/SCSS
/Sass
using the sass-convert
script:
$ sass-convert messy.scss clean.scss
or CSS to SCSS:
$ sass-convert messy.css clean.scss
or SCSS to Sass:
$ sass-convert messy.scss clean.sass
The sass-convert
script is installed when you install Sass. It can convert any direction between: css, scss, and sass.
Learn more about sass-convert
:
$ sass-convert --help
Advanced user tip: Because the sass
syntax is much stricter (only allowing one property: value
pair per line) you're less likely to run into an issue with messy code.
I'm a PHP developer and now I use Notepad++ for code editing, but lately I've been searching for an IDE to ease my work.
I've looked into Eclipse, Aptana Studio and several others, but I'm not really decided, they all look nice enough but a bit complicated. I'm sure it'll all get easy once I get used to it, but I don't want to waste my time.
This is what I'm looking for:
Are you sure you're looking for an IDE? The features you're describing, along with the impression of being too complicated that you got from e.g. Aptana, suggest that perhaps all you really want is a good editor with syntax highlighting and integration with some common workflow tools. For this, there are tons of options.
I've used jEdit on several platforms successfully, and that alone puts it above most of the rest (many of the IDEs are cross-platform too, but Aptana and anything Eclipse-based is going to be pretty heavy-weight, if full-featured). jEdit has ready-made plugins for everything on your list, and syntax highlighting for a wide range of languages. You can also bring up a shell in the bottom of your window, invoke scripts from within the editor, and so forth. It's not perfect (the UI is better than most Java UIs, but not perfect yet I don't think), but I've had good luck with it, and it'll be a hell of a lot simpler than Aptana/Eclipse.
That said, I do like Aptana quite a bit for web development, it does a lot of the grunt work for you once you're over the learning curve.
There is tidy for HTML. It's more than a validator: it doesn't only check if your HTML is valid, but also tries to fix it. But you can just look at the errors and warnings and ignore the fix if you want.
I'm not sure how well it works with HTML5, but take a look at Wanted: Command line HTML5 beautifier, there are some parameter suggestions.
For CSS there is CSSTidy (I have never used it though.)
Regarding the W3C validator: if you happen to use debian/ubuntu, the package w3c-markup-validator
is in the repositories and very easy to install via package management. Packages for other distos are also available.
Don't be so sure you have gotten all there is to pretty-printing HTML in so few lines. It took me a little more than a year and 2000 lines to really nail this topic. You can just use my code directly or refactor it to fit your needs:
https://github.com/prettydiff/prettydiff/blob/master/lib/markuppretty.js (and Github project)
You can demo it at http://prettydiff.com/?m=beautify&html
The reason why it takes so much code is that people really don't seem to understand or value the importance of text nodes. If you are adding new and empty text nodes during beautification then you are doing it wrong and are likely corrupting your content. Additionally, it is also really ease to screw it up the other way and remove white space from inside your content. You have to be careful about these or you will completely destroy the integrity of your document.
Also, what if your document contains CSS or JavaScript. Those should be pretty printed as well, but have very different requirements from HTML. Even HTML and XML have different requirements. Please take my word for it that this is not a simple thing to figure out. HTML Tidy has been at this for more than a decade and still screws up a lot of edge cases.
As far as I know my markup_beauty.js application is the most complete pretty-printer ever written for HTML/XML. I know that is a very bold statement, and perhaps arrogant, but so far its never been challenged. Look my code and if there is something you need that it is not doing please let me know and I will get around to adding it in.
I don't particularly understand what you mean by "clean unused CSS", but in any case, I'll throw two tools at you, and maybe one will work (the good ol' shotgun approach).
CSS Lint seems to point out "duplicate properties". There are a range of articles covering some of what it does. But a test with the two definitions you had,
a { color: #fff; }
a { color: #000; }
it didn't do much of anything. While ...
Code Beautifier did combine the two selectors, opting for the latter of the two (i.e. the style that's actually applied). Resulting in:
a {
color:#000;
}
- Thanks to Katana's input
The reason: A valid HTML can contain JS and CSS (and it usually does). JS can contain both css and html (i.e.: var myContent = '< div >< style >CSS-Rules< script >JS Commands';). And even CSS can contain both in comments.
So writing a parser for this close to impossible. You just cannot separate them easily.
The languages have rules upon how to write them, what you want to do is reverse architect something and check whether those rules apply. That's probably not worth the effort.
Approach 1
If the requirement is worth the effort, you could try to run different parsers on the source and see if they throw errors. I.e. Java is likely to not be a valid HTML/JS/CSS but a valid Java-Code (if written properly).
Approach 2 - Thanks to Bram's input
However if you know the source very well and have the assumption that these things don't occur in your code, you could try the following with Regular Expressions.
<code><div>This div is HTML var i=32;</div></code>
<code>#thisiscss { margin: 0; padding: 0; }</code>
<code>.thisismorecss { border: 1px solid; background-color: #0044FF;}</code>
<code>function jsfunc(){ { var i = 1; i+=1;<br>}</code>
$("code").each(function() {
code = $(this).text();
if (code.match(/<(br|basefont|hr|input|source|frame|param|area|meta|!--|col|link|option|base|img|wbr|!DOCTYPE).*?>|<(a|abbr|acronym|address|applet|article|aside|audio|b|bdi|bdo|big|blockquote|body|button|canvas|caption|center|cite|code|colgroup|command|datalist|dd|del|details|dfn|dialog|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frameset|head|header|hgroup|h1|h2|h3|h4|h5|h6|html|i|iframe|ins|kbd|keygen|label|legend|li|map|mark|menu|meter|nav|noframes|noscript|object|ol|optgroup|output|p|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video).*?<\/\2/)) {
$(this).after("<span>This is HTML</span>");
}
else if (code.match(/(([ trn]*)([a-zA-Z-]*)([.#]{1,1})([a-zA-Z-]*)([ trn]*)+)([{]{1,1})((([ trn]*)([a-zA-Z-]*)([:]{1,1})((([ trn]*)([a-zA-Z-0-9#]*))+)[;]{1})*)([ trn]*)([}]{1,1})([ trn]*)/)) {
$(this).after("<span>This is CSS</span>");
}
else {
$(this).after("<span>This is JS</span>");
}
});
What does it do: Parse the text.
If it contains characters like '<' followed by br (or any of the other tags above) and then '>' then it's html. (Include a check as well since you could compare numbers in js as well).
If it is made out of the pattern name(optional) followed by . or # followed by id or class followed by { you should get it from here... In the pattern above I also included possible spaces and tabs.
Else it is JS.
You could also do Regex like: If it contains '= {' or 'function...' or ' then JS. Also check further for Regular Expressions to check more clearly and/or provide white- and blacklists (like 'var' but no < or > around it, 'function(asdsd,asdsad){assads}' ..)
Bram's Start with what I continued was:
$("code").each(function() {
code = $(this).text();
if (code.match(/^<[^>]+>/)) {
$(this).after("<span>This is HTML</span>");
}
else if (code.match(/^(#|\.)?[^{]+{/)) {
$(this).after("<span>This is CSS</span>");
}
});
http://regexone.com is a good reference. Also check http://www.sitepoint.com/jquery-basic-regex-selector-examples/ for inspiration.
I was trying out angular 2 the other day and I faced the same issue as you do, my vendor.js was 6M and this was a simple "Hello World" app...
I've found the following post that helped a lot in understanding how we should act on this issue (for now): http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/
He uses several optimizing and compression techniques (precompile,treeshake, minify, bundle and gzip) on his 1.5M app to reduce its size to just 50kb.
Check it out, hope it helps! :)
EDIT: I've had a few runs with Angular since, and for me the best working approach was to use the angular-cli, which is at v1.0 when I'm writing this and when you run the build with --prod it does everything I wrote in my original post +a usual web server gzips your files. My complete site is under 1MB with this and his has a lot of functionality and also plenty third party stuff as well.
Languages are originally built to work independently. So that you could technically use that particular language for what is intended for only. In the case of HTML, it is only supposed to allow you to display something on a browser. CSS on the other hand, (and as you surely know), it is intended to create all the beautification process. So, with that in mind, Anyone should be able to write an HTML document without any CSS at all and browsers should display it in the most legible form. Now, for this to happen as consistent as possible, browsers have something called "sane defaults". These defaults cover the margin and padding on the body, some fonts, the most legible font size, etc. And they leave it up to you to overwrite as needed with CSS.
Without the margin and padding on the body, everything would be completely flushed to the browser window. That is not the best practice if you were reading a document
EDIT
The links below show Firefox and Webkit CSS defaults. This will help you troubleshoot those defaults that you have no idea where they came from or whay they exist.
First let me say I come from a Microsoft background and Visual Studio is my bread and butter. It has a command (keybind is arbitrary) that auto-formats any code syntax. The same command works in HTML, CSS, Javascript, C#, etc.
I have tried plugins for ST2 and so far I've found most don't work on a Windows box and if they do, it's for a very specific purpose like just Javascript.
I have tried (and opened Issues where appropriate):
https://github.com/victorporof/Sublime-HTMLPrettify
https://github.com/jdc0589/JsFormat (this one actually works)
https://github.com/welovewordpress/SublimeHtmlTidy
Have any Windows users of ST2 found anything that works to format CSS/HTML/Javascript, preferably in one shot?
Edit: Since this question is getting lots of views with no activity, I'll say that I am still looking for a plugin that can format various script types within the same command.
October 2013 Still haven't found anything that covers JS+CSS+HTML well however I have settled on JsFormat as by far the most effective and bug free with the least amount of configuration for just JavaScript.
You can't use CSS to style a WinForms application, but I don't think that's what you mean anyway.
As far as "beautifying" your application, there are a number of 3rd-party tools available. The most popular ones are (in no particular order):
People tend to get religious about their 3rd-party design tooling, and a lot of ink has been spilled on SO going over the benefits of each 3rd-party design tool.
format your css to clean it up and beautify it make your css easier to read and validate it
online css viewer editor beautifier formatter validator minifier save and share css simple quick and fast
code beautifier css formatter and optimiser - online css parser and optimiser
this free online tool lets you beautify format your css code with no side effects
the tools to minify and beautify javascript css and html codes javascript minifier middot css minifier middot html minifier middot javascript beautifier middot css beautifier
automatically format your css cascading style sheets so they are easy to read and edit use this tool to reorganize your css online simply submit your
code beautifier you can pretty-print and syntax highlight source code written in javascript html css php or other programming
beautify-css is a command-line css beautifier that uses the css npm module to parse and format valid css you can install it with npm install -g beautify-css
css cleaner beautifier formatter tidy or call it whatewer you like is a free online code optimizer that helps you clean up easily your messy style sheet files
css tool will help you format your code to the style you prefer just paste your css code in the textarea below and select the options for
reindent and reformat css http www senchalabs org cssbeautify css beautify is a javascript implementation of reindenter and reformatter for styles written
beautify css code using online css beautifier enter dirty minified css code to beautify format prettify and make it more readable the editor has the option to
this is a sublime text 2 and 3 plugin allowing you to format your html css javascript and json code it uses a set of nice beautifier scripts made by einar
beautify css javascript and json code when you open a css js json file
online css formatter and beautifier - try online css formatter and beautifier and editor to beautify and format css code using jquery plug-in
formatter plugin adding a js-beautify interface to the atom editor format and reindent your javascript js jsx json html xml css sass scss less
world s simplest css beautifier just paste your css in the form below press css prettify button and you get beautiful and clean css press button get css
i m using a great plugin html-css-js prettify sublime wbond net packages html 20prettify issue i have a page that is html which has
sion for visual studio code - beautify css sass and less code extension for visual studio code
css-html-prettify 2 0 0 downloads 8595 standalone async cross-platform unicode- ready python3 prettifier beautifier for the web standalone async
ou would expect using css beautifier is as easy as it gets paste unformatted css code into the top text area and the app produces a
css beautifier free tool to convert your minified messy looking css code into readable format you can copy the beautified code and use it in your application
a powerful tool to format deobfuscate and beautify the html javascript css or xml files in human readable format
epends on what you want to do with the code if you want to focus on performance for your production environment you probably don t need
the tabifier currently supports css html and c style code the latter being anything that uses curly braces to start and end blocks and semicolons to
beautify js js beautify for komodo edit ide this little beautifier will reformat minify css html and javascript based on the the jsbeautifier org
format your css and beautify it that it can look user friendly and professional
not the primary task for ncollector studio but it still has a decent css parser supporting both ordinary css and less scss style css exposed as a formatter on this
beautifier css3 beautifies your css automatically so that it is consistent and easy to read http html fwpolice com css
beautifier is a simple and quick utility to beautify format your css cascading style sheet source code beautify your css source code
quickly validate re-format beautify or compress css code all-in-one free css validator css formatter and css compressor
free online tool for instant css beautify css beutifier v 1 0 paste code copy to clipboard or an url to a css file or upload a css file beautify download
mmand-line stream parser for beautifying css
so i m using https github com beautify-web js-beautify with i had a look into the code for beautify-css js to see what i can do but it s a bit
related javascript minify middot javascript obfuscate middot css formatter middot html there are many option to tailor the beautifier to your personal formatting tastes
format your css to clean it up beautify it and readable format make your css easier to read and validate it
css beautifier in by xadmin january 10 2017 back to useful links beautifies your css automatically so that it is consistent and easy to read click to visit
prettify - a javascript module and css file that allows syntax highlighting of source code snippets in an html page - cdnjs com - the best foss cdn for web
full code for the css beautifier can be found on github it s light-weight and robust with pretty much the same options as the lesscss script
eautifier code formatting extension for brackets a few days ago i was asked if css http minifycode com css-beautifier and html
i was wondering if you know how to change the way the beautifier handles spaces on css files i find it quite annoying that is adds 2 empty
comb 8211 tool for sorting css properties in a specific order css beautifier is a handy tool that will take any messy css file and make it
there how i can to beautify or format my code from a key shorcut in the text editor thanks to all
tify css code using codepen few would argue that codepen has been an indispensable tool for the frontend developer community
tify css code with css beautifier format your dirty minified css code and make it more readable using our css beautifier formatter
messy minified or obfuscated css codes not anymore use this free online css formatter and beautifier to get clean and nice looking style sheets with even
brackets extensions - format javascript html and css files and related languages this is a fork of drewhamlett s beautify extension using the latest version
formatter css middot json middot sql middot xml generator lorem ipsum middot qr code middot password minifier css middot json middot sql middot xml security md5 digest tester javascript
hi i require an editor that can beautify source code that is jquery css php html all in one i looked at the online javascript beautifier it
-css-js prettify is a sublime text 2 and 3 plugin allowing you to format your html css javascript and json code it uses a set of nice
this script can beautify html css javascript json files to support json file your need add following code to your vimrc au bufread bufnewfile json setf json
formatter plugin adding a js-beautify interface to the atom editor format and reindent your javascript js jsx json html xml css sass scss less
beautify is a javascript implementation of reindenter and online css cascading style sheet beautifier tool can process a css
about css formatter minifier easy to use paste your raw css code in editor and use the buttons 8220 minify css 8221 and 8220 format css 8221 it s that much simple
- uploaded by amit paulup next sublime text - 1091 1089 1090 1072 1085 1086 1074 1082 1072 1087 1083 1072 1075 1080 1085 1072 html-css-js prettify 1055 1083 1072 1075 1080 1085 html css js prettify - duration 11 aug 2015 - 5 min - uploaded by amit paul 11 aug 2015 5 min uploaded by amit paul
format and beautify the code some of them can remove redundant elements knows php java c c perl javascript css
paste your raw svg code into the input and get back a minified and base64 encoded piece of css code
ve been given the green light to make an open-source css validator and pretty printer i ve named it prettycss since i didn t really find
nfess that am a messy coder when it comes to formatting i edit insert and delete until the code runs like i want to this often leads to
css css short for cascading style sheets is used almost universally across the web to affect the design and appearance of every
ote a css beautifier - css code styler script quot css beautifier pl quot using perl i integrated it with komodo edit as a macro see below but you
follow iconmonstr support me ads via carbon enter your messy minified or obfuscated html into the field above to have it cleaned up and made pretty
eautifier will automatically rearrange css code with custom settings sass is a css preprocessor meant for saving time during css
beautifier is a simple css cleanup tool with no frills or frivolous features it accepts pasted or linked css and carefully cleans it up based
css formatter and beautify online is a useful tool to format css data to make them readable friendly
css beautifier what can you do with css beautifier removes useless white spaces indentation characters and line breaks strips all comments removes
about us careers blog product features pricing customer stories examples schedule a demo use cases media marketing education reporting teams
css beautifier is an online tool to format beautify css data with the best possible output quickly and easily it removes unwanted spaces lines and formats the
4 m rz 2013 der css beautifier sorgt daf r dass stylesheets lesbar bleiben bzw werden und kann 8222 minified stylesheets 8220 in ein f r menschen geeignetes
n how to cleanup css and html codes these simple ways to optimize and beautifier your html codes for search engine humans and
free online css beautifier formatter format or beautifies a css file with configurable options for optimal readability
i guess i didn t notice before that cssbeautifier is a separate package with separate versioning bthorben since you seem to know more about python than i do
make your css clean and your website faster the purposes to use css optimization tools are a lot first of try css beautifier and make your css clean
javascript html and css free code beautifier a html javascript and css formatter beautifier javascript html css x 1 beautify js code 1 1
i thing a shortcut for that would be helpful autoindent html css hi suhas - can you tell us when the ability to beautify css code with
fast cdn for js-beautify - jsbeautifier org for node lt script src quot https cdnjs cloudflare com ajax libs js-beautify 1 6 14 beautify-css min js quot gt lt script gt lt script
e tested them all and my two favorites are css beautifier and clean css i d also like to recommend a tool called kaleidoscope which
another json viewer plugin which allows to beautify format view your json data with section and syntax highlighting support
it is a library for other scripts to include with the meta directive require https greasyfork org scripts 18528-beautify-css code beautify-css js version 194233
html5-print --help usage html5-print -h -o outfile -s indent width -e encoding -t html js css -v infile beautify html5 css javascript - version
css i use quot csstidy quot the c version i added css 3 0 support to it and also added a default quot indented quot template you can get the latest
in addition to the js-beautify executable css-beautify and html-beautify are also provided as an easy interface into those scripts alternatively js-beautify --css or
t this is a parsec-based haskell css parser that follows the w3c css3 module syntax draft for now it simply parses css piped to
tutorial will show you how to beautify or clean up your css so it is easy to read and understand we will be turning this code select
ty printer is an online code beautifier for multiple latest programing languages like javascript css perl java etc just paste your code in
phpstorm 2017 2 help reformatting source code keymap windows linux default windows linux default gnome kde xwin emacs visual studio
antenna house xsl formatter is a print formatter powered by xsl-fo amp css used in well over a thousand installations worldwide pdf output multilingual
this online tool allows beatify javascript css and html code it allows to read content from remote url
live preview of css less code with an in-page editor autocomplete convert less to css beautify minify css reloader linter etc run this extension and
easily deminify css code with the css beautifier deminify css code snippet generator
css formatter should insert space after selector separator after comma or at least make it an option backward compatibility issue there is probably no
run beautify settings input ltr css 1 2 3 4 5 6 7 8 example direction ltr margin 0 padding 1em 2em 5em 1em background-color 3536
riginal php code of the beautifier library has been ported to perl for css quot url quot the url of a css stylesheet that extends the plugin s
html-css-js prettify plugin is the most flexible and feature-rich of the plugins i evaluated available for sublime text 2 and sublime text
pub twiki beautifierplugin style css default css lib twiki plugins beautifierplugin pm plugin perl module lib beautifier pm perl modules lib hfile pm
the xml beautifier formats code with indentation of one tab space and is not configurable for more information see working in the code editor css beautifier
i was looking for this a while back and i finally just decided to see if there was a plugin that beautified the wordpress output seems that s all i
editor for css and less 5 5 9 compatible with firefox 57 autocomplete convert less to css beautify minify css reloader linter
a code formatter plugin adds support for a new language or formatting scheme a menu item is added to the edit code formatting menu and the key binding
mple and useful online tool just paste your messy or unformatted css in and copy your beautiful css out nice workfloweric anderson
breadcrumbs navigation home media css-beautifier previous post15 great css tools to help with easy web development we were unable to load
of einars js-beautify for use with composer default stdout --config path to config file --type js css html quot js quot -q --quiet suppress logging
thanks for a2a this css was minimized this is one of optimization steps if you want to de-minimized it use css formatter and beautifier tool this is rea
9 okt 2014 der linktipp dieser woche richtet sich vor allem an webdesigner die viel mit css arbeiten sicher kennt ihr das problem ihr tippt ein
beautifier is a simple css clean-up tool with a user friendly interface it provides the feature to place the cleaned up code to an output
i m in sublime text 2 i use tidy css and that makes a mess of less here is the site http www calluna-software com formatter css
to compress css uncompress css beautify css or tabify css
css beautifier make it look pretty - dan s tools instant screencast just click and record 6 stunning visuals that will make your content memorable
g dreamweaver you can set preferences that control the format of your css code whenever you create or edit a css rule
cory simmons - 2013 - computers
sorry if a duplicate but my search didn t return anything any way to format files with plugins like csstidy or js-beautify to take care of mostly
developer description free online css beautifier tool to unminify and format your css code making it readable and pretty last updated 6 aug 2015
include the tables plugin css file -- gt lt link rel quot stylesheet quot href quot css plugins table min css quot gt code beautifier beautifies the code inside the code view mode
css beautifier is a simple and quick utility to beautify format your css cascading style sheet source code beautify your css source code and make it
you can use an online tool to beautify css css beautifier www cleancss com css-beautify note it will turn the actual 2 kb into a 508 kb file
-beautify - beautify html css and javascript in atom
cx css-formatter 8212 format a document using css synopsis lt p declare-step type quot cx css-formatter quot xmlns cx quot http xmlcalabash com ns extensions quot gt
tutorials middot angularjs tutorial middot bootstrap tutorial middot jsplumb tutorial middot integrationtool tutorial middot wpf diagram designer middot c plugins amp modules tutorial middot c shared
here are the top 8 tools for improving and cleaning up your css css beautifier isn t an optimization or cleanup service like the others rather than trying to
a community of over 30000 software developers who really understand what s got you feeling like a coding genius or like you re surrounded by idiots ok maybe
prefixes your css using autoprefixer provides fallbacks for rem units adds opacity filter converts css shorthand filters packs media-queries inlines import
stylefmt is a tool that automatically formats css according to stylelint rules latest release 6 0 0 - updated 2 months ago - 1 78k stars
irecting file url or uploading your css file you minify and beautify your css code in this site there s also option to validate your css
mcmo 2015-03-20 16 32 48 utc 2 i use html-css-js prettify and set html preferences to quot indent handlebars quot true
e are quite a few online code beautifiers that do a fine job with formatting ordinary css but present them with nested styles and parametric
die ersehnte l sung h rt auf den namen css beautifier das kleine online-tool macht minimierte css-dateien wieder lesbar einfach so ganz ohne aufwand
auto-beautify buffer before save js2-mode web-mode css-mode you can add more nodejs and package js-beautify required npm install
python to beautify using python bash pip install jsbeautifier js-beautify file js css amp html in addition to the js-beautify executable css-beautify and
uglifyjs is a javascript parser compressor beautifier toolkit it can be used to combine and minify javascript assets so that they require less http requests and
a cool code snippet made in css depicting a simple sliding bar made with a realistic design this bar includes a tooltip that changes the text accordingly to the
ginner s guide to install and use google code prettify aka prettyprint on your look for the prettify js and prettify css in the extracted files
the last years i used the css reformat very often and always correct the in the meantime you may use beautify-css pspad script which
specify the formatter that you would like to use to format your results stylelint lint does not reject the promise when your css contains syntax errors
materialize is a material design admin template it s modern responsive and based on material design by google
over some basics of css so that you can easily spruce up your mobile content
it very simple widget with using few lines of css and html code lets see jsonlint js beautifier css beautifier yaml beautifier and mysql query beautifier
to create beautiful online forms for your organization learn how to customize form themes without knowing form css with formstack s
ss clears the junk out of your css finds and removes selectors you re as well as css compressor code beautifier and css beautify
tify css documents and css code blocks with a single click
welcome to the online css editor css viewer css formatter css beautifier css validator css minifier at devtoolmania com
www eslinstructor net vkbeautify vkbeautify is a small simple and powerfull javascript plugin to beautify xml json or css text
css beautifier is a helpful cleanup tool which organizes a disordered code snippet and automatically produces well-organized website structures
beautify hexo generated html css and js files using js-beautify filter beautify html css js hexo-blog-encrypt yet another blog encrypt plugin for hexo
hello unfortunately css formatter does not break lines then i cut and past and move the newly formatted text back into the css file
kets edge code extension that parses css documents and add vendor beautify brackets extension that formats open html css and
see also the vivliostyle formatter 2014-05-22 netsurf version 3 1 is a graphical browser with support for html5 css 2 1 svg and more risc os linux
rapid css editor screenshots and feature tour rapid css provides clean familiar and fully customizable interface for different css beautifier updated
selected template will be loaded in template editor and css in css editor the email beautifier system supports j mailalerts plugins including the socialads
syntax highlighting of source code snippets in wiki page using google-code- prettify javascript module with css files last updated on 2017-07-04 provides
javascript amp css beautifier compression high smallest low readble 12 634 page views since apr 2012 copyright 1996-2017 tom nunamaker
css beautifier online-tool like css beautifier description beautifies your css automatically so that it is consistent and easy to read payment model free
web safe css font stacks and web fonts select preview and generate css and html for your font family
ove your html and css workflow with emmet as with the beautifier this handy extension will save you time having to use an external
ed issues on beautify new line before next css selector 1142 v1 6 10 description added preserver newlines to css beautifier
html-css-js prettify 54540 47084 44536 51064 51008 51060 47492 50640 49436 50508 49688 51080 46319 51060 html css js 54028 51068 51012 50500 47492 45813 44172 47564 46308 50612 51452 45716 44592 45733 51012 51228 44277 54633 45768 45796 44592 48376 49444 51221 46108 54252 47607 50640 47582 52656 45800 54620 48264 51032 53412
andy harris - 2010 - computers
from simplifying our workflows to generating actual css these tools give us the after you ve made your css look readable with the css beautifier you can
features more styles colors can be customized the js css files can be pre- loaded or post-loaded no js css files are loaded if there is no code
html css and javascript live or run code in the console css beautify open source tool for formatting css from sencha labs
ss is a javascript framework for building css tools it s being used to build lots of stuff from linters minifiers beautifiers it s what works
css csstidy css tidy css optimiser 25972 29702 20248 21270 css 25972 29702 css 20248 21270 21387 32553 css 21387 32553
vivliostyle formatter is a print formatter which generates pdfs from html css or epubs from a command line interface to be used standalone or in a server
i would prefer to have my css code in alphabetical order per element however it is annoying to always sort them does anyone know of a tool for su
prettyprinter is a source code beautifier source code formatter similar to indent it knows php java c c perl javascript and css it is advisable to make a
theme has a css stylesheet for use with google s prettify js prettify is an easy to use javascript library that can be used to display code
y i learned about an excellent code beautifier for html css and javascript called js-beautify you can try an online version at
video tutorial online css formatter and optimizer this is a video tutorial i created to showcase an online css formatter and optimizer i ll apologize in advance
jonathan stark - 2010 - computers
css paged media pdf generation from xml and html using css perhaps the formatter with the best quality and typographical features in fact it is based
the css compressor is basically used to compress css by removing all unnecessary characters from source code beautifier css formatter and optimiser
codegainer com the free online css prettify tool
the styelsheet that you are using in your project and either copy the contents of the prettify css into it or link to it to link to it open the
here i am again was working on the theme for my blog oh yea i almost change this website whenever i get some time apparently i don t
that s an error the requested url svn loader prettify css was not found on this server that s all we know you can use the url cdnjs
online css formatter and beautifier lets you format css online with specified indentation level
bootstrap example of beautify checkboxes amp radio input group addons using html javascript jquery and css snippet by mouse0270
w module field formatter css class automates that process and makes turning simple fields into extra css classes a no-brainer
her you are in pursuit of a creative challenge or simply are looking to enhance your existing weebly website design the 8220 edit html css 8221
json formatter middot text encryption - decryption middot html editor wysiwyg middot character color converter middot advanced encryption middot css beautifier middot number to
andy harris - 2014 - computers
de minifer and beautifier in one minify takes your current npm install -g clean-css uglifycss js-beautify html-minifier uglify-js minjson svgo
8220 formatter 8221 provides a set of pre-defined formats for various types of values https cdn rawgit com ax5ui ax5ui-formatter master dist ax5formatter css
cript src quot https cdn rawgit com google code-prettify master loader prettify stylesheet but you can alternatively use your own css or one
simon collison andy budd cameron moll - 2009 - computers
andy harris - 2012 - computers
cleancss is a sublime text 3 package for beautifying your css cleancss indents all your rules properly aligns all the values by the colon and sorts each
web-beautify licence travis badge melpa badge melpa stable badge web- beautify is a formatting package of html css and javascript json for emacs
rial tips dan cara merapihkan kode css yang berantakan dengan css beautifier tools
e classic infrastructure is there a way to manually create kind of quot step groups quot that fold together in the build log i m referring to the div
finitely love and adore avivo s css js minifier beautifier mostly for options that similar tools lack like braces on own line preserve empty
baivong beautify-css newline between rules true - add a new line after every css rule e g css beautify css source text indent size 1 indent char t
cssguidelines is there a css beautifier that formats like your syntax on the site retweets 2 like 1 ux bob cssguidelines you could use css comb
beautify css code using css beautifier enter dirty minified css code to beautify format prettify and make it more readable the editor has the option
beautifier es un software online para quitar las reglas que no se usan de tus ficheros css y comprimirlos para mayor rapidez de la web
js-beautify on libhive - 159 open source examples src quot https cdnjs cloudflare com ajax libs js-beautify 1 6 14 beautify-css js quot gt lt script gt
outlook of a site mainly depends on its css but the css itself can be made to look colorful and elegant procssor is a great free service
9 m currently implementing ace as an editor for several programming languages i really want to implement a beautify functionality and currently
her you have a parsed css or a linked one you can use it code beautifier again keeps it straightforward and fuss free by only including
of wp-content plugins dopbsp templates beautify css icon name last modified size description dir parent directory - txt
index of lumberock node modules js-beautify test data css parent directory middot node mustache middot python mustache middot tests js