{"id":15646299,"url":"https://github.com/zephraph/nunjucks-markdown","last_synced_at":"2025-04-13T23:51:28.754Z","repository":{"id":22230900,"uuid":"25563952","full_name":"zephraph/nunjucks-markdown","owner":"zephraph","description":"Markdown extension for Nunjucks. Use your own renderer!","archived":false,"fork":false,"pushed_at":"2019-01-22T16:39:35.000Z","size":40,"stargazers_count":49,"open_issues_count":5,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T03:06:37.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zephraph.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-22T05:43:40.000Z","updated_at":"2023-12-03T18:26:19.000Z","dependencies_parsed_at":"2022-07-18T08:13:08.117Z","dependency_job_id":null,"html_url":"https://github.com/zephraph/nunjucks-markdown","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephraph%2Fnunjucks-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephraph%2Fnunjucks-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephraph%2Fnunjucks-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zephraph%2Fnunjucks-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zephraph","download_url":"https://codeload.github.com/zephraph/nunjucks-markdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799903,"owners_count":21163400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:12:20.644Z","updated_at":"2025-04-13T23:51:28.726Z","avatar_url":"https://github.com/zephraph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nunjucks-markdown [![Build Status](https://travis-ci.org/zephraph/nunjucks-markdown.svg)](https://travis-ci.org/zephraph/nunjucks-markdown)\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/zephraph/nunjucks-markdown.svg)](https://greenkeeper.io/)\n\nA nunjuck extension that adds a markdown tag. This plugin allows you to choose your own markdown renderer.\n\n## Install\n\n``` bash\nnpm install nunjucks-markdown --save\n```\n\n## Usage\n\nRegister the extension with nunjucks\n\n``` js\nvar nunjucks = require('nunjucks'),\n    markdown = require('nunjucks-markdown'),\n    marked = require('marked');\n\nvar env = nunjucks.configure('views');\n\n// The second argument can be any function that renders markdown\nmarkdown.register(env, marked);\n```\n\nAdd markdown to your templates\n\n```\n{% markdown %}\nHello World\n===========\n# Do stuff\n{% endmarkdown %}\n```\n\nYou can also provide the markdown tag with a template to render\n\n```\n{% markdown \"post.md\" %}\n```\n_Note: This method doesn't require a closing tag_\n\nAs you would expect, you can add tags inside your markdown tag\n```\n{% markdown %}\n{% include 'post1.md' %}\n{% include 'post2.md' %}\n{% endmarkdown %}\n```\n\n### Using with Gulp\n\nGulp requires a little more explicit settings than standard npm. See https://mozilla.github.io/nunjucks/api.html#custom-tags\n\nsee example-gulpefile.js based on https://gist.github.com/kerryhatcher/1382950af52f3082ecdc668bba5aa11b\n\n``` js\nvar nunjucks = require('nunjucks'),\n    markdown = require('nunjucks-markdown'),\n    marked = require('marked'),\n    gulpnunjucks = require('gulp-nunjucks');\n    \nvar templates = 'src/templates'; //Set this as the folder that contains your nunjuck files\n\nvar env = new nunjucks.Environment(new nunjucks.FileSystemLoader(templates));\n\n// The second argument can be any function that renders markdown\nmarkdown.register(env, marked);\n\ngulp.task('pages', function() {\n    // Gets .html files. see file layout at bottom\n    return gulp.src([templates + '/*.html', templates + '/**/*.html'])\n        // Renders template with nunjucks and marked\n        .pipe(gulpnunjucks.compile(\"\", {env: env}))\n        // output files in dist folder\n        .pipe(gulp.dest(dist))\n});\n```\n\n\n## Markdown Options\n\n**Nunjucks-markdown** doesn't require you to use any particular markdown renderer. If you were to use marked here's a good example of how it could be configured.\n\n``` js\nvar marked = require('marked');\n\nmarked.setOptions({\n  renderer: new marked.Renderer(),\n  gfm: true,\n  tables: true,\n  breaks: false,\n  pedantic: false,\n  sanitize: true,\n  smartLists: true,\n  smartypants: false\n});\n\nmarkdown.register(env, marked);\n```\n\nFor more information configuration options, checkout [marked](https://github.com/chjj/marked).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephraph%2Fnunjucks-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzephraph%2Fnunjucks-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzephraph%2Fnunjucks-markdown/lists"}