I am trying to take some input from the user with the wisywig text editor plugin. But, when I try to show the text in a label or paragraph, all the html tags become visible.
For example,
#string str = "<b>sample text</b>";
<label>#str</label>
should look like
sample text
But it is not. It looks like,
<b>sample text</b>
How can I render a html code string into a html text...???
i am working with .net mvc3 with razor view engine...
That may happen if HTML entiries are being encoded.
You need to avoid that encoding or do decoding. For example, in PHP you can use http://php.net/manual/en/function.html-entity-decode.php to decode HTML entities.
Related
I'm using Spacy NER to recognize named entities from text but I have whole HTML page as input so how can I remove all the html tags from text and only give raw text without html tags to NER model for prediction and after prediction how can I show same text with HTML tags?
I tried xml.etree.ElementTree to remove HTML tags, this gives me text without html tags, but after prediction how can I display this text with all html tags in original format.
import xml.etree.ElementTree
def remove_html_tags(text):
"""Remove html tags from a string"""
return ''.join(xml.etree.ElementTree.fromstring(text).itertext())
Is there any way that I can again display this text with original html tags or Spacy has any feature to ignore html tags while prediction of named entities ?
I know it is lazy way but you can save first condition of your html page somewhere.
I don't think spacy has a functionality like that... but you could save the xml ElementTree and just pass the text in to spacy... some version of:
root = xml.etree.ElementTree.fromstring(text)
doc = nlp(root.itertext())
In my TextArea, I'm using CKEditor as a mixins, and all changes, include the formatting goes to my DB. How to display it as formatted text, which means if HTML is <b>My Name</b> is <i>Hobas</i> will displayed as My Name is Hobas. I've tried JSoup but it looks like that lib doesn't support this job.
Use the OutputRaw component in your template (.Tml) file:
See http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/OutputRaw.html
I have one plain text which is program output, but I want to display it in html page. But still I want to keep the formats (like space/tab/enter and etc.), it's just like the code block of stackoverflow, how can I display it properly in html ? Thanks
Use the "pre" and "code" HTML tags:
<pre><code> code in here... </code></pre>
<code> the program</code>
I have created but now when user add html formating in that text area with html codes like
<b>the codes are working </b>
they are showing up same as written, instead of "the codes are working "
so how do i enable that in simple HTML form.
Textarea cannot display any html structure. You should use <pre> tag, but if you want to edit in the same time, use contenteditable attribute.
<pre contenteditable="true"><b>the codes are working</b></pre>
I think that you are trying some editor. You can use CKEditor. Quirksmode.org also can be useful.
I have an object that has a title and some text (item.itmTitle and item.itmText) which I am passing to an HTML template using Play's render() method. Within the template (which in this case is called "index.html) I am trying to display the contents of the item object:
.
.
.
<p class="title">${item.itmTitle}</p>
<div id="itemtext">${item.itmText}</div>
.
.
.
My problem is this: the contents of item.itmText are HTML formatted. What I would like is for the contents to be displayed as HTML, but what is happening is that Play is doing all necessary conversions to display the contents as text. In other words, if item.itmText has the following HTML:
<p>This is a paragraph formatted in HTML</p>
The play template converts the source as follows:
& lt;p& gt;This is a paragraph formatted in HTML& lt;/p& gt;
My question is: is there some way to stop this conversion and make the HTML appear on the page as renderable HTML?
Someone please advise.
${item.itmTitle.raw()}
You just need to make sure that these strings are guaranteed to be safe; e.g. if users are submitting the title or text you need to sanitize the content to prevent injection of javascript (or accidental breakage of your container tags).