TagHelper to supress Razor processing - razor

Is there a possibility to write a tag helper which tells Razor not to process it's content.
I would like to define new <raw> tag and everything between opening and closing "raw" tag should go to result HTML "as is".
For example, the following markup:
<raw>
Some text.
#Something
<some-other-tag-helper />
<raw>
Should go to result HTML exactly as it's listed between <raw> and </raw> without trying to consider #Something as a variable or "unpacking" other tag helpers.

Related

Getting a HTML template as a HTML string

consider that I have several HTML templates and they have custom HTML tags. For ex: c-icon, c-text, c-button etc.
For some usecase(Display other content along with innerHTML), I need to access c-icon tag HTML inside c-text and append it to some text so that I can render it with some other html text. In future, I may have another component called c-badge and even I want to refer and render.
Could you please provide any suggestions for achieving the same?

How to add html and head tag in jsoup?

I am trying to sanitize a html page in spring boot using Jsoup. I added head, html and body tag in the allowed tags in the following way.
Safelist safelist = Safelist.relaxed();
safelist.addTags("html", "head", "style", "body", "title");
in the documentation it says that this should work.
The cleaner and these safelists assume that you want to clean a body fragment of HTML (to add user supplied HTML into a templated page), and not to clean a full HTML document.
**If the latter is the case, either wrap the document HTML around the cleaned body HTML, or create a safelist that allows html and head elements as appropriate.**
When I pass the string
String s = "<html><head><title>Title of the document</title></head><body><p>some text</p></body></html>";
to Jsoup.clean() method:
Jsoup.clean(s,"",safelist,new Document.OutputSettings().prettyPrint(false))
I get output as:
<body><title>Title of the document</title><p>some text</p></body>
what I want is:
<html><head><title>Title of the document</title></head><body><p>some text</p></body></html>
Thanks in advance.

Jsoup - Prevent adding closing tags

I have to handle some not valid HTML files and have to add attributes to some tags and need the starting and end positions of the tags. So using the xml parser is not an option, because the position information get lost.
Is there any possibility to prevent jsoup from repairing "broken" HTML and don't add additional tags?
Example:
<b><p><font>Some Text</b>Text</font></p>
Output from JSOUP is:
<b></b><p><b><font added=attribute>Some Text</font></b><font>Text</font></p>
But I want:
<b><p><font added=attribute>Some Text</b>Text</font></p>

html to jade error when contains <pre>

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>

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.