{"id":14767667,"url":"https://github.com/valeriangalliat/markdown-it-highlightjs","last_synced_at":"2025-04-12T13:33:55.632Z","repository":{"id":28890275,"uuid":"32414945","full_name":"valeriangalliat/markdown-it-highlightjs","owner":"valeriangalliat","description":"Preset to use highlight.js with markdown-it.","archived":false,"fork":false,"pushed_at":"2024-10-10T11:25:44.000Z","size":314,"stargazers_count":58,"open_issues_count":2,"forks_count":31,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-19T22:55:00.295Z","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":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valeriangalliat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2015-03-17T19:22:28.000Z","updated_at":"2024-10-13T09:34:40.000Z","dependencies_parsed_at":"2024-05-16T22:46:40.688Z","dependency_job_id":"aec31b8f-b981-4b71-98a3-b45759c55e46","html_url":"https://github.com/valeriangalliat/markdown-it-highlightjs","commit_stats":{"total_commits":74,"total_committers":8,"mean_commits":9.25,"dds":0.2567567567567568,"last_synced_commit":"4a0ad28a6dc2b096d27706c861415ffc2c2c3178"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriangalliat%2Fmarkdown-it-highlightjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriangalliat%2Fmarkdown-it-highlightjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriangalliat%2Fmarkdown-it-highlightjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valeriangalliat%2Fmarkdown-it-highlightjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valeriangalliat","download_url":"https://codeload.github.com/valeriangalliat/markdown-it-highlightjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573403,"owners_count":21126824,"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-09-16T11:00:39.018Z","updated_at":"2025-04-12T13:33:55.585Z","avatar_url":"https://github.com/valeriangalliat.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# markdown-it-highlightjs [![npm version](https://img.shields.io/npm/v/markdown-it-highlightjs.svg?style=flat-square)](https://www.npmjs.org/package/markdown-it-highlightjs)\n\n\u003e Preset to use [highlight.js] with [markdown-it].\n\n[highlight.js]: https://highlightjs.org/\n[markdown-it]: https://github.com/markdown-it/markdown-it\n\n## Usage\n\n```js\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs'), opts)\n```\n\nThis will process all code blocks with highlight.js to add `span`\nelements around grammatical keywords with specific classes, that can\nthen be syled with CSS. You can find a list of preset highlighting\nstyles [here](https://github.com/highlightjs/highlight.js/tree/main/src/styles).\n\nThe `opts` object can contain:\n\n| Name             | Type    | Description                                                                                                               | Default                   |\n|------------------|---------|---------------------------------------------------------------------------------------------------------------------------|---------------------------|\n| `auto`           | boolean | Whether to automatically detect language if not specified.                                                                | `true`                    |\n| `code`           | boolean | Whether to add the `hljs` class to raw code blocks (not fenced blocks).                                                   | `true`                    |\n| `register`       | object  | Register other languages which are not included in the standard pack.                                                     | `null`                    |\n| `inline`         | boolean | Whether to highlight inline code.                                                                                         | `false`                   |\n| `hljs`           | object  | Provide the instance of [highlight.js] to use for highlighting                                                            | `require('highlight.js')` |\n| `ignoreIllegals` | boolean | Forces highlighting to finish even in case of detecting illegal syntax for the language instead of throwing an exception. | `true`                    |\n\n## Register languages\n\n```js\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs'), {\n    register: {\n      cypher: require('highlightjs-cypher')\n    }\n  })\n```\n\n## Inline code highlighting\n\nYou can enable inline code highlighting by setting `inline` to true:\n\n```js\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs'), { inline: true })\n```\n\nYou can specify the language for inline code using\n[Pandoc syntax](https://pandoc.org/MANUAL.html#extension-inline_code_attributes):\n\n```markdown\n`x=4`{.js}\n```\n\nOr [kramdown IAL syntax](https://kramdown.gettalong.org/syntax.html#inline-attribute-lists):\n\n```markdown\n`x=4`{:.js}\n```\n\nIf you do not specify a language, then highlight.js will attempt to\nguess the language if `auto` is true (which it is by default).\n\n### Usage with markdown-it-attrs\n\nIf you use markdown-it-attrs, make sure to include it *after*\nmarkdown-it-highlightjs if you want inline code highlighting to work:\n\n```js\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs'), { inline: true })\n  .use(require('markdown-it-attrs'))\n```\n\n## Provide the [highlight.js] instance\n\nYou can specify the `hljs` option to override the default [highlight.js]\ninstance with your own:\n\n```js\nconst hljs = require('highlight.js/lib/core')\n\nhljs.registerLanguage(\n  'javascript',\n  require('highlight.js/lib/languages/javascript')\n)\n\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs'), { hljs })\n```\n\n## Core plugin\n\nYou may import the core `markdown-it-highlightjs` plugin directly,\nwithout any default options. You must specify an instance of\n[highlight.js] for the `hljs` option.\n\n```js\nconst hljs = require('highlight.js/lib/core')\n\nconst md = require('markdown-it')()\n  .use(require('markdown-it-highlightjs/core'), { hljs })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriangalliat%2Fmarkdown-it-highlightjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaleriangalliat%2Fmarkdown-it-highlightjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaleriangalliat%2Fmarkdown-it-highlightjs/lists"}