{"id":16078160,"url":"https://github.com/BansheeTech/AgnosticHTML","last_synced_at":"2025-03-18T05:31:19.957Z","repository":{"id":257812291,"uuid":"868378778","full_name":"BansheeTech/AgnosticHTML","owner":"BansheeTech","description":"AgnosticHTML: A utility function that safely parses HTML strings into DOM nodes, avoiding the use of innerHTML for security reasons.","archived":false,"fork":false,"pushed_at":"2024-10-09T23:51:00.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T07:34:44.945Z","etag":null,"topics":["agnostichtml","createelement","cross-site-scripting","document","dom","html","html-to-dom","innerhtml","javascript","node","parser","safe-dom","sanitization","sanitizer","secure-html","security","vanilla-javascript","vanilla-js","xss"],"latest_commit_sha":null,"homepage":"https://github.com/BansheeDevelopment/AgnosticHTML","language":"JavaScript","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/BansheeTech.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-06T08:24:12.000Z","updated_at":"2025-01-30T17:33:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"831a00b2-f979-4896-8965-234402a3dee5","html_url":"https://github.com/BansheeTech/AgnosticHTML","commit_stats":null,"previous_names":["bansheedevelopment/agnostichtml","banshee-technologies/agnostichtml","bansheetech/agnostichtml"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BansheeTech%2FAgnosticHTML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BansheeTech%2FAgnosticHTML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BansheeTech%2FAgnosticHTML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BansheeTech%2FAgnosticHTML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BansheeTech","download_url":"https://codeload.github.com/BansheeTech/AgnosticHTML/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243903175,"owners_count":20366437,"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":["agnostichtml","createelement","cross-site-scripting","document","dom","html","html-to-dom","innerhtml","javascript","node","parser","safe-dom","sanitization","sanitizer","secure-html","security","vanilla-javascript","vanilla-js","xss"],"created_at":"2024-10-09T10:08:12.924Z","updated_at":"2025-03-18T05:31:19.951Z","avatar_url":"https://github.com/BansheeTech.png","language":"JavaScript","readme":"\n# AgnosticHTML\n\nAgnosticHTML is a lightweight utility for safely parsing HTML strings into DOM nodes, avoiding the use of `innerHTML` for security reasons. It provides a safe alternative for embedding dynamic HTML content into the DOM while offering configurable debugging capabilities for `console.log` and `console.warn`.\n\n## Installation\n\nTo install AgnosticHTML using npm, run the following command:\n\n```bash\nnpm install agnostic-html\n```\n\n## Usage\n\nTo use AgnosticHTML, import the `agnosticHTML` function and configure it to enable or disable debug messages. After configuration, you can safely insert HTML content into the DOM without using `innerHTML`.\n\n### Example:\n\n```javascript\nimport { agnosticHTML } from 'agnostic-html';\n\n// Configure AgnosticHTML with debug options\nwindow.agnosticHTML = agnosticHTML({ debugLog: true, debugWarn: true });\n\n// Insert HTML content into a specific DOM element\nwindow.agnosticHTML(\n  \\`\n  \u003cbutton type=\"button\" class=\"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800\"\u003eAgnosticHTML Button\u003c/button\u003e\n  \\`,\n  \"#html-selector\"\n);\n```\n\nIn this example, **AgnosticHTML** inserts a button into the element with the ID `#html-selector`. If the element does not exist, a warning will be shown in the console, depending on the debug settings.\n\n### Default Target (without specifying a container):\n\nIf you don't specify a custom container (e.g., `#html-selector`), the content will be inserted into the `\u003cbody\u003e` element by default:\n\n```javascript\n// Insert HTML content into the \u003cbody\u003e element by default\nwindow.agnosticHTML(\n  \\`\n  \u003cbutton type=\"button\" class=\"text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800\"\u003eAgnosticHTML Button\u003c/button\u003e\n  \\`\n);\n```\n\n## Disable Warns and/or Logs\n\nAgnosticHTML allows you to control the appearance of `console.log` and `console.warn` messages through optional flags. You can enable or disable these messages as needed using the following options:\n\n- `debugLog`: Controls the appearance of informational messages (`console.log`). It can be set to `true` or `false`.\n- `debugWarn`: Controls the appearance of warning messages (`console.warn`). It can be set to `true` or `false`.\n\nBy default, both flags are disabled.\n\n### Example usage:\n\nShow only warns on console:\n```javascript\nwindow.agnosticHTML = agnosticHTML({ debugLog: false, debugWarn: true });\n```\n\nShow only debug messages on console:\n```javascript\nwindow.agnosticHTML = agnosticHTML({ debugLog: true, debugWarn: false });\n```\n\nDoesn't show any message:\n```javascript\nwindow.agnosticHTML = agnosticHTML({ debugLog: false, debugWarn: false });\n```\n\n## License\n\nAgnosticHTML is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Issues\n\nIf you encounter any issues, feel free to report them [here](https://github.com/BansheeDevelopment/AgnosticHTML/issues).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBansheeTech%2FAgnosticHTML","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBansheeTech%2FAgnosticHTML","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBansheeTech%2FAgnosticHTML/lists"}