I try to comment out a block of HTML which contains comments, when the time I do so, the commenting terminated at the first comment tag ending. Is there any way to do so? I didn't find it anywhere.
Let see this HTML
<!-- START overview-section -->
<div class="overview gray">
<!-- Title section -->
<div class="row">
</div>
</div>
How to comment it as a whole.
Short of breaking up the pairs of -- inside the comment, you cannot achieve this in HTML.
If you were generating your HTML from some kind of template language, you could use the template language's comment syntax instead.
You can wrap it up in a script tag and use JavaScript's block comments
<script> /***
<!-- START overview-section -->
<div class="overview gray">
<!-- Title section -->
<div class="row">
</div>
</div>
***/ </script>
this can't be done with HTML. It can however be done if it were php
<?php
//<!-- START overview-section -->
//<div class="overview gray">
// <!-- Title section -->
// <div class="row">
// </div>
//</div>
?>
Related
Noob question but I want to be able to quickly comment HTML code using keyboard shortcuts in VS code. Problem is I get this:-
<!-- <div class="whatever">
<h1>Hellow World!</h1>
<p>this is code I wrote in HTML</p>
</div> -->
instead of this:-
<!-- <div class="whatever"> -->
<!-- <h1>Hellow World!</h1> -->
<!-- <p>this is code I wrote in HTML</p> -->
<!-- </div> -->
Anyone know a good extension for this in VS Code? Thanks
Julien
See this extension written by me, Toggle Line Comments, that will do what you want.
-- or older answer --
Select through your text - i.e., from some part of the first line to some part of the last line you want separately commented. I.e., highlight your block of html to comment.
Shift-Alt-I will put a cursor at the end of each line.
Ctrl-/ will comment each line separately.
This only seems necessary for html, not js or scss for example.
I suppose if you wanted to reduce keystrokes you could make a macro for steps 2 and 3 combined.
I have this problem that I want to comment a whole section of code in HTML, this section of code already have some comments inside. now if I want to comment the whole section, how can I do it. the ctrl + / dont work anymore.....
<div class="meta">
<hr>
<!-- some comments -->
<span class="meta_date"><i class="fa fa-calendar"></i> <strong>Date:</strong>
2016.05 - 2016.06</span>
<!-- some comments -->
<div class="clearfix"></div>
</div>
You can use
<?/* html code */?>
Or
<script>/* html code */</script>
I've got an issue where my some of my markup from a file in my _/includes folder, is being printed to my page inside <p> tags.
Here's what's inside my _includes/gallery.html file:
{% assign rows = page.gallery[include.gallery] %}
</section> <!-- close this -->
</div> <!-- and this -->
</div> <!-- this too -->
<section class="image-gallery">
...
</section>
<div class="container"> <!-- open this -->
<div> <!-- and this -->
<section> <!-- this too -->
I'm trying to close out some elements, and re-open them after my .image-gallery. But for some reason, my closing and opening tags are being printed inside <p> tags
Like this:
<pre><code></section>
</code></pre>
<p></div>
</div></p>
<section class="image-gallery">
...
Is there any way to stop this from happening? It seems to only affect non-closed tags, like the ones in my example. Everything inside .image-gallery displays correctly.
Anyone know why this is happening? Any help is appreciated. Thanks in advance!
Ok, I get it.
You including _includes/gallery.html from a .md file, so markdown first includes, then try to parse the code.
As you code has unopened tags at the beginning (</section></div></div>) they are treated as markdown, not html.
Edit:
The solution is to surround your code with :
{::nomarkdown}
your code here
{:/nomarkdown}
This avoid your html to be parsed by kramdown.
Is there a plugin to help with HTML commenting a block of code that may already contain other comments?
<div class="wrapper">
<div class="container"></div>
<!-- /.container -->
</div>
<!-- /.wrapper -->
BBEdit has a built in feature where if you select all of this code and apply a block comment, it will change the existing comments temporarily so that the main block comment can be applied. The output in the editor would look like:
<!--
<div class="wrapper">
<div class="container"></div>
<!~~ /.container ~~>
</div>
<!~~ /.wrapper ~~>
-->
Uncommenting the block would set the ~ characters back to dashes - so the individual comments would still be in place.
I am not looking for this specific functionality, but something that allows for block commenting content that already contains HTML comments without having to manually remove/edit the existing comments.
I could not find a plugin that does this, so I wrote one.
Installation instructions are available at https://github.com/philsinatra/HTMLNestedComments
Is there any plugin out there that creates begin, end HTML comments automatically? Like the following.
<!-- begin #page -->
<div id="page">
<!-- begin #header -->
<div id="header">
</div>
<!-- end #header -->
</div>
<!-- end #page -->
I am tired of commenting these out.
You may use this little snippet that I wrote:
<snippet>
<content><![CDATA[
<!-- .${1:className} -->
<div class="${1:className}">
${2}
</div>
<!-- /.${1:className} -->
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>divc</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
and save it in Sublime Text #\Packages\User\divc.sublime-snippet
When you are done, you can use divc+tab to generate the required snippet
Not that i know of but you can create a custom snippet and use it when you like. This will allow you to insert that text without typing it out each time.
For directions check this link:
http://sublimetext.info/docs/en/extensibility/snippets.html
If you just want to comment something out, you can just select the content you want to comment and type ctrl + / and it will do the trick.