From 17f3d8c0ea09def3279c3e3f1c7efedd6ef856ca Mon Sep 17 00:00:00 2001 From: f Date: Sat, 10 Feb 2018 20:40:37 -0300 Subject: [PATCH] renderizar con markdown-it --- app/assets/javascripts/application.js | 5 +-- app/assets/javascripts/markdown.js | 4 +++ app/views/posts/_form.haml | 2 +- package.json | 4 +++ yarn.lock | 50 +++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/markdown.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 6008f7f..3aa3fcd 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,8 +12,9 @@ // //= require rails-ujs //= require turbolinks -//= require jquery +//= require jquery/dist/jquery.js +//= require jquery.hotkeys/jquery.hotkeys //= require bootstrap-markdown/js/bootstrap-markdown -//= require markdown/lib/markdown +//= require markdown-it/dist/markdown-it //= require select2/dist/js/select2 //= require_tree . diff --git a/app/assets/javascripts/markdown.js b/app/assets/javascripts/markdown.js new file mode 100644 index 0000000..2927b9f --- /dev/null +++ b/app/assets/javascripts/markdown.js @@ -0,0 +1,4 @@ +$(document).on('turbolinks:load', function() { + var md = window.markdownit(); + $('#post_content').markdown({ parser: md.render.bind(md) }); +}); diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index ac52eea..1701e13 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -27,7 +27,7 @@ placeholder: t('posts.title') .form-group{class: @post.get_front_matter(:dir)} = text_area_tag 'post[content]', @post.content, autofocus: true, - class: 'post-content', data: { provide: 'markdown' }, + class: 'post-content', cols: 72, wrap: 'hard' .form-group = label_tag 'post_date', t('posts.date') diff --git a/package.json b/package.json index 3727457..1e7c014 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,11 @@ "private": true, "dependencies": { "bootstrap-markdown": "https://0xacab.org/itacate-kefir/bootstrap-markdown.git", + "jquery": "^3.3.1", + "jquery.hotkeys": "^0.1.0", "markdown": "^0.5.0", + "markdown-it": "^8.4.0", + "marked": "^0.3.12", "select2": "^4.0.6-rc.1" } } diff --git a/yarn.lock b/yarn.lock index 0fcbd03..4578bf9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,20 +10,62 @@ almond@~0.3.1: version "0.3.3" 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": version "2.10.0" 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: version "3.1.13" 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: version "0.5.0" resolved "https://registry.yarnpkg.com/markdown/-/markdown-0.5.0.tgz#28205b565a8ae7592de207463d6637dc182722b2" dependencies: 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: version "2.1.2" resolved "https://registry.yarnpkg.com/nopt/-/nopt-2.1.2.tgz#6cccd977b80132a07731d6e8ce58c2c8303cf9af" @@ -36,3 +78,11 @@ select2@^4.0.6-rc.1: dependencies: almond "~0.3.1" 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"