开源软件名称(OpenSource Name):treasonx/grunt-markdown开源软件地址(OpenSource Url):https://github.com/treasonx/grunt-markdown开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):grunt-markdownThis grunt task takes a set of markdown files and converts them to HTML. It supports GFM with code highlighting. The code highlighting is done using highlight.js. Getting StartedInstall this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-markdown --save-dev Then add this line to your gruntfile: grunt.loadNpmTasks('grunt-markdown'); DocumentationCreating a markdown task is simple. For the basic functionality add the following config in your gruntfile: grunt.initConfig({
markdown: {
all: {
files: [
{
expand: true,
src: 'docs/src/*.md',
dest: 'docs/html/',
ext: '.html'
}
]
}
}
}); Here is an example config using all of the options: grunt.initConfig({
markdown: {
all: {
files: [
{
expand: true,
src: 'docs/src/*.md',
dest: 'docs/html/',
ext: '.html'
}
],
options: {
template: 'myTemplate.jst',
preCompile: function(src, context) {},
postCompile: function(src, context) {},
templateContext: {},
contextBinder: false,
contextBinderMark: '@@@',
autoTemplate: true,
autoTemplateFormat: 'jst',
markdownOptions: {
gfm: true,
highlight: 'manual',
codeLines: {
before: '<span>',
after: '</span>'
}
}
}
}
}
}); These are the properties that the
modifying content with preCompile and postCompileSometimes there is a need to modify the markdown content prior to compilation. This is most commonly used to augment the template context with meta data before expanding the html template. preCompileThis function is run prior to the compilation of md to html. It has the following format: function(src, context) {
//do stuff to src and context
//optionally return the modified src
} postCompileThis function is run after the md has been converted to html. It has the following format: function(src, context) {
//do stuff to src and context
//optionally return the modified src
} templateContextThis object is used to expand your html template. Any data added to this object
will be available in the template using the template syntax This can also be a function which is expected to return a context object. markdownOptionsMost markdown options are passed as-is to the marked markdown parser. The only option that is processed prior to compiling the markdown is the
contextBinderBelow you can see example how to use this option. markdown: {
all: {
files: [
{
expand: true,
src: 'docs/src/*.md',
dest: 'docs/html/',
ext: '.html'
}
],
options: {
template: 'myTemplate.jst',
preCompile: function(src, context) {},
postCompile: function(src, context) {},
templateContext: {},
contextBinder: true,
contextBinderMark: '@@@',
markdownOptions: {
gfm: true,
highlight: 'manual',
codeLines: {
before: '<span>',
after: '</span>'
}
}
}
}
} Then inside markdown file we have to put: templateContext: {
key: 'value'
} LicenseCopyright (c) 2012-2013 James Morrin Licensed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论