sekirocc / mdeditor-rails

[DEPRECATED] Another markdown editor gem for rails3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Another Markdown editor gem for rails 3.

Edit Preview

Heavily inspired by mdeditor

Use the following libraries:

  1. pagedown as the markdown parser,
  2. pagedown-extra as the extra plugins for pagedown
  3. google-code-prettify as the code highlighter.

Usage

  1. use with simple_form
= f.input :content, as: :mdtext_area, input_html: { rows: 10 }
  1. view helper
= mdtext_area_tag :content, '' , rows: 10
  1. form builder
= f.mdtext_area :content, rows: 10

Start from a sample

rails new myapp, cd myapp

add dependencies to Gemfile

gem 'mdeditor_rails', path: '/Users/nickelchen/work/workspaces/my_gems/mdeditor_rails'
gem 'twitter-bootstrap-rails', '2.1.9'

bundle install

install bootstrap

rails generate bootstrap:install static

install mdeditor_rails, add this to application.js

//= require 'mdeditor_rails'

add this to application.css ( you know the meaning of this code )

 *= require mdeditor_rails

generate a scaffold

rails g scaffold Post title:string content:text

modify posts/_form.html.erb from f.text_area to f.mdtext_area

there you go

Format your text

Now you can save your markdown-style text in database, after all, you want to format it, display it, use the following javascript api.

MdeditorRails.start_format(container, '#{ j(raw text)}')

container is a jQuery object where you want to hold the formatted text.

About

[DEPRECATED] Another markdown editor gem for rails3

License:MIT License


Languages

Language:Ruby 59.2%Language:JavaScript 26.4%Language:CSS 14.4%