Skip to content

Commit 027a968

Browse files
committed
add marked-rails gem for comment
1 parent 86f44df commit 027a968

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gem 'coffee-rails', '~> 4.1.0'
1414
# See https://github.com/rails/execjs#readme for more supported runtimes
1515
# gem 'therubyracer', platforms: :ruby
1616
gem 'react-rails', '~> 1.0'
17+
gem 'marked-rails'
1718

1819
# Use jquery as the JavaScript library
1920
gem 'jquery-rails'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ GEM
7272
nokogiri (>= 1.5.9)
7373
mail (2.6.4)
7474
mime-types (>= 1.16, < 4)
75+
marked-rails (0.3.2.0)
7576
mime-types (3.1)
7677
mime-types-data (~> 3.2015)
7778
mime-types-data (3.2016.0521)
@@ -162,6 +163,7 @@ DEPENDENCIES
162163
coffee-rails (~> 4.1.0)
163164
jbuilder (~> 2.0)
164165
jquery-rails
166+
marked-rails
165167
rails (= 4.2.1)
166168
react-rails (~> 1.0)
167169
sass-rails (~> 5.0)

app/assets/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
//= require react
1717
//= require react_ujs
1818
//= require components
19+
//= require marked
1920
//= require_tree .

app/assets/javascripts/components/comment_box.js.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ var CommentForm = React.createClass({
3333

3434
var Comment = React.createClass({
3535
render: function() {
36+
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
3637
return (
3738
<div className="comment">
3839
<h2 className="commentAuthor">
3940
{this.props.author}
4041
</h2>
41-
{this.props.children}
42+
<span dangerouslySetInnerHTML={{__html: rawMarkup}} />
4243
</div>
4344
);
4445
}

0 commit comments

Comments
 (0)