Added marked library to text_formatting.jsx

Этот коммит содержится в:
hmhealey
2015-09-18 13:41:00 -04:00
родитель ae5a1e3ea8
Коммит bb330b662a
3 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@@ -154,7 +154,7 @@ export default class PostBody extends React.Component {
return ( return (
<div className='post-body'> <div className='post-body'>
{comment} {comment}
<p <div
key={`${post.id}_message`} key={`${post.id}_message`}
id={`${post.id}_message`} id={`${post.id}_message`}
className={postClass} className={postClass}
@@ -164,7 +164,7 @@ export default class PostBody extends React.Component {
onClick={TextFormatting.handleClick} onClick={TextFormatting.handleClick}
dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.message)}} dangerouslySetInnerHTML={{__html: TextFormatting.formatText(this.state.message)}}
/> />
</p> </div>
{fileAttachmentHolder} {fileAttachmentHolder}
{embed} {embed}
</div> </div>

Просмотреть файл

@@ -9,7 +9,8 @@
"object-assign": "3.0.0", "object-assign": "3.0.0",
"react-zeroclipboard-mixin": "0.1.0", "react-zeroclipboard-mixin": "0.1.0",
"twemoji": "1.4.1", "twemoji": "1.4.1",
"babel-runtime": "5.8.24" "babel-runtime": "5.8.24",
"marked": "0.3.5"
}, },
"devDependencies": { "devDependencies": {
"browserify": "11.0.1", "browserify": "11.0.1",

Просмотреть файл

@@ -6,6 +6,10 @@ const Constants = require('./constants.jsx');
const UserStore = require('../stores/user_store.jsx'); const UserStore = require('../stores/user_store.jsx');
const Utils = require('./utils.jsx'); const Utils = require('./utils.jsx');
const marked = require('marked');
const markdownRenderer = new marked.Renderer();
// Performs formatting of user posts including highlighting mentions and search terms and converting urls, hashtags, and // Performs formatting of user posts including highlighting mentions and search terms and converting urls, hashtags, and
// @mentions to links by taking a user's message and returning a string of formatted html. Also takes a number of options // @mentions to links by taking a user's message and returning a string of formatted html. Also takes a number of options
// as part of the second parameter: // as part of the second parameter:
@@ -29,6 +33,11 @@ export function formatText(text, options = {}) {
output = highlightCurrentMentions(output, tokens); output = highlightCurrentMentions(output, tokens);
} }
// perform markdown parsing while we have an html-free input string
console.log('output before marked ' + output);
output = marked(output, {renderer: markdownRenderer});
console.log('output after marked ' + output);
// reinsert tokens with formatted versions of the important words and phrases // reinsert tokens with formatted versions of the important words and phrases
output = replaceTokens(output, tokens); output = replaceTokens(output, tokens);