{"id":27751878,"url":"https://github.com/marcoroth/herb","last_synced_at":"2026-03-27T20:50:52.929Z","repository":{"id":288352365,"uuid":"807228638","full_name":"marcoroth/herb","owner":"marcoroth","description":"🌿 Powerful and seamless HTML-aware ERB parsing and tooling.","archived":false,"fork":false,"pushed_at":"2025-04-20T02:11:44.000Z","size":1829,"stargazers_count":227,"open_issues_count":10,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-24T19:07:36.440Z","etag":null,"topics":["erb","html","parser","ruby"],"latest_commit_sha":null,"homepage":"https://herb-tools.dev","language":"C","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/marcoroth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null},"funding":{"github":"marcoroth"}},"created_at":"2024-05-28T17:44:22.000Z","updated_at":"2025-04-24T17:18:26.000Z","dependencies_parsed_at":"2025-04-17T14:14:44.887Z","dependency_job_id":null,"html_url":"https://github.com/marcoroth/herb","commit_stats":null,"previous_names":["marcoroth/herb"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fherb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fherb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fherb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fherb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoroth","download_url":"https://codeload.github.com/marcoroth/herb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251425692,"owners_count":21587435,"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":["erb","html","parser","ruby"],"created_at":"2025-04-29T03:01:31.001Z","updated_at":"2026-03-27T20:50:52.858Z","avatar_url":"https://github.com/marcoroth.png","language":"C","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"Herb HTML+ERB parser\" height=\"256px\" src=\"https://github.com/user-attachments/assets/d0714ee1-ca33-4aa4-aaa9-d632ba79d54a\"\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eHerb\u003c/h2\u003e\n\n\u003ch4 align=\"center\"\u003eHTML+ERB (HTML + Embedded Ruby)\u003c/h4\u003e\n\n\u003cdiv align=\"center\"\u003ePowerful and seamless HTML-aware ERB parsing and tooling.\u003c/div\u003e\n\n## Contributing\n\nThis project builds the Herb program and its associated unit tests using a Makefile for automation. The Makefile provides several useful commands for compiling, running tests, and cleaning the project.\n\n### Requirements\n\n- [**Check**](https://libcheck.github.io/check/): For unit testing.\n- [**Clang 19**](https://clang.llvm.org): The compiler used to build this project.\n- [**Clang Format 19**](https://clang.llvm.org/docs/ClangFormat.html): For formatting the project.\n- [**Clang Tidy 19**](https://clang.llvm.org/extra/clang-tidy/): For linting the project.\n- [**Prism Ruby Parser v1.4.0**](https://github.com/ruby/prism/releases/tag/v1.4.0): We use Prism for Parsing the Ruby Source Code in the HTML+ERB files.\n- [**Ruby**](https://www.ruby-lang.org/en/): We need Ruby as a dependency for `bundler`.\n- [**Bundler**](https://bundler.io): We are using `bundler` to build [`prism`](https://github.com/ruby/prism) from source so we can build `herb` against it.\n- [**Emscripten**](https://emscripten.org): For the WebAssembly build of `libherb` so it can be used in the browser using the [`@herb-tools/browser`](https://github.com/marcoroth/herb/blob/main/javascript/packages/browser) package.\n- [**Doxygen**](https://www.doxygen.nl): For building the C-Reference documentation pages.\n\n##### For Linux\n\n```bash\nxargs sudo apt-get install \u003c Aptfile\n```\nor:\n\n```bash\nsudo apt-get install check clang-19 clang-tidy-19 clang-format-19 emscripten doxygen\n```\n\n##### For macOS (using Homebrew)\n\n```bash\nbrew bundle\n```\nor:\n\n```bash\nbrew install check llvm@19 emscripten doxygen\n```\n\n### Building\n\n#### Clone the Repo\n\nClone the Git Repository:\n\n```\ngit clone https://github.com/marcoroth/herb \u0026\u0026 cd herb/\n```\n\n#### Build Herb\n\nWe can now compile all source files in `src/` and generate the `herb` executable.\n\n```bash\nmake all\n```\n\n\u003e [!NOTE]\nFor any consecutive builds you can just run `make`/`make all`.\n\n### Run\n\nThe `herb` executable exposes a few commands for interacting with `.html.erb` files:\n\n```\n❯ ./herb\n./herb [command] [options]\n\nHerb 🌿 Powerful and seamless HTML-aware ERB parsing and tooling.\n\n./herb lex [file]      -  Lex a file\n./herb lex_json [file] -  Lex a file and return the result as json.\n./herb parse [file]    -  Parse a file\n./herb ruby [file]     -  Extract Ruby from a file\n./herb html [file]     -  Extract HTML from a file\n./herb prism [file]    -  Extract Ruby from a file and parse the Ruby source with Prism\n```\n\nRunning the executable shows a pretty-printed output for the respective command and the time it took to execute:\n\n```\n❯ ./herb lex examples/simple_erb.html.erb\n\n#\u003cHerb::Token type=\"TOKEN_ERB_START\" value=\"\u003c%\" range=[0, 2] start=(1:0) end=(1:2)\u003e\n#\u003cHerb::Token type=\"TOKEN_ERB_CONTENT\" value=\" title \" range=[2, 9] start=(1:2) end=(1:9)\u003e\n#\u003cHerb::Token type=\"TOKEN_ERB_END\" value=\"%\u003e\" range=[9, 11] start=(1:9) end=(1:11)\u003e\n#\u003cHerb::Token type=\"TOKEN_NEWLINE\" value=\"\\n\" range=[11, 12] start=(1:0) end=(2:1)\u003e\n#\u003cHerb::Token type=\"TOKEN_EOF\" value=\"\" range=[12, 12] start=(2:1) end=(2:1)\u003e\n\nFinished lexing in:\n\n        12 µs\n     0.012 ms\n  0.000012  s\n```\n\n### Building the Ruby extension\n\nWe use `rake` and `rake-compiler` to compile the Ruby extension. Running rake will generate the needed templates, run make, build the needed artifacts, and run the Ruby tests.\n\n```bash\nrake\n```\n\nIf `rake` was successful you can use `bundle console` to interact with `Herb`:\n\n```bash\nbundle console\n```\n\n```\nirb(main):001\u003e Herb.parse(\"\u003cdiv\u003e\u003c/div\u003e\")\n\n# =\u003e #\u003cHerb::ParseResult:0x0000000 ... \u003e\n```\n\n### Test\n\nBuilds the test suite from files in `test/` and creates the `run_herb_tests` executable to run the tests:\n\n#### For the C Tests\n\n```bash\nmake test \u0026\u0026 ./run_herb_tests\n```\n\n#### For the Ruby Tests\n\n```bash\nrake test\n```\n\n### Clean\n\nRemoves the `herb`, `run_herb_tests`, `prism` installation, and all `.o` files.\n\n```bash\nmake clean\n```\n\n### Local Integration Testing\n\nThe `bin/integration` script allows for quick local iteration. On every run it cleans the directory, builds the source from scratch and runs all checks, including the C-Tests, Ruby Tests, Linters, and examples in succession.\n\n```bash\nbin/integration\n```\n\nThe integration was successful if you see:\n\n```\n❯ bin/integration\n\n[...]\n\nIntegration successful!\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE.txt) file for details.\n","funding_links":["https://github.com/sponsors/marcoroth"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fherb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoroth%2Fherb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fherb/lists"}