-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7861 from elastic/jasper/backport/7855/4.x
[backport] PR #7855 to 4.x
- Loading branch information
Showing
5 changed files
with
16 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'))); | ||
}); | ||
|
||
}; |