{"id":15664806,"url":"https://github.com/jdalrymple/html-to-latex","last_synced_at":"2025-05-06T19:29:32.716Z","repository":{"id":119015778,"uuid":"250849416","full_name":"jdalrymple/html-to-latex","owner":"jdalrymple","description":"Basic script to convert HTML source into Latex","archived":false,"fork":false,"pushed_at":"2024-03-11T18:11:28.000Z","size":716,"stargazers_count":19,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T02:11:53.706Z","etag":null,"topics":["cli","conversion","html","latex","nodejs"],"latest_commit_sha":null,"homepage":"","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/jdalrymple.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}},"created_at":"2020-03-28T17:04:24.000Z","updated_at":"2024-10-09T21:48:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ebbd9c5-a666-4965-b924-4a3c3358fda1","html_url":"https://github.com/jdalrymple/html-to-latex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fhtml-to-latex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fhtml-to-latex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fhtml-to-latex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdalrymple%2Fhtml-to-latex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdalrymple","download_url":"https://codeload.github.com/jdalrymple/html-to-latex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252752801,"owners_count":21798856,"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":["cli","conversion","html","latex","nodejs"],"created_at":"2024-10-03T13:44:12.267Z","updated_at":"2025-05-06T19:29:32.697Z","avatar_url":"https://github.com/jdalrymple.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"border-bottom: none;\"\u003eHTML-to-Latex\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003eBasic script to convert HTML source into Latex\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://travis-ci.com/jdalrymple/html-to-latex\"\u003e\n    \u003cimg src=\"https://travis-ci.com/jdalrymple/html-to-latex.svg?branch=master\" alt=\"Travis Pipeline Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codeclimate.com/github/jdalrymple/html-to-latex\"\u003e\n    \u003cimg src=\"https://codeclimate.com/github/jdalrymple/html-to-latex/badges/gpa.svg\" alt=\"Code Climate maintainability\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/jdalrymple/html-to-latex\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/jdalrymple/html-to-latex/master.svg\" alt=\"CodeCov test coverage\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/jdalrymple/html-to-latex\"\u003e\n    \u003cimg src=\"https://david-dm.org/jdalrymple/html-to-latex/status.svg\" alt=\"Dependency Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/jdalrymple/html-to-latex?type=dev\"\u003e\n    \u003cimg src=\"https://david-dm.org/jdalrymple/html-to-latex/dev-status.svg.svg\" alt=\"Dev Dependency Status\" /\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://flat.badgen.net/dependabot/jdalrymple/html-to-latex?icon=dependabot\" alt=\"Dependabot Badge\" /\u003e\n  \u003ca href=\"http://commitizen.github.io/cz-cli/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\" alt=\"Commitizen\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/code%20style-prettier-ff69b4.svg\" alt=\"Prettier\"\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=html-to-latex\"\u003e\n    \u003cimg src=\"https://packagephobia.now.sh/badge?p=html-to-latex\" alt=\"Install Size\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"LICENSE.md\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"Licence: MIT\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n**[IN DEVELOPMENT]**\n\n## Install\n\n```bash\n$ npm install html-to-latex\n```\n\n## Usage\n\nConverting html text:\n```javascript\nimport { convertText } from 'html-to-latex';\n\nconst html = `\u003cp\u003eStyled \u003cb\u003eText\u003c/b\u003e\u003c/p\u003e`;\nconst tex = await convertText(html);\n\nconsole.log(tex)\n//\\documentclass{article}\n//\n//\\begin{document}\n//\n//Styled \\textbf{Text}\n//\n//\\end{document}\n```\n\nConverting html file:\n```javascript\nimport { convertFile } from 'html-to-latex';\n\nconst html = 'filePath.html';\n\nawait convertFile(html);\n```\n\n### API\n\n#### convertText(htmlText, options?)\n\nReturns: `Promise\u003cstring\u003e`\n\nConverts the input htmlText to a valid latex string. \n\n##### htmlString\n\nType: `string`\n\n##### options\n\nType: `object`\n\n###### ignoreBreaks\n\nType: `boolean`\nDefault: `true`\nCLI Options: `-ib` or `--ignore-breaks`\n\nInstead of replacing `\u003cbr/\u003e`  with //, ending the line, a simple space character is inserted instead.\n\n###### preferDollarInlineMath\n\nType: `boolean`\nDefault: `false`\nCLI Options: `-dm` or `--prefer-dollar-inline-math`\n\nReplace `\\(` and `\\)`  with `$`.\n\n###### skipWrappingEquations\n\nType: `boolean`\nDefault: `false`\nCLI Options: `-swe` or  `--skip-wrapping-equations`\n\nIs an equation is defined in a `p` tag without any other content besides that equation, it will automatically be wrapped in `\\[` and `\\]`.\n\n###### includeDocumentWrapper\n\nType: `boolean`\nDefault: `false`\nCLI Options: `-dw` or  `--include-document-wrapper`\n\nAdds a latex document wrapper around the converted text. This is required to have a valid latex file:\n\n```latex\n\\documentclass{article}\n\n\\begin{document}\n%...converted text\n\\end{document}\n```\n\n###### documentClass\n\nType: `string`\nDefault: `article`\nCLI Options: `-dc` or  `--document-class`\n\nIf a document wrapper is added, the document class will be set.\n\n```latex\n\\documentclass{article}\n%...\n```\n\n###### includePackages\n\nType: `string[]`\nDefault: `[]`*\nCLI Options: `-ip` or  `--include-packages`\n\nIf the document wrapper is added, a list of used packages will be set.\n\n```latex\n\\documentclass{article}\n\n\\usepackage{packagename}\n\n\\begin{document}\n%...converted text\n\\end{document}\n```\n\n\\*If nothing is specified, the list of includes packages will be inferred from the html:\n\n\n| Tag    | Added Package |\n|--------|---------------|\n| \\cfrac | amsmath       |\n| \\img   | graphicx      |\n| \\therefore | amssymb   |\n\n###### title\n\nType: `string`\nDefault: `undefined`\nCLI Options: `-t` or  `--title`\n\nIf a document wrapper is added, the title will be set.\n\n```latex\n\\documentclass{article}\n\n\\title{Altered Carbon}\n\n\\begin{document}\n%...converted text\n\\end{document}\n```\n\n###### author\n\nType: `string`\nDefault: `undefined`\nCLI Options: `-a` or  `--author`\n\nIf a document wrapper is added, the author will be set.\n\n```latex\n\\documentclass{article}\n\n\\author{Takashi Kovacs}\n\n\\begin{document}\n%...converted text\n\\end{document}\n```\n\n###### includeDate\n\nType: `boolean`\nDefault: `false`\nCLI Options: `-d` or  `--incude-date`\n\nIf a document wrapper is added, the current date will be set.\n\n```latex\n\\documentclass{article}\n\n\\date{\\today}\n\n\\begin{document}\n%...converted text\n\\end{document}\n```\n\n###### compilationDir\n\nType: `string`\nDefault: `process.cwd`\nCLI Options: `-cdr` or `--compilation-dir`\n\nIf any images need to be downloaded for the latex compilation, they will be places in a 'images' subdirectory inside this directory.\n\n###### autoGenImageNames\n\nType: `boolean`\nDefault: `true`\nCLI Options: `-ain` or `--autogen-image-names`\n\nTo avoid any weird file names, image files that are downloaded are automatically given a random Id with the extension of the original file. This can be turned off by passing a `false` value.\n\n###### imageWidth\n\nType: `string`\nDefault: `undefined`\nCLI Options: `-iw` or `--image-width`\n\nAllows you to set a image width. This would be in the form normally accepted by latex such as: `2cm`\n\n###### imageHeight\n\nType: `string`\nDefault: `undefined`\nCLI Options: `-ih` or `--image-height`\n\nAllows you to set a image height. This would be in the form normally accepted by latex such as: `2cm`\n\n###### keepImageAspectRatio\n\nType: `boolean`\nDefault: `undefined`\nCLI Options: `-kar` or `--keep-aspect-ratio`\n\nAllows you to maintain the aspect ratio of the image. This also requires either the image width property or image height property to be set.\n\n###### debug\n\nType: `boolean`\nDefault: `false`\nCLI Options: `--debug`\n\nPrints error messages when they occur such as when an image cannot be found at the given url.\n\n\n#### convertFile(filepath, options?)\nCLI: `available` (see options for cli option names)\nReturns: `Promise`\n\nConverts the input file to a valid latex file. \n\n##### filepath\n\nType: `string`\nCLI Option: Positional, or `-ifp`\n\nPath of html file\n\n##### options\n\nType: `object`\n\nAll options included in .... and\n\n*includeDocumentWrapper option is defaulted to true for this function, as it would make more sense to do so*\n\n##### outputFilepath\n\nType: `string`\nDefault: `filepath` (The input file path)\nCLI Option: `-ofp` or `--output-file-path`\n\nThe output filepath of the converted file. By default it will overwrite the input file.\n\n### CLI API\nThe same arguments are valid for the cli. The cli is exposed under html-to-latex executable and has the functions: `convert-file` and `convert-text`. Run `html-to-latex --help` for more information.\n\n## Improving output\n### Ignoring br tags\nInstead designate new sections/paragraphs using the proper html tag such as a `\u003cp\u003e`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdalrymple%2Fhtml-to-latex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdalrymple%2Fhtml-to-latex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdalrymple%2Fhtml-to-latex/lists"}