wysiwyg editor which uses paragraph tags - editor

I must have looked at at least 15 different editors and all of them seem to use <br/> tags for their line breaks. I would very much prefer to find one which wraps each return with paragraph tags.
Thanks.

Depending on what you are trying to do, the wysiwyg editor built into wordpress uses paragraph tags.
Also I've noticed that most editors use a line break for a single return, but use a paragraph tag for two returns.

I don't know what you might have searched for, but the 2 main WYSIWYG editors are CKEditor and tinyMCE and both of them take do generate paragraphs by default. I think than in tinyMCE you can't control it, but CKEditor allows to specify if you want to use p, br or div for enter and shift+enter.

Related

ruby on rails: text filed formatting

I tried to copy and past from Word document to text field using Ruby on Rails.
But all formatting( spaces, bold and other) are disappeared on text filed.
I've just got the simple lines of text without any formatting.
I've read that need to use Simple format tool... but I want that a user be able just to copy and past a text to text field without doing any adjustments.
I mean, I want make all adjustment in advance and the user could just copy and past the text and got all formatting, the same as in Word doc.
The link to file with text field as below.
https://gist.github.com/tatyana12/2f9d39c2f6e4f8fabea5e70e11eaf310
Also I have Application.html.erb file:
https://gist.github.com/tatyana12/15c27d542091b04f3c3adfdfd252b7f4
How to initialize editor if I don't have id = "edit" right now?
How to put some code extra style to this file?
Have a go at wrapping your field in your show.html.erb or wherever you want to display it with simple_format, for example:
<%= simple_format(#object.description) %>
See http://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format for more info.
I've solved this problem by implementing SKEditor.
There is a lot of tutorial how to implement this editor.
I (as a lot of other users) have problem that my text wasn't formatted because this editor is not compatible with turbo links.
So, I disable turbo links in some files, and as result I have the text formatted.

How to write a front-end interface for Markdown editing in Rails?

I have used Redcarpet to interpret Markdown, but use the normal Form to type Markdown.
I want a form that when I type the Markdown syntax in Form, it will highlight the text.
I have tried many thins but not work. I'm not familiar with Javascript, only know a little syntax.
Could anyone give a code example ? Thanks a lot.
You may be interested in something such as markituUp! Rails
What you're basically looking for is a wysiwyg editor for markdown (like StackOverflow's editor). The important thing to note is this type of editor needs to be able to process inputs (selecting bold | italic | underline etc), and translating them to Rails
Javascript
In reference to javascript, JS is just a wrapper for HTML elements
All the WYSIWYG editors out there are just a way to "decorate" your HTML text_area inputs, allowing you to assign different commands to the input. For example, a WYSIWYG "bold" button will just input **your_text** around your selected text
Hope this helps?

Rails]Using Markdown Markup Language

In my rails application, people are supposed to submit "posts." However, in the default scaffolding, there are some problems in the text input: not allowed HTML code, changing the line doesn't work, etc. From what I've learned, I need to use a markdown-markup language to solve this issue. Is there a guide for me to follow to apply such language to solve my problem?
UPDATE: Here are my problems.
1) Every sentence is combined into one line even if I put a line space.
first line
second line
becomes
first line second line
2) I can't make text bold, italicized, or hyperlink. Like in stackoverflow, user should easily put <b> and make bold text, ** to make italicized, etc. And URL address should automatically be translated to href link.
To do these, I thought I had to use markdown library. I could be mistaken, so I needed someone to guide me through. Railscasts on Markdown
Well, yes, new lines in HTML have no meaning. You need to replace line breaks with <br> to preserve them in HTML. To automatically highlight links, you need to look for links in the text and wrap them in appropriate <a> tags. Finally, if you're not filtering HTML tags, they should still be in there. It all depends on what you're doing. Markdown is something entirely different, a special markup language that enables you to do the above while being easier to write than HTML. It depends on what you want to use.

trouble using tinymce using ruby on rails

I am having trouble in using tinymce editor with rails 3. I want to show text in bold letters and having trouble using tags like when I write something in p tags It should go to next paragraphs. in my case this tags is not working. It remains on same lines and display p tags on site page.
The usual suspect when it comes to rails 3 printing raw html output to the site, is that someone forgot to call html_safe on whatever text should be printed.
So if you have a #my_model_instance.description that you edit with tinymce, you might want to make the view look like #my_model_instance.description.html_safe, or as they suggest in the comment on the documentation, raw(#my_model_instance.description).
If the text is coming from user input, however, you might want to be a bit cautious, since it might be possible for users to input all sorts of nasty injection hacks this way.

Generating a link with Markdown (BlueCloth) that opens in a new window

I'd like to have a link generated with BlueCloth that opens in a new window. All I could find was the ordinary [Google](http://www.google.com/) syntax but nothing with a new window.
Ideas?
Regards
Tom
Here is a complete reference for markdown: http://daringfireball.net/projects/markdown/syntax
And since there is no mention of how to set the target attribute, I would believe it is not directly possible, but the reference also says:
For any markup that is not covered by
Markdown’s syntax, you simply use HTML
itself. There’s no need to preface it
or delimit it to indicate that you’re
switching from Markdown to HTML; you
just use the tags.
Source: http://daringfireball.net/projects/markdown/syntax#html
So I would suggest you have to use the html syntax for links like this
update
if you wrap the markdown generated content in a div with a specific id like this:
and you use jQuery, you can add the following javascript:
$('#some_id a').attr('target','_blank');
Or you can save the BlueCloth output in a variable before outputting.
markdown_generated_string.gsub!(/<a\s+/i,'<a target="_blank" ')

Resources