How to disable editing some tag in block of tags that ending tag is modified automatically? - phpstorm

Working with PhpStorm ( version 2021.2 ) sometimes I found it very
inconvenient when editing some tag in block of tags that ending tag is modified automatically. Say when modifying tag <section> into </div>.
Is there an option to disable this behavior?
Maybe preferable way is to disable this behavior temporary, say when holding some hot key?
Thanks in advance!

Is there an option to disable this behavior?
Sure:
Settings (Preferences on macOS)
Editor | General | Smart Keys
HTML/CSS | Simultaneous '<tag></tag>' editing
Say when modifying tag <section> into </div>.
I see no problem with such editing. Section has the closing </section> tag so the IDE just edits both places at the same time (from section to div).
Unless you have a broken HTML (not balanced open/closing tags) already...
Maybe preferable way is to disable this behavior temporary, say when holding some hot key?
No. But if you disable the aforementioned option then you can still edit both open and closing tag at once -- just manually invoke Refactor | Rename on it.

Related

How can I prevent Cloudfare from deleting a HTML tag?

A client is using Cloudfare to deliver his web content but their filters are removing tags that are unknown to them. Unfortunately that breaks the service that we provide.
For example, before the DOCTYPE tag we use a tag of our own like <!-- Example --> which tells our server filter to encrypt the HTML that follows. But Cloudfare filters are removing that tag, and thus breaking the service.
Do they have a whitelist or something that can be used to prevent the corruption?
You Just don't minify the HTML,CSS And JavaScript.
just skip them while you adding the domain. it works for me.
So you want to preserve html tags similar to "comments" that don't normally appear on a page?
Page speed modifiers strip such tags because they are not important to a page and thus are not necessary. By removing all comments a few Bytes can be removed from the download of a page. On most pages that will make little difference, but some websites, especially those running a CMS with a multitude of plugins, can contain a lot of comments.
So it is page speed enhancement that you need to disable to preserve such tags.
Cloudfare provides a Control Panel to make adjustments. In the top menu, click on "Rules" to Create a Page Rule for your website. Then enter the URL of the page that you want to exempt. Enclosing the URL in asterisks [*] will cater for all similar urls, like example.com/special. Then pick a setting by selecting "Disable Performance".
This will create a rule to disable pagespeed enhancement of all pages that include "example.com/special" in their URL.

How to blacklist additional HTML tags in MediaWiki?

I really dislike the non-semantic usage of <big> on our wiki, and would like to prevent it. Flat-out commands didn't work so far, so I'm switching to doing it by code...
AFAIK, there's no configuration switch to control the blacklist/whitelist of HTML tags. Looking at the source code, it seems like the data is coming from Sanitizer::getRecognizedTagData(), while the work itself is done in Sanitizer::removeHTMLtags(). However, I do not see a way to add to the list myself, except using one of the hooks before or after (InternalParseBeforeSanitize, InternalParseBeforeLinks) and either:
Call Sanitizer::removeHTMLtags() again myself, with the additional tag to blacklist as a parameter
Do a search myself on the text to remove all the <big> tags.
The first one is a duplication of work, the second one is a duplication of code. Is there a better way? What would you recommend?
No coding is needed: just install AbuseFilter and create a rule that warns or disallows on save of pages containing these tags.

Regular Expressions to fix invalid HTML

