Format html file with HookyQR.beautifyFile command. Software I code in requires && , < , and > characters to be escaped && , < and >. When I format my code, spaces are added to the escaped characters.
example code
<script>
$(document).ready(function () {
/* darkmode */
var darkSwitch = document.getElementById("darkSwitch");
var jswitch = $("#darkSwitch");
console.log(jswitch);
console.log(darkSwitch);
if (darkSwitch) {
function initTheme() {
var darkThemeSelected = localStorage.getItem("darkSwitch") !== null &&
localStorage.getItem("darkSwitch") === "dark";
darkSwitch.checked = darkThemeSelected;
darkThemeSelected ? (
document.body.setAttribute("data-theme", "dark"),
$('table.table').addClass('table-dark'),
$('nav.navbar').removeClass('navbar-light'),
$('nav.navbar').addClass('navbar-dark')
) : (
document.body.removeAttribute("data-theme"),
$('table.table').removeClass('table-dark'),
$('nav.navbar').removeClass('navbar-dark'),
$('nav.navbar').addClass('navbar-light')
);
}
function resetTheme() {
if (darkSwitch.checked) {
$('table.table').addClass('table-dark');
$('nav.navbar').toggleClass('navbar-light navbar-dark');
document.body.setAttribute("data-theme", "dark");
localStorage.setItem("darkSwitch", "dark");
} else {
$('table.table').removeClass('table-dark');
$('nav.navbar').toggleClass('navbar-light navbar-dark');
document.body.removeAttribute("data-theme");
localStorage.removeItem("darkSwitch");
}
}
initTheme();
darkSwitch.addEventListener("click", function (event) {
resetTheme();
});
}
});
/* end darkmode */
</script>
Expected results
Expected to format code normally
<script>
$(document).ready(function () {
/* darkmode */
var darkSwitch = document.getElementById("darkSwitch");
var jswitch = $("#darkSwitch");
console.log(jswitch);
console.log(darkSwitch);
if (darkSwitch) {
function initTheme() {
var darkThemeSelected = localStorage.getItem("darkSwitch") !== null &&
localStorage.getItem("darkSwitch") === "dark";
darkSwitch.checked = darkThemeSelected;
darkThemeSelected ? (
document.body.setAttribute("data-theme", "dark"),
$('table.table').addClass('table-dark'),
$('nav.navbar').removeClass('navbar-light'),
$('nav.navbar').addClass('navbar-dark')
) : (
document.body.removeAttribute("data-theme"),
$('table.table').removeClass('table-dark'),
$('nav.navbar').removeClass('navbar-dark'),
$('nav.navbar').addClass('navbar-light')
);
}
function resetTheme() {
if (darkSwitch.checked) {
$('table.table').addClass('table-dark');
$('nav.navbar').toggleClass('navbar-light navbar-dark');
document.body.setAttribute("data-theme", "dark");
localStorage.setItem("darkSwitch", "dark");
} else {
$('table.table').removeClass('table-dark');
$('nav.navbar').toggleClass('navbar-light navbar-dark');
document.body.removeAttribute("data-theme");
localStorage.removeItem("darkSwitch");
}
}
initTheme();
darkSwitch.addEventListener("click", function (event) {
resetTheme();
});
}
});
/* end darkmode */
</script>
Actual results
Beautify does a wonderful job of formatting the code but adds spaces to the escaped characters which causes an error in the software I work with. Is there a way to create an exception for these characters in the settings? Every time I format my code I always have to do a find and replace for the escaped characters which takes a lot of time.
NOTE: Please provide code snippets instead of screen shots. Your issue needs to be replicated, and we need the failing code (text) to do this.
Provide the settings you use: (VS Code workspace and user settings, .jsbeautifyrc, .editorconfig) VS Code Workspace Settings:
VS Code User Settings:
Action performed
Format html file with
HookyQR.beautifyFile
command. Software I code in requires&& , < , and >
characters to be escaped&& , < and >
. When I format my code, spaces are added to the escaped characters. example codeExpected results
Expected to format code normally
Actual results
Beautify does a wonderful job of formatting the code but adds spaces to the escaped characters which causes an error in the software I work with. Is there a way to create an exception for these characters in the settings? Every time I format my code I always have to do a find and replace for the escaped characters which takes a lot of time.