Skip to content

Conversation

slickplaid
Copy link

... such as jspx which can mangle code and cause browsers to improperly format it to the user.

The Problem

I'm working on a project that utilizes Java's JSPX format which pre-processes HTML files served to the user. I am working on integrating a front-end build process to their workflow, but the JSPX processing is so heavy handed that there is absolutely no option for disabling some "features" that force empty tags into self terminating tags.

<script src="..."></script> turns into <script src="..." />, <link ...> without a self terminated / completely breaks compilation. I have looked into patching the behavior on the pre-processors end, but they give no options or concessions on that it needs to work that way.

Proposed Solution

Add two options:

  • strictCssXML --- one for formatting the <link> tag to make it self terminated
  • strictScriptXML --- another for formatting the <script> tag with a CDATA tag in the empty space

I have included a proper fix for pull request #12 and made it an option rather than forcing it for the user.

All tests and linting should be passing, although I had to make a concession to not pass the options object to the formatter and instead pass it to the bb object because of some linting rules that were violated with number of arguments and number of statements in a function. Hopefully these are to the project's standards.

Let me know if there's anything else I can do to get these options into the package. I'd prefer to use this widely accepted package vs. my one-off branch that includes these options for the small (but non-zero, if myself and #12 's show) amount of users who have this same problem.

…s such as jspx which can mangle code and cause browsers to improperly format it to the user.
@coveralls
Copy link

coveralls commented Aug 12, 2016

Coverage Status

Changes Unknown when pulling 8b5b733 on slickplaid:slickplaid-patch-2 into * on jonkemp:master*.

@slickplaid
Copy link
Author

Just to comment on the 8b5b733 commit: I have no idea how those files weren't included in my original fork from your project. I've included them now.

@jonkemp
Copy link
Owner

jonkemp commented Aug 30, 2016

Sorry it's taken so long to get to this. For what you are wanting, you may be able to use custom blocks. Documentation is here:

https://github.com/jonkemp/useref#custom-blocks

I was able to get your test passing this way without using your code changes.

var useref = require('useref');
var result = useref(inputHtml, {
  test: function (content, target, options) {
    return '<link rel="stylesheet" href="/css/combined.css"/>';
  }
});
var useref = require('useref');
var result = useref(inputHtml, {
  test: function (content, target, options) {
    return '<script src="scripts/combined.concat.min.js">//<![CDATA[ //]]></script>';
  }
});

@jonkemp jonkemp mentioned this pull request Aug 30, 2016
@jonkemp jonkemp closed this Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants