Disable prettier for Tailwind classes - prettier

I really want to use Prettier but i get alot of extra lines of code because I also use Tailwind and Prettier formats every class on a new line.
Can I disable this?

Yes, as per prettier documentation, in an html file you can ignore the entire elemenent, all atributes or an specific attribute (which seems to be what you want)
<!-- prettier-ignore -->
<div class="x" >hello world</div >
<!-- prettier-ignore-attribute -->
<div
(mousedown)=" onStart ( ) "
(mouseup)=" onEnd ( ) "
></div>
<!-- prettier-ignore-attribute (mouseup) -->
<div
(mousedown)="onStart()"
(mouseup)=" onEnd ( ) "
></div>
Take a look at the documentation regarding ignoring parts of the code with prettier as the way and scope of ignoring may change depending on the file type.
Prettier Ignoring code documentation

Related

Bootstrap group list shows text sprites at runtime

The code is listed below, using the bootstrap class class="list-group-item-text".
As the image here shows, the text seems to have a duplicate version just above it - looks almost like dotted lines.
`
<asp:Panel ID="pnlInstructions" runat="server" Visible="true">
<h4>Instructions:</h4>
<div class="form-inline col-lg-12" id="Instructions" style="padding-top:10px;padding-bottom:20px;padding-left:10px;">
<ol class="list-group-item-text" style="text-emphasis:filled;outline:none;">
<li>First, please use MyEd to get your extract file ready.</li>
<li>Then, fill in the following to Log in.</li>
</ol>
</div>
</asp:Panel>
`
I've researched the problem using the word "sprites", but that seems to have a different meaning than I expected, since I thought it meant "unwanted junk" in a display.
I'm not sure if this appears on all browsers.

How can I specify HTML5 output from RMarkdown to get semantic elements like <section>?

I noticed that in HTML produced by knitr from my RMarkdown document, sections are marked up thus:
<div id="chunk_id" class="section level2">
<h2>...</h2>
<p>...</p>
</div>
and so on. I think it's best practice to use a <section> element rather than a <div> here (reference 1, reference 2), so I forked the RMarkdown code to see if I could make a change and a PR. In the code I found the following:
#'#param section_divs Wrap sections in <div> tags (or <section> tags in HTML5),
#' and attach identifiers to the enclosing <div> (or <section>) rather than the
#' header itself. ```
so it seems like there is no need for a change to RMarkdown - it will already use <section> in the way I want, if it is told to output HTML5.
My question is: how do you tell knitr to output HTML5? I have
output:
html_document:
section_divs = TRUE
but no idea how to "switch on" HTML5.

Line breaks within indented <source> tag

I have not been able to find an answer to this anywhere.
I am working on an internal Wiki entry. I have code that I want to include inside a <source> tag. Because the <source> tag is inside a bulleted list, I want it indented.
Here's my problem: my code includes multiple lines, and I want to insert line breaks in the code example. But for whatever reason, Wiki markup won't let me do this.
When I try to insert a carriage return, the <source> formatting disappears for the new line.
When I try to insert a <br /> tag, the tag actually shows up; it does NOT break the line!
So far, the only workaround I've found is something like this -- which is NOT what I want!!!
:<source lang="sql">select * from table1</source>
:<source lang="sql">select * from table2</source>
NO!!! What I want is something like this:
:<source lang="sql">select * from table1
select * from table2</source>
--note the line break for the second SELECT statement!
--also note the ':' that indicates that I want it indented!
--when I try it this way, the <source> formatting for the second line disappears!
--I also tried adding the ':' to the second line -- that doesn't work, either!
I've also tried this, but it doesn't work, either!
:<source lang="sql">select * from table1<br />select * from table2</source>
--when I try this, the <br /> tag actually shows up; it does NOT break the line!
In other words, I want both individual lines to appear within the same indented <source> tag.
How do I get this to work?
I discovered that the answer is not to use Wiki markup for bullet lists at all. Instead, use HTML markup.
Example:
<ul>
<li>list 1</li>
<li>list 2
<source lang="sql">select * from table1
select * from table2</source>
</li>
</ul>
As soon as I abandoned the Wiki markup method of using bulleted lists and indents, and instead used straight HTML, it did exactly what I wanted.

How to filter the html markups when render a template with jinja2?

Now I'm biulding a django project with jinja2 dealing with templates. Some page contents are submited by the client with wysiwy editor, and thing's going fine with the detail pages.
But the list pages are wrong with the slice of the contents.
My code:
<div class="summary ">
<div class="content">{{ question.content[:200]|e}}...</div>
</div>
But the output is:
<p>what i want to show here is raw text without markups</p>...
The expected result is that the html markups like <p></p> <section>.... are gone (filtered or eliminated) and only the raw text shows!
So how can I fix it? Thanks in advance!
Use striptags filter:
striptags(value)
Strip SGML/XML tags and replace adjacent whitespace
by one space.
<div class="content">{{ question.content|striptags}}...</div>
Jinja2 striptags filter test will also help you to understand how it works.
Hope that helps.

Change vim indenting format

I want to add to the way html is indented in vim. I'm doing django development and I would like to indent whenever a django template tag is used. Currently, using filetype indent, it does not indent after the template tags. So currently my code looks like this:
{% do_something %}
<div>
<p>Hello</p>
</div>
{% end %}
And I'd like for it to recognize the {% %} as a tag and indent like so:
{% do_something %}
<div>
<p>Hello</p>
</div>
{% end %}
Is there a filetype plugin for this or a way I can add {% %} to the list of things that should be indented after?
When you have filetype indent on for an html file it will use the indenting rules found in the ../vim/vim73/indent subdirectory in file html.vim.
The braces you want to use as signaling indent of next line are, I'm sure, not treated in html.vim because they're not part of html. You can alter the rules in html.vim to get it done the way you want.
See :h indent-expr for a bit of info and you will also want to look at other files in the /indent directory to see how it works.
There is an alternate html.vim you can get at vim website, maybe it is better than html.vim that ships with Vim:
http://www.vim.org/scripts/script.php?script_id=2075
There is a pending pull request for the django.vim project to include an alternative django-custom vim implementation from Steve Losh. This works, for the most part, better than the default one.