{"id":16184623,"url":"https://github.com/rmariuzzo/xml-comment-api","last_synced_at":"2025-04-02T00:31:53.587Z","repository":{"id":57401797,"uuid":"98478844","full_name":"rmariuzzo/xml-comment-api","owner":"rmariuzzo","description":"Parse XML comment that provide an API","archived":false,"fork":false,"pushed_at":"2021-10-15T22:00:57.000Z","size":101,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T03:23:03.919Z","etag":null,"topics":["xml"],"latest_commit_sha":null,"homepage":null,"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/rmariuzzo.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":"2017-07-27T01:05:47.000Z","updated_at":"2023-03-09T01:19:11.000Z","dependencies_parsed_at":"2022-09-15T18:21:53.208Z","dependency_job_id":null,"html_url":"https://github.com/rmariuzzo/xml-comment-api","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fxml-comment-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fxml-comment-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fxml-comment-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2Fxml-comment-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmariuzzo","download_url":"https://codeload.github.com/rmariuzzo/xml-comment-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246720434,"owners_count":20822902,"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":["xml"],"created_at":"2024-10-10T07:10:50.642Z","updated_at":"2025-04-02T00:31:53.063Z","avatar_url":"https://github.com/rmariuzzo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=center\u003e\n  \u003ch1\u003eXML Comment API\u003c/h1\u003e\n  \u003cp\u003eParse XML comment that provide an API\u003c/p\u003e\n  \u003cimg src=\"banner.png\"\u003e\n\u003c/div\u003e\n\n## Installation\n\n```shell\nnpm install xml-comment-api\n```\n\n## Usage\n\n```js\nconst XmlCommentApi = require('xml-comment-api')\n\nconst input = `\n  # Hello World\n  \u003c!-- salute(name:Rubens) --\u003e \u003c!-- /salute --\u003e\n`\n\nXmlCommentApi(input).replace('salute', (tag) =\u003e `Hi ${tag.attributes.name}`)\n// \u003e # Hello World\n//   \u003c!-- salute(name:Rubens) --\u003eHi Rubens\u003c!-- /salute --\u003e\n```\n\n## API\n\nEverything starts by invoking the `XmlCommentApi` function passing the string containgin XML comments.\n\n```js\nconst XmlCommentApi = require('xml-comment-api')\nXmlCommentApi('\u003c!-- tag-name --\u003e \u003c!-- /tag-name --\u003e')\n```\n\nWhen `XmlCommentApi` is invoked it will return an object exposing a few methods:\n\n### `find(name: String, options: Object) : Array`\n\nFind all tags by `name`. The `name` by default is case sensitive. The second parameter are `options`.\n\n```js\nXmlCommentApi('\u003c!-- salute --\u003e😘\u003c!-- /salute --\u003e')\n  .find('salute')\n\n// \u003e  [{\n//      tag: 'salute', \n//      attributes: undefined,\n//      contents: '😘',\n//      start: 15,\n//      end: 17\n//    }]\n```\n\n### `replace(name: String, options: Object, callback: Function|String) : XmlCommentApiObject`\n\nFind all tags by `name` using `options` and replace the contents of matching tags with the result of the `callback` (when a `Function` is given) or with the `callback` itself (when a `String` is given).\n\n```js\nXmlCommentApi('\u003c!-- salute --\u003e😘\u003c!-- /salute --\u003e')\n  .replace('salute', '❤️')\n  .contents()\n\n// \u003e  \u003c!-- salute --\u003e❤️\u003c!-- /salute --\u003e\n```\n\n### `contents() : String`\n\nReturn the modified string. Useful when using `replace` to obtain the modified string.\n\n#### License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fxml-comment-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmariuzzo%2Fxml-comment-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fxml-comment-api/lists"}