Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas C. Zakas committed Jun 6, 2011
0 parents commit f685544
Show file tree
Hide file tree
Showing 13 changed files with 5,173 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
csslint.pnproj
build/
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2011 Nicole Sullivan. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
87 changes: 87 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<project name="csslint" default="all">

<!-- the directories containing the source files -->
<property name="src.dir" value="./src" />

<!-- the directories and files to output to -->
<property name="build.dir" value="./build" />

<!-- the directory containing library files -->
<property name="lib.dir" value="./lib" />

<!-- output filenames -->
<property name="www.build.file" value="csslint-www.js"/>
<property name="node.build.file" value="csslint-node.js"/>
<property name="rhino.build.file" value="csslint-rhino.js"/>

<loadfile property="license.text" srcfile="LICENSE" />


<!-- build the WWW library -->
<target name="build.www">

<concat destfile="${build.dir}/${www.build.file}" fixlastline="true">
<header trimleading="yes">/*
${license.text}
*/
(function(){
</header>
<fileset dir="${lib.dir}" includes="*.js" />
<filelist dir="${src.dir}/core" files="CSSLint.js" />
<fileset dir="${src.dir}/core" includes="*.js" excludes="CSSLint.js"/>
<fileset dir="${src.dir}/rules" includes="*.js" />
<fileset dir="${src.dir}/www" includes="*.js" />
<footer trimleading="yes">
})();
</footer>
</concat>

</target>

<!-- build the Node.js library -->
<target name="build.node">

<concat destfile="${build.dir}/${node.build.file}" fixlastline="true">
<header trimleading="yes">/*
${license.text}
*/
(function(){
</header>
<fileset dir="${lib.dir}" includes="*.js" />
<filelist dir="${src.dir}/core" files="CSSLint.js" />
<fileset dir="${src.dir}/core" includes="*.js" excludes="CSSLint.js"/>
<fileset dir="${src.dir}/rules" includes="*.js" />
<fileset dir="${src.dir}/node" includes="*.js" />
<footer trimleading="yes">
})();
</footer>
</concat>

</target>

<!-- build the Rhino library -->
<target name="build.rhino">

<concat destfile="${build.dir}/${rhino.build.file}" fixlastline="true">
<header trimleading="yes">/*
${license.text}
*/
var CSSLint = (function(){
</header>
<fileset dir="${lib.dir}" includes="*.js" />
<filelist dir="${src.dir}/core" files="CSSLint.js" />
<fileset dir="${src.dir}/core" includes="*.js" excludes="CSSLint.js"/>
<fileset dir="${src.dir}/rules" includes="*.js" />
<fileset dir="${src.dir}/rhino" includes="*.js" />
<footer trimleading="yes">
})();
</footer>
</concat>

</target>


<!-- Build all files -->
<target name="all" depends="build.www,build.node,build.rhino"/>

</project>
85 changes: 85 additions & 0 deletions demos/CSSLintDemo.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html>
<head>
<title>CSS Parser Demo</title>
<script type="text/javascript" src="../build/csslint-www.js"></script>
<style type="text/css">
.error { color: red; }
</style>
</head>
<body>
<h1>CSSLint Demo</h1>
<textarea rows="10" cols="40" id="input">
@charset "UTF-8";

@import url("booya.css") print,screen;
@import "whatup.css" screen;
@import "wicked.css";

@namespace "http://www.w3.org/1999/xhtml";
@namespace svg "http://www.w3.org/2000/svg";

li.inline {
background: url("something.png");
display: inline;
padding-left: 3px;
padding-right: 7px;
border-right: 1px dotted #066;
}

li.last {
display: inline;
padding-left: 3px !important;
padding-right: 3px;
border-right: 0px;
}

@media print {
li.inline {
color: black;
}
}

@page {
margin: 10%;
counter-increment: page;

@top-center {
font-family: sans-serif;
font-weight: bold;
font-size: 2em;
content: counter(page);
}
}
</textarea>
<input type="button" id="lint-btn" value="Run CSSLint">
<p>(You may want to keep the CSS kinda small, this could take a while.)</p>
<div id="output">

</div>
<script>
(function(){

document.body.onclick = function(event){
event = event || window.event;
var target = event.target || event.srcElement,
results, messages, i, len;

if (target.id == "lint-btn"){
results = CSSLint.verify(document.getElementById("input").value);
messages = results.messages;
for (i=0, len=messages.length; i < len; i++){
log(messages[i].message + " (line " + messages[i].line + ", col " + messages[i].col + ")", messages[i].type);
}

}
};

function log(value, level){
var output = document.getElementById("output");
output.innerHTML += "<span class=\"" + level + "\">" + value.replace(/ /g, "&nbsp;") + "</span><br>";
}
})();
</script>
</body>
</html>
Loading

0 comments on commit f685544

Please sign in to comment.