GravityProject / gravity

Open source social network built with Meteor
MIT License
131 stars 62 forks source link

allow markdown in posts #43

Closed drgorb closed 8 years ago

drgorb commented 8 years ago

in order to format one's post it would be nice to be able to use markdown. there is a meteor package for that

pmuens commented 8 years ago

Good idea. Do you know what Meteor package serves this well?

josephdburdick commented 8 years ago

@pmuens I've had good luck with https://github.com/chuangbo/meteor-marked

pmuens commented 8 years ago

@josephdburdick Thanks man! I'll look into it!

zaverichintan commented 8 years ago

https://atmospherejs.com/meteor/markdown It says it's inbuilt.

mattvella07 commented 8 years ago

Yes the package is an internal Meteor package, but that doesn't mean that all fields are parsed for markdown by default. If you try to include some markdown in a post it is displayed as plain text, so there still is some work that needs to be done in order to format posts using markdown.

zaverichintan commented 8 years ago

Everything inside markdown is considered markdown so make sure you do this:

{{#markdown}}{{>innerPreview}}{{/markdown}} Instead of

{{#markdown}} {{>innerPreview}} {{/markdown}} The jquery wouldn't work because {{markdown}} is rendered before the DOM is put in place.

Instead use a session

Template.hello.markdown_data = function() {return Session.get("markdown_data")}); Then your template

{{#markdown}}{{{markdown_data}}}{{/markdown}} Then store your markdown document in

Session.set("markdown_data","");

Found the above thing here- http://stackoverflow.com/a/17030896/4500248

pmuens commented 8 years ago

Great find! Anyone up to implement this?

zaverichintan commented 8 years ago

I tried doing it but then entire thing becomes markdown supported.

pmuens commented 8 years ago

@zaverichintan Thank you for investigation. I think that this is a great addition (even if everything will be "markdownable".

zaverichintan commented 8 years ago

Done.