Visual Studio 2010 html indenting - html

In visual studio, when I paste an html snippet into the source window of an aspx/ascx file the IDE re-indents the contents. For instance, if I paste this ...
<div><ul><li>Item 1</li><li>
Item 2</li><li>Item 3</li></ul>/div>
.. the ide will reformat the text to ....
<div>
<ul>
<li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>
</div>
But really, I want the html formatted like this ...
<div>
<ul>
<li>
Item 1
</li>
<li>
Item 2
</li>
<li>
Item 3
</li>
</ul>
</div>
How do I change the way VS indents html to the above?

You can change this by introducing custom formatting for the text (HTML) editor, got to:
Options -> Text Editor -> HTML -> Formatting -> Tag Specific Options (Button)
-> Client HTML Tags -> a -> Set Line breaks dropdown to Before and after
Do this for all the tags you want formatted differently.

Ctrl+K then Ctrl+D, will format the current document.
Ctrl+K then Ctrl+F, will format the selected text.

Related

How can I add a class attribute to the `<ul>` tag in the automated table of contents in Rmarkdown?

The organization that I work for has a HTML template for our website. I'm using this template as a custom HTML template in R markdown:
---
title: "My report"
output:
html_document:
template: my-template.html
toc: true
---
Below is a snippet of the HTML template for our website. As with everything else in the template, the table of contents follows my organization's style guide. The HTML code for the table of contents is this:
<div class="panel-body">
<ul class="sidebar-items">
<li>header 1</li>
<li>Header 2</li>
<li>Header 3</li>
</ul>
</div>
I need to customize this template by inserting pandoc variables so that I can use it as my html template in Rmarkdown.
My problem is this: how can I do this and still keep the class="sidebar-items" attribute in the <ul> tag?
I've tried this:
<div class="panel-body">
<ul class="sidebar-items">
$toc$
</ul>
</div>
But the result of course is an extra pair of <ul>-tags:
<div class="panel-body">
<ul class="sidebar-items">
<ul>
<li>header 1</li>
<li>header 2</li>
<li>header 3</li>
</ul>
</ul>
</div>
How can I prevent this, but still include the class="sidebar-items" attribute?
I could just change it manually in the output HTML file from Rmarkdown, but the problem is that I
need to create many HTML files, and I would very much like to avoid this extra manual
work.
Thanks a lot for your help!
As #mb21 points out in the comments: there is currently no (easy) way to this via pandoc. You could use a pandoc filter to create the TOC yourself, but that would be a bit of an effort.
I suggest to either
post-process the HTML output,
add a JavaScript snippet to insert the desired classes or
rewrite the CSS/JS code which depends on the sidebar-items class to use a different selector.

common mark / vscode table of contents not working

I'm using the current version visual studio code and extensions Markdown All in One, Markdown Paste, markdownlint, and Markdown+Math.
in markdown I write:
## Table of Contents
1. [heading](##heading%201)
2. [heading](##heading%202)
## heading 1
...
## Heading 2
This works as expected in the preview screen, which is nice but irrelevant
In Html I get
<h2 id="table-of-contents">Table of Contents</h2>
<ol>
<li>heading 1</li>
<li>heading 2</li>
</ol>
<h2 id="heading-1">heading 1</h2>
...
<h2 id="heading-2">heading 2</h2>
and while the links navigate to file:///c:....html#heading%20X the broswer, current version of chrome, doesn't jump to the right spot.
How can I fix this? Is it a problem with the md to html transformation or the file protocol?

is this a valid html- an a tag inside text?

<li> text text ( text ) </li>
I don't know it confuses me, an a tag inside li tag between 2 parentheses ?
Yes:
<li> text text ( text ) </li>
If not, you wouldn't be able to do things like
<ul>
<li>this is a list item with an inline link</li>
</ul>
Html is a very flexible language and some bad codes works that you think that will never works! But your code has no problem.
And you could write that in this way:
<li> text text (text) </li>

Rmarkdown Slidy indented lists

I use Rmarkdown with slidy mostly. I like it because I can use html tags outside of r code chunks (perhaps it is do-able in other formats, no idea). However I run into trouble with indented lists.
---
title: "Test"
author: "Me"
date: "Today"
output:
slidy_presentation
---
## Test Slide
<ul>
<li>One Bullet Point
</ul>
This works like a charm.
Output (html):
<div id="test-slide" class="slide section level2">
<h1>Test Slide</h1>
<ul>
<li>
One Bullet Point
</ul>
</div>
However:
## Test Slide Indented
<ul>
<li>One Bullet Point
<ul>
<li>One Indented Bullet Point
</ul>
</ul>
Causes trouble. Output (html again):
<div id="test-slide-indented" class="slide section level2">
<h1>Test Slide</h1>
<ul>
<li>
One Bullet Point
<ul>
<pre><code> <li>One Indented Bullet Point</code></pre>
</ul>
</ul>
</div>
And thus "list within the list" appears as a code chunk rather than an indented list in the html document.
You have four spaces preceding the line with the list element. This means that pandoc will interpret that line as a code chunk. As far as I know there's no option to prevent this, so you will need to remove the indenting before the html tags.
http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#verbatim-code-blocks
I will also point out that markdown supports nested lists so there's no need to use html tags in your example:
- One bullet point
+ One indented bullet

Auto-indentation in C#

Is there an open-source library or code-sample in C#, that will re-indent a string of HTML code?
For example, convert this:
<li>
this
</li><li>that
</li>
To this:
<li>
this
</li>
<li>
that
</li>
Note: I don't want any of the HTML to be altered or moved around the way HTML Tidy does.
I only want the markup to be re-indented, nothing else.
Using Notepad++ if you paste your sample in and choose Language | Html and then Text FX | Text FX Html Tidy | Tidy Reindent Xml ...
Your sample becomes:
<li>
this
</li>
<li>
that
</li>