I need to get both plain text as well as html text from Ajax Editor. I'm able to get the html text and not able to retrieve plain text. i'm not supposed to eliminate html tags from the editor to retrieve plain text.
Is there any property, which gives plain text from ajax editor?
Sample code from my app:
i'm able to get rich html text like this:
string desc = QuestionAndAnswerEditor.Content;
Same way i want plain text.
Please help me.
Use HTML.Encode for getting encoded text. and html.decode ..
Related
I have a text_area field in a form which allows some text formatting through a very simple WYSIWYG (bold / underline / bullet points). This was aimed at having a consistent formatting in the description profile of the users.
<%= l.text_area :access, value: "#{t('.access_placeholder_html')}" %>
Nevertheless, some users usually filled the text_area by copy / pasting directly from their website. And their specific formatting "hypertext links", font size, etc. is after reflected on my website, which makes it a bit dirty.
How can I solve this problem. Ideally I would love that when saving the form it gets rid of all the HTML code that is not allowed instead of not allowing copy / paste. Is this possible? Was wondering if should use Sanitize but if so how? (Sorry new to code, I guess you would have understood).
You didn't say which version of Rails, but you could use #sanitize from ActionView::Helpers::SanitizeHelper module to strip all the HTML formatting. It scrubs HTML from text with a scrubber. The default scrubber allows optional whitelisting of attributes. You can even build your own custom scrubber to modify the string if you need more control over what is output. The module also contains #strip_tags and #strip_links, which are very simple scrubbers that remove all HTML tags and all HTML link tags (leaving the link text).
Note that you can wind up with malformed text if the user's input wasn't valid HTML.
Quick examples from the docs:
// remove all HTML tags except <strong> <em> <a> and the
// <href> attributes from #text
nomarkup_text = sanitize #text, tags: %w(strong em a), attributes: %w(href)
// remove all HTML markup
strip_tags("<b>Bold</b> no more! <a href='more.html'>See more here</a>...")
returns the string Bold no more! See more here...
// remove just the link markup
strip_links('Please e-mail me at me#email.com.')
returns the string Please e-mail me at me#email.com.
More detail at the API page for SantizeHelper
I am trying to create a formatted text field that will have its contents then parsed into a Ruby Date object. I think I have the logic for taking a value from a text field and turning that into a date, but I can't figure out the formatting part.
I want a text field that would already have separators in it by default, that the user could not overwrite. So I would want the text field to look like:
__/__/__
And when they tab into the field, the text they type fills in the spaces instead of overwriting everything in there.
Thanks!
not sure about the ruby but you can use jQuery like so:
http://digitalbush.com/projects/masked-input-plugin/
jQuery(function($){
$("#key").mask("aaaaa-aaaaa-aaaaa-aaaaa-aaaaa");
});
and simply use <noscript> in your page header to make sure anyone's viewing your page has the javascript enabled.
How can I get the HTML code (markup) that the AJAX HTMLEditor creates?
I'm trying to use the editor in order to transform rich text into a full html file. Then, the file will be used to write a SQL statement in order to insert it into a database.
You should be able to use the Content property.
have a form that uses FCKeditor. I can input with formatting, but when I bring back what I put in FCKeditor it also displays the raw html format syntax. I.E. <p><p>&
Question: is there a setting I'm missing that uses the formatting to format the text instead of displaying the formatting syntax along with the text?
thanks
Randy
i dont know whether you are using ASP.net C# or not but if yes then first import
using System.Text.RegularExpressions;
using FredCK.FCKeditorV2;
these two things and then where you are retrieving your value from fckeditor then use
string fckContent = Regex.Replace(FCKEditorID.value, #"<(.|\n)*?>", string.Empty);
I have a Yahoo pipe taking the Atom feed from a Google group, and I want to do some processing on the message's full text (running various regular expressions to extract data). I can get a message's text in plain text from from Google using a url like this:
http://groups.google.com/group/(group_name)/msg/(message_id)?dmode=source&output=gplain
However, I'm having trouble getting it inside Yahoo pipes as a string value. Fetch Page rejects non-HTML pages. YQL using the html table seems to work, and wraps the plain text inside a p element, whose text I can extract like this:
select * from html where url="..." and xpath="//p"
However, if the message text contains html tags, YQL returns an HTML subtree instead of a string. Is there any way of flattening it back into its HTML source?
The trick is to remove the "output=gplain" and grab the content from the pre element.
select content from html
where url="http://groups.google.com/group/haml/msg/0f78eda2f5ef802d?dmode=source"
and xpath='//div[contains(#class,"maincontbox")]/pre'
I have created a pipe with Google Group and Message ID as inputs to demonstrate:
http://pipes.yahoo.com/pipes/pipe.info?_id=3d345e162405e7dbd47d73b95c21f102