{"id":19388811,"url":"https://github.com/james2doyle/grunt-highlight","last_synced_at":"2025-04-23T23:31:45.425Z","repository":{"id":12063535,"uuid":"14650213","full_name":"james2doyle/grunt-highlight","owner":"james2doyle","description":"Use highlight.js via a Grunt task","archived":false,"fork":false,"pushed_at":"2014-09-04T18:37:55.000Z","size":179,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T22:32:53.279Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mpandey-myglobalit/SGKBarcodeBundle","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/james2doyle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-23T20:52:42.000Z","updated_at":"2016-12-02T21:26:36.000Z","dependencies_parsed_at":"2022-09-07T01:01:22.795Z","dependency_job_id":null,"html_url":"https://github.com/james2doyle/grunt-highlight","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fgrunt-highlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fgrunt-highlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fgrunt-highlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fgrunt-highlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james2doyle","download_url":"https://codeload.github.com/james2doyle/grunt-highlight/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250532103,"owners_count":21446117,"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-11-10T10:13:47.549Z","updated_at":"2025-04-23T23:31:45.134Z","avatar_url":"https://github.com/james2doyle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-highlight\n\n\u003e Run highlight.js over files\n\n## Getting Started\nThis plugin requires Grunt.\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-highlight --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-highlight');\n```\n\n## The \"highlight\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `highlight` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  highlight: {\n    task: {\n      options: {\n        // Task-specific options go here.\n      },\n      your_target: {\n        // Target-specific file lists and/or options go here.\n      }\n    }\n  }\n});\n```\n\n### Options\n\n#### options.lang\nType: `Boolean`\nDefault value: `false`\n\nIf you know the highlight language, use this.\n\n#### options.useCheerio\nType: `Boolean`\nDefault value: `true`\n\nYou target files are HTML and you want to parse over them and highlight code blocks. *Turn off for raw code input*.\n\n#### options.selector\nType: `Boolean`\nDefault value: `pre code`\n\nThis is what cheerio will be looking for as code block in your HTML. *Only used when useCheerio is true*.\n\n### Usage Examples\n\n#### Default Options\n\n```js\ngrunt.initConfig({\n  highlight: {\n    task: {\n      options: {},\n      files: {\n        'dest/out.html': ['src/in.html'],\n      }\n    }\n  }\n});\n```\n\n#### Full Code Files\n\nIf you want to highlight an entire file then use the following:\n\n```js\ngrunt.initConfig({\n  highlight: {\n    task: {\n      options: {\n        useCheerio: false,\n        lang: 'javascript' // treat the file as a javascript file\n      },\n      files: {\n        'dest/highlighted.html': ['src/bunch-o-javascript.js'],\n      }\n    }\n  }\n});\n```\n\n#### One-to-One Compilation\n\nSometimes you want to take in a folder of code, and output a folder of highlighted HTML.\n\n```js\nhighlight: {\n  scripts: {\n    options: {\n      useCheerio: false, // these are pure js files\n      lang: 'javascript' // there is no auto-detect for files\n    },\n    files: [{\n      expand: true,\n      cwd: 'scripts', // in folder\n      src: ['{,*/}*.js'],\n      dest: 'html', // out folder\n      rename: function(dest, src) {\n        // we dont want the output to be .js, make it .html\n        return dest + '/' + src.replace(/\\.js$/, '.html');\n      }\n    }]\n  }\n}\n```\n\n#### Many Tasks\n\n```js\ngrunt.initConfig({\n  highlight: {\n    scripts: {\n      options: {\n        useCheerio: false,\n        lang: 'javascript'\n      },\n      files: {\n        'javascript.html': ['src/script.js']\n      }\n    },\n    styles: {\n      options: {\n        useCheerio: false,\n        lang: 'css'\n      },\n      files: {\n        'stylesheet.html': ['src/style.css']\n      }\n    }\n  }\n});\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n_(Nothing yet)_\n\n## License\nCopyright (c) 2013 James Doyle. Licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fgrunt-highlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames2doyle%2Fgrunt-highlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fgrunt-highlight/lists"}