Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions core/client/app/helpers/gh-format-markdown.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/* global Showdown, html_sanitize*/
/* global html_sanitize*/
import Ember from 'ember';
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
import markdownit from 'npm:markdown-it';
import markdownitFootnote from 'npm:markdown-it-footnote';
import markdownitAnchor from 'npm:markdown-it-anchor';
import markdownitMark from 'npm:markdown-it-mark';
import markdownitUpload from 'npm:markdown-it-ghost-upload';

const {Helper} = Ember;

let showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm', 'footnotes', 'highlight']});
const md = markdownit({
html: true,
linkify: true,
typographer: true,
breaks: true,
}).use(markdownitFootnote)
.use(markdownitAnchor)
.use(markdownitMark)
.use(markdownitUpload);

export default Helper.helper(function (params) {
if (!params || !params.length) {
Expand All @@ -15,7 +28,7 @@ export default Helper.helper(function (params) {
let escapedhtml = '';

// convert markdown to HTML
escapedhtml = showdown.makeHtml(markdown);
escapedhtml = md.render(markdown);

// replace script and iFrame
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
Expand Down
20 changes: 16 additions & 4 deletions core/client/app/mixins/ed-editor-shortcuts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/* global moment, Showdown */
/* global moment */
import Ember from 'ember';
import titleize from 'ghost/utils/titleize';
import markdownit from 'npm:markdown-it';
import markdownitFootnote from 'npm:markdown-it-footnote';
import markdownitAnchor from 'npm:markdown-it-anchor';
import markdownitMark from 'npm:markdown-it-mark';

const {Mixin} = Ember;

const md = markdownit({
html: true,
linkify: true,
typographer: true,
breaks: true,
}).use(markdownitFootnote)
.use(markdownitAnchor)
.use(markdownitMark);

// Used for simple, noncomputational replace-and-go! shortcuts.
// See default case in shortcut function below.
let simpleShortcutSyntax = {
Expand Down Expand Up @@ -103,13 +116,12 @@ let shortcuts = {
},

copyHTML(editor, selection) {
let converter = new Showdown.converter();
let generatedHTML;

if (selection.text) {
generatedHTML = converter.makeHtml(selection.text);
generatedHTML = md.render(selection.text);
} else {
generatedHTML = converter.makeHtml(editor.getValue());
generatedHTML = md.render(editor.getValue());
}

// Talk to the editor
Expand Down
1 change: 0 additions & 1 deletion core/client/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"pretender": "0.10.1",
"rangyinputs": "1.2.0",
"selectize": "~0.12.1",
"showdown-ghost": "0.3.6",
"sinonjs": "1.14.1",
"validator-js": "3.39.0",
"xregexp": "2.0.0"
Expand Down
5 changes: 0 additions & 5 deletions core/client/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ module.exports = function (defaults) {
// 'dem Scripts
app.import('bower_components/validator-js/validator.js');
app.import('bower_components/rangyinputs/rangyinputs-jquery-src.js');
app.import('bower_components/showdown-ghost/src/showdown.js');
app.import('bower_components/showdown-ghost/src/extensions/ghostgfm.js');
app.import('bower_components/showdown-ghost/src/extensions/ghostimagepreview.js');
app.import('bower_components/showdown-ghost/src/extensions/footnotes.js');
app.import('bower_components/showdown-ghost/src/extensions/highlight.js');
app.import('bower_components/moment/moment.js');
app.import('bower_components/keymaster/keymaster.js');
app.import('bower_components/devicejs/lib/device.js');
Expand Down
6 changes: 6 additions & 0 deletions core/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "2.2.0",
"ember-browserify": "^1.1.4",
"ember-cli": "1.13.13",
"ember-cli-app-version": "1.0.0",
"ember-cli-babel": "5.1.5",
Expand Down Expand Up @@ -49,6 +50,11 @@
"ember-watson": "0.7.0",
"fs-extra": "0.16.3",
"glob": "^4.0.5",
"markdown-it": "^5.1.0",
"markdown-it-anchor": "^2.3.3",
"markdown-it-footnote": "^2.0.0",
"markdown-it-ghost-upload": "^1.0.1",
"markdown-it-mark": "^2.0.0",
"walk-sync": "^0.1.3"
},
"ember-addon": {
Expand Down
13 changes: 10 additions & 3 deletions core/server/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ var _ = require('lodash'),
Promise = require('bluebird'),
sequence = require('../utils/sequence'),
errors = require('../errors'),
Showdown = require('showdown-ghost'),
converter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}),
ghostBookshelf = require('./base'),
events = require('../events'),
config = require('../config'),
baseUtils = require('./base/utils'),
Post,
Posts;

var md = require('markdown-it')({
html: true,
linkify: true,
typographer: true,
breaks: true,
}).use(require('markdown-it-footnote'))
.use(require('markdown-it-anchor'))
.use(require('markdown-it-mark'));

Post = ghostBookshelf.Model.extend({

tableName: 'posts',
Expand Down Expand Up @@ -112,7 +119,7 @@ Post = ghostBookshelf.Model.extend({

ghostBookshelf.Model.prototype.saving.call(this, model, attr, options);

this.set('html', converter.makeHtml(this.get('markdown')));
this.set('html', md.render(this.get('markdown')));

// disabling sanitization until we can implement a better version
// this.set('title', this.sanitize('title').trim());
Expand Down
2 changes: 1 addition & 1 deletion core/test/unit/rss_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('RSS', function () {
// special/optional tags
xmlData.should.match(/<title><!\[CDATA\[Short and Sweet\]\]>/);
xmlData.should.match(/<description><!\[CDATA\[test stuff/);
xmlData.should.match(/<content:encoded><!\[CDATA\[<h2 id="testing">testing<\/h2>\n\n/);
xmlData.should.match(/<content:encoded><!\[CDATA\[<h2 id="testing">testing<\/h2>/);
xmlData.should.match(/<img src="http:\/\/placekitten.com\/500\/200"/);
xmlData.should.match(/<media:content url="http:\/\/placekitten.com\/500\/200" medium="image"\/>/);

Expand Down
Loading