-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not remove first comment from HTML if it's MOTW (Mark of the WEB) #206
Comments
Not against this feature but I don't have time to spend on IE11 compatibility, sorry :) PRs welcome |
I would love to stop supporting IE11 but unfortunately, users of my projects (https://github.com/EvotecIT/PSWriteHTML) are usually running my tools on servers or are enterprise customers which often have dated defaults. Servers for the next few years will come, by default, with IE11 and until Microsoft auto deploys Edge to those I'm stuck. Not sure if I will be able to fix this in PR, but maybe - some day. Thanks for not closing this issue. |
OK, seeing as its Christmas I'll take a look! So this feature already exists! You need to modify |
Hrmm, glad to hear, but will it keep it on a separate line? It can't be touched at all. |
What do you mean? write something like this (untested)
|
For minimize process: $Pattern = "<!-- saved from url=\(0014\)about:internet -->"
$MOTW = [System.Text.RegularExpressions.Regex]::new($Pattern, [System.Text.RegularExpressions.RegexOptions]::MultiLine)
$Settings.KeepCommentsRegex.Add($MOTW) For format process: $Pattern = "<!-- saved from url=\(0014\)about:internet -->"
$MOTW = [System.Text.RegularExpressions.Regex]::new($Pattern) #, [System.Text.RegularExpressions.RegexOptions]::MultiLine)
$Settings.KeepCommentsRegex.Add($MOTW)
The regex you provided throws an error about digits or so. Input: <!-- saved from url=(0014)about:internet -->
<!DOCTYPE html>
<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"><meta content="width=device-width, initial-scale=1" name="viewport"><meta content="2020-12-30 14:16:09" name="revised"><title></title><link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap" as="style" type="text/css" rel="stylesheet preload prefetch"/><style>body { font-family: 'Roboto Condensed', sans-serif; font-size: 8pt; margin: 0px;}input { font-size: 8pt;}</style></head><body><div class="main-section"></div></body></html> Output format: <!-- saved from url=(0014)about:internet --><!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="2020-12-30 14:16:10" name="revised" />
<title></title>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap" as="style" type="text/css" rel="stylesheet preload prefetch" />
<style>
body {
font-family: 'Roboto Condensed',sans-serif;
font-size: 8pt;
margin: 0
}
input {
font-size: 8pt
}
</style>
</head>
<body>
<div class="main-section"></div>
</body>
</html> Output minimize <!DOCTYPE html><html><head><meta content="text/html; charset=utf-8" http-equiv=Content-Type /><meta content="width=device-width, initial-scale=1" name=viewport /><meta content="2020-12-30 14:16:10" name=revised /><title></title><link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed&display=swap" as=style type=text/css rel="stylesheet preload prefetch" /><style>body{font-family:'Roboto Condensed',sans-serif;font-size:8pt;margin:0}input{font-size:8pt}</style></head><body><div class=main-section></div></body></html> So minimize ignored setting. Formatting did the same thing it did without the "keepCommentsREgex", as I already have The trick for MOTW is that it can only be the only one in line. Meaning: Wrong: <!-- saved from url=(0014)about:internet --><!DOCTYPE html>
<html>
<head> Good: <!-- saved from url=(0014)about:internet -->
<!DOCTYPE html>
<html>
<head> I guess one RemoveComments is required to be $false for KeepCommentsRegex to work? Or it doesn't matter for this option? |
I've updated the XMLDOC Comments on With regards the comments remaining on the same line before the Ive added a PR to address both |
fixed in 1.13.1 |
So, I've came back to testing this - and it works fine for formatting I need new line after that comment. Any way to force it? |
At this point, I think I could always try and force adding of that comment myself outside of your library. |
During minify, all comments are removed, but some comments are crucial for Internet Explorer compatibility and JavaScript.
During formatting, the comment is followed by first tag right away which also breaks it.
Reference LINK: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/ms537628(v=vs.85)?redirectedfrom=MSDN
This is the default I have:
After formatting:
After minify:
If you don't provide saved from URL about:internet when you run HTML file with javascript as a local file in internet explorer it will prevent JS from running and prompt you to click. Just adding this special line (I know, it's weird) and following proper rules around it makes IE 11 behave properly for JavaScript code without useless prompts.
The text was updated successfully, but these errors were encountered: