{"id":24568733,"url":"https://github.com/lwhiteley/gitbook-plugin-codegroup","last_synced_at":"2025-07-05T20:37:42.380Z","repository":{"id":30853423,"uuid":"126056932","full_name":"lwhiteley/gitbook-plugin-codegroup","owner":"lwhiteley","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-05T02:46:25.000Z","size":386,"stargazers_count":7,"open_issues_count":8,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T17:22:02.510Z","etag":null,"topics":["codegroup","codetabs","gitbook","gitbook-plugin","markdown","markdown-to-html","markdown-to-pdf","tabs"],"latest_commit_sha":null,"homepage":"https://plugins.gitbook.com/plugin/codegroup","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lwhiteley.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":"2018-03-20T17:28:43.000Z","updated_at":"2021-09-04T14:38:29.000Z","dependencies_parsed_at":"2023-01-14T17:49:37.507Z","dependency_job_id":null,"html_url":"https://github.com/lwhiteley/gitbook-plugin-codegroup","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwhiteley%2Fgitbook-plugin-codegroup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwhiteley%2Fgitbook-plugin-codegroup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwhiteley%2Fgitbook-plugin-codegroup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lwhiteley%2Fgitbook-plugin-codegroup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lwhiteley","download_url":"https://codeload.github.com/lwhiteley/gitbook-plugin-codegroup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250285782,"owners_count":21405308,"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":["codegroup","codetabs","gitbook","gitbook-plugin","markdown","markdown-to-html","markdown-to-pdf","tabs"],"created_at":"2025-01-23T14:55:14.864Z","updated_at":"2025-04-22T17:22:04.897Z","avatar_url":"https://github.com/lwhiteley.png","language":"JavaScript","readme":"GitBook CodeGroup Plugin\n==============\n\n[![npm version](https://badge.fury.io/js/gitbook-plugin-codegroup.svg)](https://badge.fury.io/js/gitbook-plugin-codegroup)\n[![Build Status](https://travis-ci.org/lwhiteley/gitbook-plugin-codegroup.svg?branch=master)](https://travis-ci.org/lwhiteley/gitbook-plugin-codegroup)\n\n## Add Plugin\n\nbook.json\n```js\n{\n    \"plugins\": [\"codegroup\"]\n}\n```\n\nthen run\n```bash\n$ gitbook install\n```\n\n### Configure (Optional Step)\n\nbook.json\n```js\n\"pluginsConfig\": {\n    \"codegroup\":{\n        \"defaultTabName\": \"Code\",\n        \"tabNameSeperator\": \"::\",\n        \"rememberTabs\": true\n    }\n}\n```\n\n### Config Options:\n| Option | Description |\n| ------------- | ------------- |\n| defaultTabName {string} \u003cbr\u003e **default**: `Code` | a fallback tab name if no language is specied for a fenced code block  |\n| tabNameSeperator {string}  \u003cbr\u003e **default**: `::` | a string delimeter that differentiates the language name from the tab name  |\n| rememberTabs {boolean}  \u003cbr\u003e **default**: `false` |determines if the plugin will remember the selected tab, given the info in the codegroup has not changed  |\n\n## Template\n\n\u003cpre\u003e\n\u003ccode\u003e\n{% codegroup %}\n```js::sdk\n    var s = console.log;\n```\n```js\n    var s = console.warn;\n```\n{% endcodegroup %}\n\u003c/code\u003e\n\u003c/pre\u003e\n\n##### Args\n\n`codegroup` takes optional named arguments: \n\n- `rememberTabs` (`boolean`): Overrides value in `pluginsConfig.codegroup.rememberTabs`.\n- `defaultTabName` (`string`): A default tab name to use for the specific code group. Overrides value in `pluginsConfig.codegroup.defaultTabName`\n\n**example**:\n\u003cpre\u003e\n\u003ccode\u003e\n{% codegroup rememberTabs=true, defaultTabName=\"Snippet\" %}\n```js::nodejs\n    var s = \"sample\";\n```\n```swift\n    let s: String = \"sample\";\n```\n{% endcodegroup %}\n\u003c/code\u003e\n\u003c/pre\u003e\n\n\n#### Notes:\n- ebook/PDF compatible\n- The goal of this project is to write codegroups/codetabs as close to markdown as possible\n\n### Custom Named Tabs\n\nAs seen in the example above, tabs can have custom names for situations where it is required to group the same language and there is need to differentiate them.\n\nThe example above shows a code block `js::sdk`, where `js` is the language syntax to be used and `sdk` denotes the name to be seen in the tab; `::` (configurable) is used to separate both terms.\n\n### Custom Print Titles\n\nIt is also possible to supply a `Print Title` using a second `tabNameSeperator`\n\n**Examples**:\n\n| Example | Description |\n| ------------- | ------------- |\n| **Explicit** \u003cbr/\u003e\u003cbr/\u003e `js::sdk::Javascript SDK`| When converted to pdf, `Javascript SDK` will be placed above the code block |\n| **Syntax+Print Only** \u003cbr/\u003e\u003cbr/\u003e`js::::Javascript SDK`| It is possible to omit the `custom tab name` by using a double `tabNameSeperator` |\n| **TabName+Print Only** \u003cbr/\u003e\u003cbr/\u003e`::sdk::Javascript SDK`| It is possible to omit the `syntax name` to only define the `custom tab name` and `print title` |\n| **Print Only** \u003cbr/\u003e\u003cbr/\u003e`::::Javascript SDK` |It is possible to omit the `syntax name` and `custom tab name` by using a double `tabNameSeperator` |\n\n### CodeGroup Use Case:\n- This is ideal for displaying similar usages of the same code in multiple languages\n    - for example an sdk that can be used in several languages\n\n### Output Sample:\n![js-tab](https://i.imgur.com/UhTS6j9.png)\n![swift-tab](https://i.imgur.com/E08d0oV.png)\n\n### Similar Projects\n- [remarkable-codegroup](https://github.com/lwhiteley/remarkable-codegroup)\n- [GitbookIO/plugin-codetabs](https://github.com/GitbookIO/plugin-codetabs)\n\n### TODOs:\n- consider using a select list in mobile\n\nPull requests are welcome\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwhiteley%2Fgitbook-plugin-codegroup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flwhiteley%2Fgitbook-plugin-codegroup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flwhiteley%2Fgitbook-plugin-codegroup/lists"}