Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ScriptsToConcat.java works with root relative URL's

Implemented nelsams fix in the ScriptsToConcat.java file and compiled it
to a class file. This fixes the issue wher the build script couldn't
handle root relative URL's in the script tags.
  • Loading branch information...
commit 8b53c80da6bdd5ef4d2ef897880d888dcd4786fa 1 parent 700003f
@tkahn authored
View
BIN  tools/ScriptsToConcat.class
Binary file not shown
View
107 tools/ScriptsToConcat.java
@@ -1,52 +1,55 @@
-// HTML5 boilerplate scripts parser
-// Daniel Holth <dholth@fastmail.fm.com>, 2012
-// Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
-
-import java.io.FileReader;
-import java.io.IOException;
-
-import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTML.Tag;
-import javax.swing.text.html.HTMLEditorKit.ParserCallback;
-import javax.swing.text.html.parser.ParserDelegator;
-
-
-/**
- * Parse an HTML file, printing the src attribute of all scripts
- * between magic <!-- scripts concatenated --> and <!-- end scripts --> comments.
- */
-public class ScriptsToConcat extends ParserCallback {
- private boolean emitting = false;
-
- @Override
- public void handleComment(char[] arg0, int arg1) {
- String text = new String(arg0);
- if(text.startsWith(" scripts concatenated ")) {
- emitting = true;
- } else if (text.startsWith(" end scripts ") ||
- text.startsWith(" end concatenated and minified scripts")) {
- emitting = false;
- }
- }
-
- @Override
- public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
- if(!emitting || t != HTML.Tag.SCRIPT) {
- return;
- }
- String scriptName = a.getAttribute(HTML.Attribute.SRC).toString();
- if(scriptName != null) {
- System.out.println(scriptName);
- }
- }
-
- public static void main(String args[]) throws IOException {
- if(args.length != 1) {
- System.err.println("Accepts exactly one argument: the filename of an HTML document.");
- System.exit(1);
- }
- FileReader fr = new FileReader(args[0]);
- new ParserDelegator().parse(fr, new ScriptsToConcat(), true);
- }
-}
+// HTML5 boilerplate scripts parser
+// Daniel Holth <dholth@fastmail.fm.com>, 2012
+// Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
+
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
+import javax.swing.text.html.HTMLEditorKit.ParserCallback;
+import javax.swing.text.html.parser.ParserDelegator;
+
+
+/**
+ * Parse an HTML file, printing the src attribute of all scripts
+ * between magic <!-- scripts concatenated --> and <!-- end scripts --> comments.
+ */
+public class ScriptsToConcat extends ParserCallback {
+ private boolean emitting = false;
+
+ @Override
+ public void handleComment(char[] arg0, int arg1) {
+ String text = new String(arg0);
+ if(text.startsWith(" scripts concatenated ")) {
+ emitting = true;
+ } else if (text.startsWith(" end scripts ") ||
+ text.startsWith(" end concatenated and minified scripts")) {
+ emitting = false;
+ }
+ }
+
+ @Override
+ public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
+ if(!emitting || t != HTML.Tag.SCRIPT) {
+ return;
+ }
+ String scriptName = a.getAttribute(HTML.Attribute.SRC).toString();
+ if(scriptName != null) {
+ if(scriptName.startsWith("/")) {
+ System.out.println(scriptName);
+ }
+ System.out.println(scriptName);
+ }
+ }
+
+ public static void main(String args[]) throws IOException {
+ if(args.length != 1) {
+ System.err.println("Accepts exactly one argument: the filename of an HTML document.");
+ System.exit(1);
+ }
+ FileReader fr = new FileReader(args[0]);
+ new ParserDelegator().parse(fr, new ScriptsToConcat(), true);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.