{"id":21325788,"url":"https://github.com/flaviotordini/markdown-it-yaml","last_synced_at":"2026-05-11T06:50:29.938Z","repository":{"id":58481384,"uuid":"519521830","full_name":"flaviotordini/markdown-it-yaml","owner":"flaviotordini","description":"Insert YAML documents inside Markdown and have them render to HTML using Mustache templates","archived":false,"fork":false,"pushed_at":"2022-09-06T12:32:05.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T12:31:04.346Z","etag":null,"topics":["markdown","markdown-it","markdown-it-plugin","mustache","yaml"],"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/flaviotordini.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-07-30T13:20:07.000Z","updated_at":"2023-01-12T12:42:53.000Z","dependencies_parsed_at":"2023-01-17T21:16:04.307Z","dependency_job_id":null,"html_url":"https://github.com/flaviotordini/markdown-it-yaml","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fmarkdown-it-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fmarkdown-it-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fmarkdown-it-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviotordini%2Fmarkdown-it-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flaviotordini","download_url":"https://codeload.github.com/flaviotordini/markdown-it-yaml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806040,"owners_count":20350775,"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":["markdown","markdown-it","markdown-it-plugin","mustache","yaml"],"created_at":"2024-11-21T21:07:26.454Z","updated_at":"2026-05-11T06:50:29.883Z","avatar_url":"https://github.com/flaviotordini.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-it-yaml\n\nInsert YAML documents inside Markdown and have them render to HTML using Mustache templates.\n\nThis is useful when you need structured data in your Markdown documents. You get a very easy syntax to write the data (YAML) and total control on HTML output. Objects can be anything: images, galleries, polls, family trees, whatever.\n\n## Example\nExample input:\n\n    # Title\n\n    Some content.\n\n    ```yaml\n    type: image\n    src: cat.jpg\n    alt: A cat\n    caption: The cat is on the table\n    credit: Flavio\n    ```\n\n    More Markdown content.\n\nSince `type` is `image`, a mustache template named `image.html` must be created in your template directory.\n\nThe template directory defaults to the current working directory. You should set it in the options.\n\nA Mustache template would look like:\n\n```handlebars\n\u003cfigure\u003e\n    \u003cimg src=\"{{{src}}}\" alt=\"{{#alt}}{{alt}}{{/alt}}\" /\u003e\n    {{#caption}}\u003cfigcaption\u003e{{caption}}\u003c/figcaption\u003e{{/caption}}\n    {{#credit}}\u003cdiv class=\"credit\"\u003e{{credit}}\u003c/div\u003e{{/credit}}\n\u003c/figure\u003e\n```\n\nOutput:\n```html\n\u003ch1\u003eTitle\u003c/h1\u003e\n\n\u003cp\u003eSome content.\n\n\u003cfigure\u003e\n    \u003cimg src=\"cat.jpg\" alt=\"A cat\" /\u003e\n    \u003cfigcaption\u003eThe cat is on the table\u003c/figcaption\u003e\n    \u003cdiv class=\"credit\"\u003eFlavio\u003c/div\u003e\n\u003c/figure\u003e\n\n\u003cp\u003eMore Markdown content.\n```\n\n## Syntax\n\nI chose the standard code block marker \u003ccode\u003e```yaml\u003c/code\u003e as the default marker in order to get nice editing and preview for authors and not introduce a new Markdown syntax. It can be changed in the options.\n\nBy appending some other word after \u003ccode\u003e```yaml\u003c/code\u003e you can disable this plugin for a specific YAML code block:\n\n    ```yaml norender\n    this: won't get mustached\n    ```\n\n## API\n\n### Object List\n\nAn array of the parsed YAML blocks can be accessed at `env.objects` after the Markdown document has been processed. This can be useful to generate table of contents, statistics, export data, etc. See the Usage example below.\n\n### Object callback\n\nSpecify a `onObject` callback in the options to be notified of each parsed YAML document. You can then modify it as you need. See the Usage example below.\n\n## Install\n\nComing soon\n\n```bash\n$ npm install markdown-it-yaml\n```\n\n## Usage\n\nMinimal usage:\n\n```js\nconst md = require('markdown-it')();\nmd.use(require('markdown-it-yaml'), { templateDir: 'myDir' }\nconst html = md.render(markdown, {});\n```\n\nComplete usage:\n\n```js\nconst md = require('markdown-it')();\n\nmd.use(require('markdown-it-yaml'), {\n  // optional, these are the defaults\n  templateDir: '.',\n  markerStart: '```yaml',\n  markerEnd: '```',\n  typeKey: 'type',\n  templateExtension: '.html',\n  autoNumbering: false,\n  numberKey: 'number',\n  render: (template, obj) =\u003e {\n    return myFavoriteTemplateEngine(template, obj);\n  },\n  onObject: (obj) =\u003e {\n    // do whatever you want with the data\n  },\n  debug: false\n});\n\nconst markdown = 'Load your Markdown from somewhere...';\n\nconst env = {\n  someExtraTemplateData: 'foo'\n};\nconst html = md.render(markdown, env);\n\n// Access the parsed YAML objects\nfor (const obj of env.objects) {\n  console.log(obj);\n}\n```\n\n## Support\n\nI'll approve pull requests that are easy to understand. Feel free to open and I'll give my feedback.\n\nIf you need extra features, I'm available for hire.\n\n## License\n\nMIT © [Flavio Tordini](https://flavio.tordini.org/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviotordini%2Fmarkdown-it-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaviotordini%2Fmarkdown-it-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviotordini%2Fmarkdown-it-yaml/lists"}