{"id":14971367,"url":"https://github.com/nmyvision/html2pug","last_synced_at":"2025-10-26T15:30:29.728Z","repository":{"id":57131463,"uuid":"150006807","full_name":"NMyVision/html2pug","owner":"NMyVision","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-11T00:22:26.000Z","size":145,"stargazers_count":2,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T20:55:52.685Z","etag":null,"topics":[],"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/NMyVision.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-09-23T17:10:39.000Z","updated_at":"2022-08-11T15:29:06.000Z","dependencies_parsed_at":"2022-08-31T19:41:57.011Z","dependency_job_id":null,"html_url":"https://github.com/NMyVision/html2pug","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/NMyVision%2Fhtml2pug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMyVision%2Fhtml2pug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMyVision%2Fhtml2pug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NMyVision%2Fhtml2pug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NMyVision","download_url":"https://codeload.github.com/NMyVision/html2pug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238347904,"owners_count":19457012,"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-24T13:45:05.755Z","updated_at":"2025-10-26T15:30:24.377Z","avatar_url":"https://github.com/NMyVision.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# html2pug\n\n\n#### ✔ Documentation is for v2 which is a complete rewrite \n\nConverts **HTML** to **Pug** templating language (_formerly Jade_).  \nRequires Node.js version `7.6` or higher. Library written in typescript.\n\nTurns this :unamused:\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\n  \u003chead\u003e\n    \u003ctitle\u003eJade\u003c/title\u003e\n    \u003cscript type=\"text/javascript\"\u003e\n      const foo = true;\n      let bar = function() {};\n      if (foo) {\n        bar(1 + 5)\n      }\n    \u003c/script\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch1\u003ePug - node template engine\u003c/h1\u003e\n    \u003cnav aria-label=\"breadcrumb\"\u003e\n      \u003col class=\"breadcrumb\"\u003e\n        \u003cli class=\"breadcrumb-item active\" aria-current=\"page\"\u003eHome\u003c/li\u003e\n      \u003c/ol\u003e\n    \u003c/nav\u003e\n    \u003cdiv class=\"col\" id=\"container\"\u003e\n      \u003cp\u003eYou are amazing\u003c/p\u003e\n      \u003cp\u003e\n        Jade is a terse and simple\n        templating language with a\n        strong focus on performance\n        and powerful features.\n      \u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\n\u003c/html\u003e\n```\n\nInto this :tada:\n```pug\ndoctype html\nhtml\n  head\n    title Jade\n    script(type=\"text/javascript\").\n      const foo = true;\n      let bar = function() {};\n      if (foo) {\n      bar(1 + 5)\n      }\n  body\n    h1 Pug - node template engine\n    nav(aria-label=\"breadcrumb\"): ol.breadcrumb: li.breadcrumb-item.active(aria-current=\"page\") Home\n    #container.col\n      p You are amazing\n      p\n        | Jade is a terse and simple\n        | templating language with a\n        | strong focus on performance\n        | and powerful features.\n```\n\n\n## Programmatically\n\n```js\nimport Parser from \"@nmyvision/html2pug\"\n\nconst parser = new Parser({ tabs: true, collapse: true }) \n/* new Parser(undefined) ... for defaults */\nconst html = '\u003cheader\u003e\u003ch1 class=\"title\"\u003eHello World!\u003c/h1\u003e\u003c/header\u003e'\nconst pug = parser.parse(html)\n```\n\n## Options\n\nName | Version | Type | Default | Description\n--- |:---:| --- |:---:| ---\ntabs | all | Boolean | `false` | Use tabs instead of spaces\ncollapse | all | Boolean | `true` | Combine when possible using : notation\ncommas | v2 | Boolean | `false` | Add commas between attributes\ndoubleQuotes | v2 | Boolean | `true` | Use double quotes \ntabs | v2 | Boolean | `false` | Use tabs (`tabChar`) otherwise use (`whitespaceChar`)\npreserveTags | v2 | Boolean | `['script', 'pre']` | element renders with . ending\ntabChar | v2 | Boolean | `'\\t'` | system tab character\nwhitespaceChar | v2 | Boolean | `'  '` | two spaces\n\n# Why \n\n*Why even create another HTML 2 Pug/Jade library?*\n\nThere were a few scenerios that most libraries didn't address. \n\n## Shorthand \n\n***source***\n```html\n\u003cnav aria-label=\"breadcrumb\"\u003e\n  \u003col class=\"breadcrumb\"\u003e\n    \u003cli\u003eSample\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/nav\u003e\n```\n**before**\n\n```pug\nnav(aria-label=\"breadcrumb\")\n  ol.breadcrumb\n    li Sample\n```\n\n**after** (with collapse flag)\n```pug\nnav(aria-label=\"breadcrumb\"): ol.breadcrumb: li Sample\n```\n## Proper handle of non typical class names \n\n**source**\n```html\n\u003col class=\"sm:hover x-translate-1/2\"\u003e\n  Stuff  \n\u003c/ol\u003e\n\n\u003cdiv class=\"sm:hover x-translate-1/2\"\u003e\n  Stuff  \n\u003c/div\u003e\n```\n**before** note period \"ol.\"\n```pug\nol.(class='sm:hover x-translate-1/2')\n  | Stuff\n\n.(class='sm:hover x-translate-1/2')\n  | Stuff\n```\n\n**after**\n```pug\nol(class=\"sm:hover x-translate-1/2\") Stuff\n\ndiv(class=\"sm:hover x-translate-1/2\") Stuff\n```\n---\n\n## Some invalid results \n\n**source**\n```html\n\u003ca\u003eLink A\u003c/a\u003e | \u003ca\u003eLink\u003c/a\u003e\n```\n**before**\n```pug\na Link A\n|  \na Link B\n```\n\n**after** spaces shown with '.'\n```pug\na Link A\n| .|.\na Link B\n```\n\u003c!--\ntextElements | String[] | `['pre','script']`| element renders with . ending\nrecommended | Boolean | `false` | wrap extra \\| around elements surrounded by text\nomitPre | Boolean | `true` | Do not render the contents of the pre text --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmyvision%2Fhtml2pug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmyvision%2Fhtml2pug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmyvision%2Fhtml2pug/lists"}