{"id":15689533,"url":"https://github.com/jdalrymple/markdown-it-codeblocks","last_synced_at":"2025-03-30T12:12:31.841Z","repository":{"id":119015787,"uuid":"101335156","full_name":"jdalrymple/markdown-it-codeblocks","owner":"jdalrymple","description":"Simple plugin for segmenting sample code and reference blocks in markdown processing","archived":false,"fork":false,"pushed_at":"2019-04-23T14:19:01.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T21:44:11.042Z","etag":null,"topics":["markdown","markdown-it-plugin","nodejs"],"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/jdalrymple.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-24T20:28:51.000Z","updated_at":"2019-04-23T14:19:03.000Z","dependencies_parsed_at":"2023-08-01T11:16:08.058Z","dependency_job_id":null,"html_url":"https://github.com/jdalrymple/markdown-it-codeblocks","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":"0.11764705882352944","last_synced_commit":"f47487d6e43aa07df7b879e1caa2b0ff60dc18e4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fmarkdown-it-codeblocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fmarkdown-it-codeblocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fmarkdown-it-codeblocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fmarkdown-it-codeblocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdalrymple","download_url":"https://codeload.github.com/jdalrymple/markdown-it-codeblocks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314168,"owners_count":20757463,"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-plugin","nodejs"],"created_at":"2024-10-03T18:02:58.599Z","updated_at":"2025-03-30T12:12:31.818Z","avatar_url":"https://github.com/jdalrymple.png","language":"JavaScript","readme":"# markdown-it-codeblocks\n\nSplits up your header sections into samples and references ie :\n\n````markdown\n#heading1\n\nHere is some sample code\n\n```code\nvar a = 8;\n```\n\ndescription here\n\n````\n\nwould get converted to:\n\n```html\n\u003ch1\u003e heading1 \u003c/h1\u003e\n\u003csection class='sample'\u003e\n\t\u003cp\u003e \n       Here is some sample code\n    \u003c/p\u003e\n\t\u003ccode\u003e var a = 8 \u003c/code\u003e\n\u003c/section\u003e\n\n\u003csection class='reference'\u003e\n\tdescription here\n\u003c/section\u003e\n\n```\n\nIf there are multiple code sections, it will only include up to the last consecuritve code section:\n\n````markdown\n#heading1\n\nHere is some sample code\n\n```code\nvar a = 8;\n```\n\n```code\nvar a = 2;\n```\n\nSome more text\n\n````\n\nwould get converted to:\n\n```html\n\u003ch1\u003e heading1 \u003c/h1\u003e\n\u003csection class='sample'\u003e\n\t\u003cp\u003e \n        Here is some sample code\n    \u003c/p\u003e\n\t\u003ccode\u003e var a = 8 \u003c/code\u003e\n\t\u003ccode\u003e var a = 2 \u003c/code\u003e\n\u003c/section\u003e\n\n\u003csection class='reference'\u003e\n\tSome more text\n\u003c/section\u003e\n\n```\n\nBut, if there is anything inbetween those sections like:\n\n\n````markdown\n#heading1\n\nHere is some sample code\n\n```code\nvar a = 8;\n```\n\nSome other markdown in between these two code sections\n\n\n```code\nvar a = 2;\n```\n\nSome more text\n\n````\n\nit would get converted to:\n\n```html\n\u003ch1\u003e heading1 \u003c/h1\u003e\n\u003csection class='sample'\u003e\n\t\u003cp\u003e \n        Here is some sample code\n    \u003c/p\u003e\n\t\u003ccode\u003e var a = 8 \u003c/code\u003e\n\u003c/section\u003e\n\n\u003csection class='reference'\u003e\n\t\u003cp\u003e\n\t\tSome other markdown inbetween these two code sections\n\t\u003c/p\u003e\n\t\u003ccode\u003e var a = 2 \u003c/code\u003e\n\t\u003cp\u003e\n\t\tSome more text\n\t\u003c/p\u003e\n\u003c/section\u003e\n\n```\n\nWorks well when combined with the [markdown-it-header-sections](https://www.npmjs.com/package/markdown-it-header-sections) plugin!\n\n# Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [API](#api)\n* [License](#licence)\n* [Changelog](#changelog)\n\n# Install\n```\nnpm install -S markdown-it-codeblocks\n```\n\n# Usage\n\nWith defaults:\n\n```javascript\nconst MarkdownItCodeBlocks = require('markdown-it-codeblocks');\nconst MarkdownIt = require('markdown-it')\n\t.use(MarkdownItCodeBlocks)\n```\n\nWith custom classes:\n\n```javascript\nconst MarkdownItCodeBlocks = require('markdown-it-codeblocks');\nconst MarkdownIt = require('markdown-it')\n\t.use(MarkdownItCodeBlocks, {sampleClass:'foo', referenceClass:'bar'})\n```\n\nWith level grouping:\n\n```javascript\nconst MarkdownItCodeBlocks = require('markdown-it-codeblocks');\nconst MarkdownIt = require('markdown-it')\n\t.use(MarkdownItCodeBlocks, {levelGrouping:2})\n```\n\nThis would group all headings within the 2 headings that are larger than 2 ie:\n\n````markdown\n## heading2a\n\nSome markdown\n\n### inner heading\n\n#### another inner heading\n\n\n## heading2b\n\n````\n\nIn this case, everything between `heading2a` and `heading2b` will be considered a single section\n\n# API\n\nMarkdownItCodeBlocks(md, options)\n\n\nParameters:\n\n| Attribute | Type | Required | Description | Default |\n| --------- | ---- | -------- | ----------- | ------- |\n| `md` | String | yes | The input markdown  |         |\n| `options.sampleClass` | String | no | Class assigned to the sample blocks | 'sample' |\n| `options.referenceClass` | String | no | Class assigned to the reference blocks | 'reference' |\n| `options.levelGrouping` | Integer | no | Allows you to group certain headings into one section. | null |\n\n# License\n\nMIT\n\n# Changelog\n\n[1.0.0](https://github.com/jdalrymple/markdown-it-codeblocks/commit/6628f28aaa11d5f8382dee9c1adf506aea638bd0) (2017-09-02)\n------------------\n- Release","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdalrymple%2Fmarkdown-it-codeblocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdalrymple%2Fmarkdown-it-codeblocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdalrymple%2Fmarkdown-it-codeblocks/lists"}