Skip to content

Commit

Permalink
Merge pull request #7861 from elastic/jasper/backport/7855/4.x
Browse files Browse the repository at this point in the history
[backport] PR #7855 to 4.x
  • Loading branch information
jbudz authored Jul 27, 2016
2 parents b397370 + 1042d46 commit 44c9f98
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"angular-bootstrap-colorpicker": "3.0.19",
"angular-elastic": "2.5.0",
"angular-route": "1.4.7",
"angular-sanitize": "1.5.7",
"ansicolors": "0.3.2",
"autoprefixer": "5.1.1",
"autoprefixer-loader": "2.0.0",
Expand Down Expand Up @@ -117,7 +118,7 @@
"less-loader": "2.2.0",
"loader-utils": "0.2.11",
"lodash": "3.10.1",
"marked": "0.3.3",
"marked": "0.3.5",
"minimatch": "2.0.10",
"mkdirp": "0.5.1",
"moment": "2.10.6",
Expand Down Expand Up @@ -160,7 +161,6 @@
"grunt-s3": "0.2.0-alpha.3",
"grunt-simple-mocha": "0.4.0",
"gruntify-eslint": "1.0.1",
"html-entities": "1.1.3",
"husky": "0.8.1",
"intern": "3.2.3",
"istanbul-instrumenter-loader": "0.1.3",
Expand All @@ -175,7 +175,6 @@
"license-checker": "3.1.0",
"load-grunt-config": "0.7.2",
"makelogs": "2.0.0",
"marked-text-renderer": "0.1.0",
"mocha": "2.3.0",
"nock": "2.10.0",
"npm": "2.15.8",
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/markdown_vis/public/markdown_vis_controller.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
define(function (require) {
const marked = require('marked');
require('angular-sanitize');

marked.setOptions({
gfm: true, // Github-flavored markdown
sanitize: true // Sanitize HTML tags
});

const module = require('ui/modules').get('kibana/markdown_vis', ['kibana']);
const module = require('ui/modules').get('kibana/markdown_vis', ['kibana', 'ngSanitize']);
module.controller('KbnMarkdownVisController', function ($scope, $sce) {
$scope.$watch('vis.params.markdown', function (html) {
if (!html) return;
$scope.html = $sce.trustAsHtml(marked(html));
$scope.html = marked(html);
});
});
});
4 changes: 2 additions & 2 deletions src/ui/public/vislib/visualizations/_map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
return function MapFactory(Private, tilemap) {
return function MapFactory(Private, tilemap, $sanitize) {
let _ = require('lodash');
let $ = require('jquery');
let L = require('leaflet');
Expand All @@ -14,7 +14,7 @@ define(function (require) {
let defaultMarkerType = 'Scaled Circle Markers';

let tilemapOptions = tilemap.options;
let attribution = marked(tilemapOptions.attribution);
let attribution = $sanitize(marked(tilemapOptions.attribution));

let mapTiles = {
url: tilemap.url,
Expand Down
4 changes: 3 additions & 1 deletion src/ui/public/visualize/visualize.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
define(function (require) {
require('angular-sanitize');

require('ui/modules')
.get('kibana/directive')
.get('kibana/directive', ['ngSanitize'])
.directive('visualize', function (Notifier, SavedVis, indexPatterns, Private, config, $timeout) {

require('ui/visualize/spy');
Expand Down
30 changes: 5 additions & 25 deletions tasks/build/readme.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
let marked = require('marked');
let Promise = require('bluebird');
let { join } = require('path');
let TextRenderer = require('marked-text-renderer');
let _ = require('lodash');
let fs = require('fs');
let { AllHtmlEntities } = require('html-entities');
let entities = new AllHtmlEntities();

TextRenderer.prototype.heading = function (text, level, raw) {
return '\n\n' + text + '\n' + _.map(text, function () { return '='; }).join('') + '\n';
};

module.exports = function (grunt) {

grunt.registerTask('_build:readme', function () {
let transform = function (input) {
let output = input.replace(/<\!\-\- [^\-]+ \-\->/g, '\n');
output = marked(output);
return entities.decode(output);
};

marked.setOptions({
renderer: new TextRenderer(),
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
});
function transformReadme(readme) {
return readme.replace(/\s##\sSnapshot\sBuilds[\s\S]*/, '');
}

grunt.file.write('build/kibana/README.txt', transform(grunt.file.read('README.md')));
grunt.file.write('build/kibana/LICENSE.txt', transform(grunt.file.read('LICENSE.md')));
grunt.file.copy('LICENSE.md', 'build/kibana/LICENSE.txt');
grunt.file.write('build/kibana/README.txt', transformReadme(grunt.file.read('README.md')));
});

};

0 comments on commit 44c9f98

Please sign in to comment.