{"id":25983975,"url":"https://github.com/pankaj28843/html2latex","last_synced_at":"2026-03-06T20:03:33.547Z","repository":{"id":18258182,"uuid":"21415175","full_name":"pankaj28843/html2latex","owner":"pankaj28843","description":"Convert WYSIWYG HTML to LaTeX with typed ASTs, full table support, and 100% test coverage","archived":false,"fork":false,"pushed_at":"2026-02-20T14:10:49.000Z","size":1661,"stargazers_count":17,"open_issues_count":8,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-20T15:51:25.453Z","etag":null,"topics":["ast","converter","document-conversion","html","html-to-latex","latex","pdf-generation","python","typesafe","wysiwyg"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/pankaj28843.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2014-07-02T07:25:27.000Z","updated_at":"2026-02-20T14:09:49.000Z","dependencies_parsed_at":"2025-03-05T10:43:11.344Z","dependency_job_id":"1eed67db-8032-47a3-b1af-7df1d6f03dc7","html_url":"https://github.com/pankaj28843/html2latex","commit_stats":null,"previous_names":["psjinx/html2latex"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/pankaj28843/html2latex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pankaj28843%2Fhtml2latex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pankaj28843%2Fhtml2latex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pankaj28843%2Fhtml2latex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pankaj28843%2Fhtml2latex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pankaj28843","download_url":"https://codeload.github.com/pankaj28843/html2latex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pankaj28843%2Fhtml2latex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30195570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ast","converter","document-conversion","html","html-to-latex","latex","pdf-generation","python","typesafe","wysiwyg"],"created_at":"2025-03-05T10:43:06.589Z","updated_at":"2026-03-06T20:03:33.530Z","avatar_url":"https://github.com/pankaj28843.png","language":"Python","readme":"# HTML2LaTeX\n\n![CI](https://github.com/pankaj28843/html2latex/actions/workflows/ci.yml/badge.svg)\n\nHTML2LaTeX converts WYSIWYG HTML fragments into LaTeX. The pipeline is built on\n`justhtml`, typed ASTs, and deterministic serialization to produce reliable\noutput suitable for PDFs and reports.\n\n## Highlights\n\n- **Block elements**: headings (`h1`-`h5`), paragraphs, divs, lists (`ul`/`ol`/`dl`),\n  blockquotes, `pre` blocks, `hr`, `figure`/`figcaption`, and semantic containers.\n- **Tables**: Full support including `thead`/`tbody`/`tfoot`, `th`/`td`, `colspan`,\n  `rowspan` (via `\\multirow`), cell alignment (via `align` attribute or CSS `text-align`),\n  and `caption`.\n- **Inline formatting**: bold, italic, underline, code, superscript, subscript,\n  strikethrough (`del`/`s`/`strike`), highlighted text (`mark`), font sizes (`small`/`big`),\n  inline quotes (`q` with proper nesting), and semantic tags (`kbd`, `samp`, `var`, `cite`, `ins`).\n- **Links and images**: `\\href`/`\\url` for links, `\\includegraphics` for images with\n  `width`/`height` attribute support.\n- **Math passthrough**: via `\u003cspan class=\"math-tex\"\u003e`, `data-latex`, or `data-math` attributes.\n- **Text alignment**: `text-align` CSS on `p`/`div` maps to `center`/`flushleft`/`flushright`.\n- **Thread-safe**: Immutable options with diagnostics for invalid input.\n\n## Requirements\n\n- Python 3.10+\n- Dependencies managed with `uv` via `pyproject.toml`\n\n## Quick Start\n\n```bash\nuv sync\n```\n\n```bash\nuv run python - \u003c\u003c'PY'\nfrom html2latex import html2latex\n\nprint(html2latex(\"\u003cp\u003eHello World\u003c/p\u003e\"))\nPY\n```\n\nExpected output (fragment):\n\n```\nHello World\\par\n```\n\n## Usage\n\n### Convert HTML to a LaTeX fragment\n\n```python\nfrom html2latex import html2latex\n\nhtml = \"\"\"\n\u003cp\u003eHello \u003cstrong\u003eWorld\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eInline math: \u003cspan class=\"math-tex\"\u003e\\( x^2 + y^2 = z^2 \\)\u003c/span\u003e\u003c/p\u003e\n\"\"\"\n\nfragment = html2latex(html)\nprint(fragment)\n```\n\n### Convert HTML and inspect packages/diagnostics\n\n```python\nfrom html2latex import Converter, ConvertOptions\n\nconverter = Converter(ConvertOptions(strict=False))\nresult = converter.convert(\"\u003ca href='https://example.com'\u003eLink\u003c/a\u003e\")\n\nprint(result.body)       # LaTeX fragment\nprint(result.packages)   # e.g., (\"hyperref\",)\nprint(result.diagnostics)\n```\n\n### Render a full LaTeX document\n\n```python\nfrom html2latex import render\n\nprint(render(\"\u003cp\u003eFull document\u003c/p\u003e\"))\n```\n\nTo add preamble content:\n\n```python\nfrom html2latex import render, ConvertOptions\n\noptions = ConvertOptions(metadata={\"preamble\": \"\\\\usepackage{amsmath}\"})\nprint(render(\"\u003cp\u003eMath\u003c/p\u003e\", options=options))\n```\n\n## LaTeX Packages\n\nPackage requirements are inferred from the output. If you need a full document,\nuse `render()` or `render_document()` and include `result.preamble`.\n\nCommon packages:\n\n- `hyperref` (links)\n- `graphicx` (images)\n- `xcolor` (highlighted text via `mark`)\n- `ulem` (strikethrough via `del`/`s`/`strike`)\n- `multirow` (table cells spanning multiple rows)\n\n## Demo App\n\nA demo Flask app with a rich text editor is available:\n\n```bash\ndocker compose build\ndocker compose up\n```\n\nVisit \u003chttp://127.0.0.1:15005/\u003e.\n\n## History\n\nThe original implementation (2014-2016) powered the ClassKlap publishing\nworkflow. This version targets Python 3.10+ and general-purpose use.\n\n## CI\n\nCI runs `ruff` (lint + format) and `pytest` (465 tests, 100% coverage) across\nPython 3.10-3.14, plus LaTeX validity checks (Tectonic) and Playwright E2E\nsmoke tests.\n\n## License\n\nMIT License - see [LICENSE](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpankaj28843%2Fhtml2latex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpankaj28843%2Fhtml2latex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpankaj28843%2Fhtml2latex/lists"}