html to jade error when contains <pre> - html

I have some static html documents, and I want to convert them into Jade. I tried html2jade in npm, everything is OK except this: the <pre> elements in html convert empty, can someone help me?
The html code looks like this:
<pre><code><p>Hello</p><span>Hello Again</span></code></pre>
The result is:
pre.

You can write that a couple different ways in Jade. Here are two different methods. The first takes advantage of Jade's automatic escaping while the second uses HTML entities instead.
Automatic escaping:
pre
code= '<p>Hello</p><span>Hello Again</span>'
HTML entities:
pre
code <p>Hello</p><span>Hello Again</span>

Related

EE Core: How do I pass entry data to an embedded template

I had code like this:
{exp:channel:entrieschannel="blog_channel"limit="10"}
<h1>{entry_title}</h1>
<p>{entry_body}</p>
<p>{entry_author}</p>
{/exp:channel:entries}
Basically I want the HTML content with the exp tags to be made separate and placed in a template file. I attempted this by doing this:
{exp:channel:entries channel="blog_channel"limit="10"}
{embed="blog/post"}
{/exp:channel:entries}
My problem is the output all the tags ({entry_title}, {entry_body} etc etc) are being shown literally and the they are not being treated as a variable.
How can I fix this?
Thanks,
Peter
For what it appears you're looking to do, i might suggest avoiding an embed and instead using a snippet. They're more efficient but still allow you to have the same markup used in more than one template, for example, so you don't have to repeat yourself. Some something like this:
{exp:channel:entries channel="blog_channel" limit="10"}
{sn_blog_post_list}
{/exp:channel:entries}
And then in your snippet, which in this case is called "sn_blog_post_list":
<h1>{entry_title}</h1>
<p>{entry_body}</p>
<p>{entry_author}</p>
This would allow you to use the same snippet for different instances of the entries loop. SO in a different template, you could do something like:
{exp:channel:entries channel="blog_channel" limit="30"}
{sn_blog_post_list}
{/exp:channel:entries}
And so this would again apply the exact same markup to each blog entry, but return 30 entries instead of 10 as with the earlier example without having to repeat the markup.
Hope that helps.

How to show the string inside a tag verbatim?

What tag can I use to prevent any interpretation? I need that because I need to write down some source code and it's result in blogger. I have this code in blogspot, but the code inside the <pre> is processed
The code is as follows:
<pre class='prettyprint'>
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
</pre>
This is the result:
$latex \displaystyle S(n)=\sum_{k=1}^{n}{\frac{1}{T_{k}}=\sum_{k=1}^{n}{\frac{6}{k(k+1)(k+2)}$
When I can replace '$' in <pre> with something equivalent, I could avoid this issue.
I tried <code> and <pre>, but they all interpret the content.
ADDED
I'm trying to use the javascript code found in this post.
If I understand correctly, you are using Replacemath, and its documentation says: “Should you need to to prevent certain $ signs from triggering LaTeX rendering, replace $ with the equivalent HTML <span>$</span> or $, or put the code inside a <pre> or <code> block if appropriate.” Of these, the first method seems to actually work.
That is, replace all occurrences of “$” inside the pre element by <span>$</span>.
I tested this by publishing a test in my blog (which had been dormant for 6 years...). I had to manually break the pre block to fit into the column.

Rails 3 Escape BBCode-parsed HTML Only Within Pre+Code Tags

I'm trying to implement a markup system in my Rails application using the bb-ruby gem. Currently I'm working on something similar to how Stackoverflow handles it's code markdown and I ran into some difficulty.
Essentially I want the user-entered text:
[code]<h1>Headline</h1>[/code]
To spit out the code in plain-text, perhaps in a pre and code tag block. Passing that string of text to my code parser will wrap the code in a pre and code block but the HTML also gets rendered. I pass the string to my code parser like so:
sanitize(text.bbcode_to_html(formats, false).html_safe)
Of course, if I remove the .html_safe helper from the call my view will spit out:
<pre><code><br /> <h1>Hello World</h1><br /> </code></pre>
Obviously that's not the desired result. So my question is, how can I accomplish plain-text code only within the pre + code tags while maintaining the html_safe helper method?
I know this is an old question but you can try using the strip_tags after the bbcode_to_html one.

Outputting HTML-encoded tags as HTML

I have some text from a service that looks like this:
Text with some <p%gt; tags.
If I output that in Rails with .html_safe it renders like this:
Text with some <p> tags.
but I want the tags to actually be HTML, so it would render like this:
Text with some
tags.
or similar.
I can't seem to work out how to get Rails to decode the entities and output them as HTML - I've tried various combinations of .html_safe and CGI.unencode but nothing has worked so far.
Ha, 30 seconds after I posted this I worked out a solution:
CGI.unescapeHTML(string).html_safe
does it :)

Emit raw html in ASP page?

This is extremely aggravating. I just want to simply insert raw html. I can't use the literal control because there's no ignoring the quote character. I don't want to use a script element because I'm adding it in a ascx file. I just want raw html output. Is there no operater for this?
I've properbly misunderstood you completely but:
In Classic ASP it is:
<%=("<div style=""color:red;"">html</div>")%>
output:
<div style="color:red;">html</div>