{"id":13670021,"url":"https://github.com/jGleitz/markdown-it-prism","last_synced_at":"2025-04-27T09:31:23.090Z","repository":{"id":37611986,"uuid":"71077897","full_name":"jGleitz/markdown-it-prism","owner":"jGleitz","description":"Highlight code blocks in markdown-it using prism","archived":false,"fork":false,"pushed_at":"2024-11-01T19:27:56.000Z","size":8070,"stargazers_count":85,"open_issues_count":14,"forks_count":22,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-01T20:24:10.548Z","etag":null,"topics":["code-highlight","markdown","markdown-it","prismjs"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/jGleitz.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-16T21:20:47.000Z","updated_at":"2024-10-25T15:02:23.000Z","dependencies_parsed_at":"2023-09-26T23:40:18.181Z","dependency_job_id":"7fa4d035-1c17-4406-8378-2da6fbcaeb7f","html_url":"https://github.com/jGleitz/markdown-it-prism","commit_stats":{"total_commits":940,"total_committers":9,"mean_commits":"104.44444444444444","dds":0.4723404255319149,"last_synced_commit":"4663109f73d2f95b8547522d4ca62491f3210a21"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Fmarkdown-it-prism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Fmarkdown-it-prism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Fmarkdown-it-prism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jGleitz%2Fmarkdown-it-prism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jGleitz","download_url":"https://codeload.github.com/jGleitz/markdown-it-prism/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224066996,"owners_count":17250096,"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":["code-highlight","markdown","markdown-it","prismjs"],"created_at":"2024-08-02T09:00:29.959Z","updated_at":"2024-11-11T07:31:03.666Z","avatar_url":"https://github.com/jGleitz.png","language":"TypeScript","readme":"# markdown-it-prism [![Build Status](https://travis-ci.org/jGleitz/markdown-it-prism.svg?branch=master)](https://travis-ci.org/jGleitz/markdown-it-prism) [![npm version](https://badge.fury.io/js/markdown-it-prism.svg)](https://badge.fury.io/js/markdown-it-prism) [![Bower version](https://badge.fury.io/bo/markdown-it-prism.svg)](https://badge.fury.io/bo/markdown-it-prism)\n\n\u003e [markdown-it](https://github.com/markdown-it/markdown-it) plugin to highlight code blocks using [Prism](http://prismjs.com/)\n\n## Usage\n\n```js\nconst md = require('markdown-it')();\nconst prism = require('markdown-it-prism');\n\nmd.use(prism, options);\n```\n\nThe plugin will insert the necessary markup into all code blocks. [Include one of Prism’s stylesheets](http://prismjs.com/#basic-usage) in\nyour HTML to get highlighted code.\n\n### Options\n\nThe `options` object may contain:\n\n| Name                            | Description                                                                                                                                                                                                                                                                                                                                                       | Default     |\n|---------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|\n| `highlightInlineCode`           | Whether to highlight inline code.                                                                                                                                                                                                                                                                                                                                 | `false`     |\n| `plugins`                       | Array of [Prism Plugins](http://prismjs.com/#plugins) to load. The names to use can be found [here](https://github.com/PrismJS/prism/tree/master/plugins). Please note that some prism plugins (notably line-numbers) rely on the DOM being present and can thus not be used with this package (see [#1](https://github.com/jGleitz/markdown-it-prism/issues/1)). | `[]`        |\n| `init`                          | A function called after setting up prism. Will receive the prism instance as only argument. Useful for plugins needing further intialisation.                                                                                                                                                                                                                     | `() =\u003e {}`  |\n| `defaultLanguageForUnknown`     | The language to use for code blocks that specify a language that Prism does not know. No default will be used if this option is `undefined`.                                                                                                                                                                                                                      | `undefined` |\n| `defaultLanguageForUnspecified` | The language to use for code block that do not specify a language. No default will be used if this option is `undefined`.                                                                                                                                                                                                                                         | `undefined` |\n| `defaultLanguage`               | Shorthand to set both `defaultLanguageForUnknown` and `defaultLanguageForUnspecified` to the same value.                                                                                                                                                                                                                                                          | `undefined` |\n\n### Inline Code\n\nWhen `highlightInlineCode` is set, inline code will be highlighted just like fenced code blocks are.\nTo specifiy the language of inline code, add `{language=\u003cyour-language\u003e}` after the code segment:\n\n```markdown\n`class Demo { };`{language=cpp}\n```\n\nThis syntax is compatible with [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs):\nThe `language=\u003cx\u003e` part will be stripped, but everything else between `{` and `}` will work\nwith [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs) as usual.\n\n## Usage with Webpack\n\nIf you want to use this plugin together with [Webpack](https://webpack.js.org/), you need to import all languages you intend to use:\n\n```javascript\nimport MarkdownIt from 'markdown-it';\nimport prism from 'markdown-it-prism';\n\nimport \"prismjs/components/prism-clike\"\nimport \"prismjs/components/prism-java\"\n\nfunction component() {\n\tconst md = new MarkdownIt();\n\tmd.use(prism);\n\tconst element = document.createElement('div');\n\telement.innerHTML = md.render(`\nHere is some *code*:\n\\`\\`\\`java\npublic class Test {\n  public void foo() {}\n}\n\\`\\`\\`\n`);\n\n\treturn element;\n}\n\ndocument.body.appendChild(component());\n```\n\n*Beware*: Prisms languages have dependencies onto each other. You need to import the languages together with their dependencies in the\ncorrect order.\n","funding_links":[],"categories":["Pre-packed","🙌 Marp をもっと楽しむ 🙌"],"sub_categories":["Plugins","Markdown 拡張構文の利用"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjGleitz%2Fmarkdown-it-prism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FjGleitz%2Fmarkdown-it-prism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FjGleitz%2Fmarkdown-it-prism/lists"}