I have hundreds of files (ancient ASP and HTML) filled with outdated and often completely invalid HTML code.
Between Visual Studio and ReSharper, this invalid HTML is flagged and easily visible if the editor window is scrolled to where the invalid HTML appears. However, neither tool is providing any method to quickly fix the errors across the whole project.
The first few errors on which ReSharper focuses my attention are tags that are either not closed or closed but not opened. Sometimes this occurs because the opening and closing tags overlap - for instance:
<font face=verdana size=5><b>some text</font></b>
<span><p>start of a paragraph
with multiple lines of <i><b>text/hmtl
</i> with a nice mix of junk</b>
</span></p>
Sometimes opening tags without a corresponding closing tag were allowed in older versions of HTML (or the tools which generated the HTML didn't care about the standards as some browsers usually figured out what the author meant). So the mess I'm attempting to clean up has many unclosed HTML tags that ought to be closed.
<font face = tahoma size=2>some more text<b><sup>*</sup></b>
...
...
</body>
</html>
And just for good measure, the code includes lots of closing HTML tags that have no matching start tag.
</b><p>some text that is actually within closed tags</p>
</td>
</tr>
</table>
So, other than writing a new application to parse, flag, and fix all these errors - does anyone have some .Net regular expressions that could be used to locate and preferably fix this stuff with Visual Studio 2012's Search and Replace feature?
Though a single expression that does it all would be nice, multiple expressions that each handle one of the above cases would still be very helpful.
For the case of overlapped HTML tags, I'm using this expression:
(?n)(?<t1s>(?><(?<t1>\w+)[^>]*>))(?<c1>((?!</\k<t1>>)(\n|.))*?)(?<t2s>(?><(?!\k<t1>)(?<t2>(?>\w+))[^>]*>))(?<c2>((?!(</(\k<t1>|\k<t2>)>))(\n|.))*?)(?<t1e></\k<t1>>)(?<c3>(?>(\n|.)*?))(?<t2e></\k<t2>>)
Explanation:
(?n) Ignore unnamed captures.
(?<t1s>(?><(?<t1>\w+)[^>]*>)) Get the first tag, capturing the full tag and attributes
for replacement and the name alone for further matching.
(?<c1>((?!</\k<t1>>)(\n|.))*?) Capture content between the first and second tag.
(?<t2s>(?><(?!\k<t1>)(?<t2>(?>\w+))[^>]*>)) Get the 2nd tag, capturing the full
tag and attributes for replacement, the name along for further matching, and ensuring
it does not match the 1st tag and that the first tag is still open.
(?<c2>((?!(</(\k<t1>|\k<t2>)>))(\n|.))*?) Capture content between the second tag
closing of the first tag.
(?<t1e></\k<t1>>) Capture the closing of the first tag, where the second tag is
still open.
(?<c3>(?>(\n|.)*?)) Capture content between the closing of the first tag and the closing
of the second tag.
(?<t2e></\k<t2>>) Capture the closing of the second tag.
With this replacement expression:
${t1s}${c1}${t2s}${c2}${t2e}${c3}${t1e}
The issues with this search expression is that it is painfully slow. Using . instead of (\n|.) for the three content captures is much quicker, but limits the results to just those where the overlapped tags and intervening content are on a single line.
The expression will also match valid, properly closed and properly nested HTML if the first tag appears inside the content of the second tag, like this:
<font color=green><b>hello world</b></font><span class="whatever"><font color=red>*</font></span>
So it is not safe to use the expression in a "Replace All" operation, especially across the hundreds of files in the solution.
For unclosed tags, I've successfully handled the self-closing tags: <img/>, <meta/>, <input/>, <link/>, <br/>, and <hr/>. However, I've still not attempted the generic case for all the other tags - those that may have content or should be closed with a separate closing tag.
Also, I've no idea how to match closing tags without a matching opening tag. The simple solution of </\w+> will match all closing tags regardless of whether or not they have a matched opening tag.
According to their website, Resharper has this feature:
Solution-Wide Analysis
Not only is ReSharper capable of analyzing a specific code file for errors, but it can extend its analysis skills to cover your whole solution.
...
All you have to do is explicitly switch Solution-Wide Analysis on, and then, after it analyzes the code of your solution, view the list of errors in a dedicated window:
[
Even without opening that window, you can still easily navigate through errors in your solution with Go to Next Error in Solution (Shift+Alt+PageDown) and Go to Previous Error in Solution (Shift+Alt+F12) commands.
Your current "solution" is to use regexes on a context-sensitive language (invalid HTML). Please, NO. People flip out already when people suggest parsing context-free languages with regexes.
On second thought, there might be a solution that we can use regexes for.
For this HTML:
<i><b>text/html
</i> with a nice mix of junk</b>
A better transformation would be (it's more valid, right?):
<i><\i><b><i>text/hmtl
</i> with a nice mix of junk</b>
There are many ways this could go wrong, (although it's pretty bad as-is), but I assume you have this all backed up. This regex (where i is an example of a tag you may want to do this with):
<(i(?: [^>]+)?)>([^<]*)<(\/?[^i](?: [^>]+)?)>
Might help you out. I don't know how regex replace works in whatever flavor you're using, but if you replace $0 (everything matched by the regex) with <$1>$2</$1><$3><$1>, you'll get the transformation I'm talking about.

Umbraco: Customising RTE to work with HTML tags

I am using Umbraco 7 CMS to set up a website. Within the pages, I have several RichText Editors that I would like to customise to accept tags (namely the abbr tag).
I googled this, and came across the following instructions;
Editing the tinyMceConfig file to accept new commands, namely umbracoAlias acronym and abbr.
Editing the CDATA to accept new information in the ValidElements section of tinyMceConfig file.
Editing the web.Config in order to force Umbraco to reload.
Selected the new fields (they are visible now in Umbraco when they weren't before) acronym and abbr in the RTE section of the Developer tag. The site now said I should see 2 checkboxes appear on the RTE in order to create inline styles when typing in the RTE.
Reloaded nodes, republished site, logged in and out of Umbraco numerous times but they do not show on the RTE.
Any ideas as to how I can try to fix this? It's really annoying! Thanks a lot.
This is due to TidyHtml and is an unfortunate issue indeed!
I just ran across the same problem myself and was curious if there has been any update since i answered this question for umbraco4.8 a year ago.
I was hoping that it would have been resolved in the releases up to umbraco7, but no luck.
Umbraco documentation shows /config/umbracosettings.config sections where Tidy can be disabled.
Heads up that the TidyEditorContent element is no longer in the default instalation of this file but can easily be added back under the content section:
<content>
<TidyEditorContent>False</TidyEditorContent>
<errors>
<error404>1</error404>
This may not be what you want since by removing this Tidy cleanup - you lose control and introduce potential nastyness... I have just verified that it will allow abbr tags through though.

What web admin wysiwyg preview options are available?

I have a web admin where there is a wysiwyg editor when a user edits information.
There is also a view only template.The user views the information before clicking an edit action.
Currently the view template results in one line for the saved field value.
<p><b>Hello</b></p><p>there</p>
What options do I have to al least make the a little more readable when the user is "viewing"?
Options I can think of are:
Leave as it. Well, that can become a long line of text.
Somehow to avoid encoding of MVC3 and to add actual <br> in place of the </p> or <br> that is in the content. At least the lines will break up.
Have the content actually present as html. This is, you will see bold. What if there is an unclosed tag.
With any of the above, i may place it in a scrollable div.
(I had trouble tagging this question. Feel free to retag).
Typically when you are working with editors you are going to eventually be presenting the HTML live on the site anyway, so encoding shouldn't be a big concern as you are already trusting them.
Now, what I've done in the past is with using editors, such as ckeditor, etc, they cleanup the content which would fix the issue with your concern about unclosed tag.
so I would go with option 3 on your list.
Also ensure that any editor you support encoded data before sending to the server. Do not turn off request validation.
Use the [AllowHtml] attribute on a model property if necessary.
Also use the Anti-xss library from Microsoft - specifically the HTML sanitizer to help remove evil script and help protect against cross site scripting.