{"id":28092589,"url":"https://github.com/kiranparajuli589/htmlmark","last_synced_at":"2025-05-13T13:21:19.704Z","repository":{"id":41517649,"uuid":"509997109","full_name":"kiranparajuli589/htmlmark","owner":"kiranparajuli589","description":"A very lightweight Markdown Parser ✨","archived":false,"fork":false,"pushed_at":"2024-11-20T19:44:56.000Z","size":3869,"stargazers_count":17,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T04:39:23.800Z","etag":null,"topics":["hacktoberfest","hacktoberfest2023","javascript","lexer","markdown","nodejs","parser"],"latest_commit_sha":null,"homepage":"https://kiranparajuli589.github.io/htmlmark/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiranparajuli589.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-07-03T10:57:24.000Z","updated_at":"2025-04-16T00:49:26.000Z","dependencies_parsed_at":"2023-11-11T11:27:46.565Z","dependency_job_id":null,"html_url":"https://github.com/kiranparajuli589/htmlmark","commit_stats":null,"previous_names":["kiranparajuli589/markdown-parser","kiranparajuli589/htmlmark"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranparajuli589%2Fhtmlmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranparajuli589%2Fhtmlmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranparajuli589%2Fhtmlmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiranparajuli589%2Fhtmlmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiranparajuli589","download_url":"https://codeload.github.com/kiranparajuli589/htmlmark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948511,"owners_count":21988962,"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":["hacktoberfest","hacktoberfest2023","javascript","lexer","markdown","nodejs","parser"],"created_at":"2025-05-13T13:21:19.140Z","updated_at":"2025-05-13T13:21:19.677Z","avatar_url":"https://github.com/kiranparajuli589.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"display: flex; justify-content: center; flex-direction: column; text-align: center\"\u003e\n\t\u003ch1\u003eHtmlMark\u003c/h1\u003e\n\t\u003cp\u003e\u003cimg src=\"https://github.com/kiranparajuli589/htmlmark/blob/main/demo/src/assets/logo.png?raw=true\" style=\"height: auto; width: 200px;\" alt=\"HtmlMark Logo\"\u003e\u003c/p\u003e\n\t\u003cp\u003eA very lightweight Markdown Parser powered by Regex\u003c/p\u003e\n\u003c/div\u003e\n\n\n## 🔑 Why HtmlMark?\n- no use of external dependencies\n- lexer: to produce markdown tokens\n- parser: to produce the HTML code from the lexer\n- code highlighting support\n- support for front matter\n\n## 🌐 Demo\n\nCheckout the features of the parser from this [Live Demo](https://kiranparajuli589.github.io/htmlmark/ 'Live Demo').\n\n## 🎠 Installation\n\n```bash\nnpm i htmlmark\n```\n\n## 💠 Usage\n\n```js\nimport HtmlMark from 'htmlmark';\n\nconst opts = {\n\tindent: 4,\n\thighlightFn: (code, lang) =\u003e {\n\t\t// return the highlighted code\n\t},\n\tuseLinkRefs: true\n};\n\nconst htmlmark = new HtmlMark(opts);\n\nhtmlmark.tokenize(\"## Hello World\"); // returns the tokens\nhtmlmark.parse(\"## Hello World\"); // returns the HTML code\n```\n\n## 🎡 Options\n\n| Option      | Type       | Default     | Description                                       |\n|-------------|------------|-------------|---------------------------------------------------|\n| indent      | `number`   | `4`         | Number of spaces (or tabs) to use for indentation |\n| tabSize     | `number`   | `4`         | Equivalent spaces for a single tab used           |\n| highlightFn | `function` | `undefined` | Function to highlight the code                    |\n| useLinkRefs | `boolean`  | `true`      | Whether to use link references or not             |\n\n\n## 🎢 APIs\n- `tokenize(markdown: string): Token[]`:\n  Returns the lexer from the markdown string\n- `parse(markdown: string): string`:\n  Returns the HTML code from the markdown string\n- `getFrontMatter(markdown: string): FrontMatter{}`:\n  Returns the front matter from the markdown string\n\n### Lexer\nThe provided markdown string is scanned line by line and checked against various regex patterns to produce the accurate markdown tokens. A general token structure is as:\n\n```json\n{\n\t\"indent\": 0,\n\t\"level\": 1,\n\t\"raw\": \"# Heading One Text\",\n\t\"setext\": false,\n\t\"type\": \"heading\",\n\t\"value\": \"Heading One Text\",\n\t\"tokens\": [{\n\t\t\"raw\": \"Heading One Text\",\n\t\t\"type\": \"text\",\n\t\t\"value\": \"Heading One Text\"\n\t}]\n}\n```\n\n### Front Matter\nThe front matter is the metadata of the markdown file. It is written in the YAML format and is separated from the markdown content by a line containing three hyphens `---`. It must be placed at the top of the markdown file.\n\n#### Example:\n\n```md\n---\ntitle: Hello World\ndate: 2021-01-01\nauthor: John Doe\n---\n\n## Hello World\nLorem ipsum dollar sit amet\n```\n\nThe above markdown file will produce the following front matter:\n\n```json\n{\n\t\"title\": \"Hello World\",\n\t\"date\": \"2021-01-01\",\n\t\"author\": \"John Doe\"\n}\n```\n\n## 💁 Contributing to HtmlMark\nContributions are always welcome, no matter how large or small. Before contributing, please read the [code of conduct](https://github.com/kiranparajuli589/htmlmark/blob/main/CODE_OF_CONDUCT.md 'code of conduct'). You can also find the development guide [here](https://github.com/kiranparajuli589/htmlmark/blob/main/CONTRIBUTING.md 'here').\n\n## 📝 License\nGNU GENERAL PUBLIC LICENSE v3.0 © [Kiran Parajuli](https://kiranparajuli.com.np 'Kiran Parajuli')\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranparajuli589%2Fhtmlmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiranparajuli589%2Fhtmlmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiranparajuli589%2Fhtmlmark/lists"}