locate missing html tags in emacs - emacs

How can I validate that all tags have been closed in emacs?
<div>
hi
<div id="2">
hello
<div>
The above being a very simple example of a missing div. How can i see in emacs which html tag is missing?

If it is XHTML, nxml-mode can validate it automatically. That's what I am using. (I.e. I switch to nxml-mode for validation, though I usually use html-mode.)

Related

keycloak translation / message with link should open in new Tab

I would like to have a translation in my messages_en.properties containing a link, which opens in a new tab. Is there a way to do this?
I already tried to add
<a target="_blank" href="http://example.com">Example</a>
and
<a href="#" onclick='window.open("http://example.com");return false;'>Example</a>
without success.
Thanks in advance
Most likely your HTML isn't working because of kcSanitize in the template file. Wherever HTML messages are allowed, Keycloak's FreeMarker templates will also wrap the text with this method which:
Allows sanitizing of html that uses Freemarker ?no_esc. This way, html
can be allowed but it is still cleaned up for safety. Tags and
attributes deemed unsafe will be stripped out.
The no_esc allows HTML to render (by not being escaped) but the kcSanitize strips unsafe tags and attributes first. In my testing, I found that "target" and "onclick" are stripped out.
One way that works but that I wouldn't recommend for safety is removing the kcSanitize() around where your message displays in the corresponding .ftl file.
Another idea is adding an id or class to the element in your .properties file and using custom Javascript to set the target="_blank" attribute.

Handlebars formatting in NetBeans

I'm using NetBeans as my IDE for a Ember.js project. When I create handlebars templates in my app like below the code highlighting doesn't work correctly.
<script type="text/x-handlebars">
<div>
</div>
</script>
Normally, when I'd select the first div, it and its matching end tag would highlight yellow, but this doesn't work. Since its inside the handlebars script tag both are highlighted red as errors and don't match together. This makes writing complex templates kinda annoying as it can be difficult to pinpoint syntax errors.
Is there anyway to get NetBeans to highlight inside the handlebars tag as if its regular html?
One option, until Netbeans implements this enhancement, is to add the following script tag in index.html immediately after your reference to jQuery:
<script src="js/libs/jquery.js"></script>
<!-- use following line to change script type to 'text/x-handlebars' -->
<script>jQuery('script[type="text/html"]').attr('type', 'text/x-handlebars');</script>
This is a variation of the answer provided by GCoda.
I had the same problem and tried various non satisfying fixes.
In the end I figured the best solution is simply to change the script's type attribute to text/html:
<script type="text/html">
<div>
</div>
</script>
I got same problem. And i just used a some kind of postprocessing, i am using node.js, so i did res.send(data.replace(/type="text\/html"/g,'type="text/x-handlebars"')); on my / page.
I think you can do something similar in you language, and ofcource this is not a fix, just an ugly trick to make developing more easy. Dont keep it in production.

HTML comment tag <!-- --> Removed in CQ5

I'm using Rich Text Editor with MiscTools plugin to edit text in CQ%
However when I open the HTML editor and create sth like this
<div id="test">Test <!-- Test Comment --></div>
the CQ rewrites it to after switch back to HTML mode and source edit mode
<div id="test">Test </div>
Is it possible to keep HTML comment tag <!-- --> in the source code?
Thank you for answer my question
I would suggest taking it out of the div and see if that works.
In CQ5.4-5.6.1 (not sure about latest version AEM6), the Rich Text Editor intentionally strips out all HTML comments. The only way to stop it from doing this is to modify the product javascript source code in WhitespaceProcessor.js. However, allowing HTML comments in this way wouldn't be recommended as it hasn't been fully tested it might cause other errors. If you still need this feature, then you might consider contacting Adobe Customer Care to request it to be officially added to the product.

Incorrect MIME type for GET requests

I've been using the Lift Web Framework as a REST only service for quite a while, but I need to use it as a stand alone tool now.
<lift:surround with="default" at="content">
<head>
<script data-lift="with-resource-id" src="/test.js" type="text/javascript"></script>
</head>
<h2>Welcome to your project!</h2>
<p><lift:helloWorld.howdy /></p>
</lift:surround>
I have the above very basic Lift template. The problem is when I view it in the browser something is adding an <?xml> DOCTYPE and the browser defaults to interpreting the resource as XML instead of plain HTML.
How do I tell Jetty/Lift that my static file is HTML?
Sounds like you may be using the XHTML doctype. In your Boot.scala file, you may want to try adding:
LiftRules.htmlProperties.default.set((r: Req) =>
new Html5Properties(r.userAgent))
That should set your application to use HTML5, and should turn off adding the <?xml... encoding header.
Also, as #VasyaNovikov mentioned, the lift: prefixed tags are an older construct (even though a lot of documentation still mentions them). They still work but will have some issues with HTML5. It is recommended to use either of the equivalent forms:
Original:
<lift:surround with="default" at="content">...</lift:surround>
HTML5:
<span data-lift="surround?with=default;at=content"></span>
<span class="lift:surround?with=default;at=content"></span>
If you want to use the lift: variety, the biggest issue you'll find is that in HTML5 the tags and attributes are converted to lowercase, so <lift:helloWorld.howdy /> will be interpreted as <lift:helloworld.howdy />, and Lift will not find the snippet. Using <span data-lift="helloWorld.howdy"></span> should allow you to work around that.
Maybe adding the header will help?
<html>
<head>...
Example:
https://github.com/lift/lift_25_sbt/blob/master/scala_29/lift_basic/src/main/webapp/index.html
In general, you use a very old approach to templates, with custom tags <lift:surround>, <lift:helloWorld> and such. Where did you get them? I suggest to use the new template style like in the link I posted.

Objective C Hpple to get commented element information

I'm starting my iPhone programming adventure, with a simple HTML scraping. I'm using the Hpple library to do the job, and I have a question...
Suppose I have the following html to parse...
<div>
<div> A <!-- Comment 1 --></div>
<div> B </div>
<div> C <!-- Comment 2 --></div>
</div>
How can I retrieve the commented parts? They don't show up on the objects... I was checking the docs but there's nothing pointing to that direction.. (also googling "hpple comment" doesn't produce the best results...).
thanks in advance.
Comments are not considered part of the content and are stripped out by pretty much all parsers except humans.
Similarly, you can't ask the parser to tell you how many spaces and newlines are between the first two <div> elements.