renderizar con markdown-it

This commit is contained in:
f 2018-02-10 20:40:37 -03:00
parent aeeef64c83
commit 17f3d8c0ea
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
5 changed files with 62 additions and 3 deletions

View file

@ -12,8 +12,9 @@
// //
//= require rails-ujs //= require rails-ujs
//= require turbolinks //= require turbolinks
//= require jquery //= require jquery/dist/jquery.js
//= require jquery.hotkeys/jquery.hotkeys
//= require bootstrap-markdown/js/bootstrap-markdown //= require bootstrap-markdown/js/bootstrap-markdown
//= require markdown/lib/markdown //= require markdown-it/dist/markdown-it
//= require select2/dist/js/select2 //= require select2/dist/js/select2
//= require_tree . //= require_tree .

View file

@ -0,0 +1,4 @@
$(document).on('turbolinks:load', function() {
var md = window.markdownit();
$('#post_content').markdown({ parser: md.render.bind(md) });
});

View file

@ -27,7 +27,7 @@
placeholder: t('posts.title') placeholder: t('posts.title')
.form-group{class: @post.get_front_matter(:dir)} .form-group{class: @post.get_front_matter(:dir)}
= text_area_tag 'post[content]', @post.content, autofocus: true, = text_area_tag 'post[content]', @post.content, autofocus: true,
class: 'post-content', data: { provide: 'markdown' }, class: 'post-content',
cols: 72, wrap: 'hard' cols: 72, wrap: 'hard'
.form-group .form-group
= label_tag 'post_date', t('posts.date') = label_tag 'post_date', t('posts.date')

View file

@ -3,7 +3,11 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"bootstrap-markdown": "https://0xacab.org/itacate-kefir/bootstrap-markdown.git", "bootstrap-markdown": "https://0xacab.org/itacate-kefir/bootstrap-markdown.git",
"jquery": "^3.3.1",
"jquery.hotkeys": "^0.1.0",
"markdown": "^0.5.0", "markdown": "^0.5.0",
"markdown-it": "^8.4.0",
"marked": "^0.3.12",
"select2": "^4.0.6-rc.1" "select2": "^4.0.6-rc.1"
} }
} }

View file

@ -10,20 +10,62 @@ almond@~0.3.1:
version "0.3.3" version "0.3.3"
resolved "https://registry.yarnpkg.com/almond/-/almond-0.3.3.tgz#a0e7c95ac7624d6417b4494b1e68bff693168a20" resolved "https://registry.yarnpkg.com/almond/-/almond-0.3.3.tgz#a0e7c95ac7624d6417b4494b1e68bff693168a20"
argparse@^1.0.7:
version "1.0.9"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
dependencies:
sprintf-js "~1.0.2"
"bootstrap-markdown@https://0xacab.org/itacate-kefir/bootstrap-markdown.git": "bootstrap-markdown@https://0xacab.org/itacate-kefir/bootstrap-markdown.git":
version "2.10.0" version "2.10.0"
resolved "https://0xacab.org/itacate-kefir/bootstrap-markdown.git#580184dc214ea2364fca0fdcb70e3c5e08bd5605" resolved "https://0xacab.org/itacate-kefir/bootstrap-markdown.git#580184dc214ea2364fca0fdcb70e3c5e08bd5605"
entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
jquery-mousewheel@~3.1.13: jquery-mousewheel@~3.1.13:
version "3.1.13" version "3.1.13"
resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5" resolved "https://registry.yarnpkg.com/jquery-mousewheel/-/jquery-mousewheel-3.1.13.tgz#06f0335f16e353a695e7206bf50503cb523a6ee5"
jquery.hotkeys@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/jquery.hotkeys/-/jquery.hotkeys-0.1.0.tgz#a88f636494fe75de41e4b753a059e5a523b83273"
jquery@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
linkify-it@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.0.3.tgz#d94a4648f9b1c179d64fa97291268bdb6ce9434f"
dependencies:
uc.micro "^1.0.1"
markdown-it@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.0.tgz#e2400881bf171f7018ed1bd9da441dac8af6306d"
dependencies:
argparse "^1.0.7"
entities "~1.1.1"
linkify-it "^2.0.0"
mdurl "^1.0.1"
uc.micro "^1.0.3"
markdown@^0.5.0: markdown@^0.5.0:
version "0.5.0" version "0.5.0"
resolved "https://registry.yarnpkg.com/markdown/-/markdown-0.5.0.tgz#28205b565a8ae7592de207463d6637dc182722b2" resolved "https://registry.yarnpkg.com/markdown/-/markdown-0.5.0.tgz#28205b565a8ae7592de207463d6637dc182722b2"
dependencies: dependencies:
nopt "~2.1.1" nopt "~2.1.1"
marked@^0.3.12:
version "0.3.12"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.12.tgz#7cf25ff2252632f3fe2406bde258e94eee927519"
mdurl@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
nopt@~2.1.1: nopt@~2.1.1:
version "2.1.2" version "2.1.2"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-2.1.2.tgz#6cccd977b80132a07731d6e8ce58c2c8303cf9af" resolved "https://registry.yarnpkg.com/nopt/-/nopt-2.1.2.tgz#6cccd977b80132a07731d6e8ce58c2c8303cf9af"
@ -36,3 +78,11 @@ select2@^4.0.6-rc.1:
dependencies: dependencies:
almond "~0.3.1" almond "~0.3.1"
jquery-mousewheel "~3.1.13" jquery-mousewheel "~3.1.13"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
uc.micro@^1.0.1, uc.micro@^1.0.3:
version "1.0.5"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376"