# Latex to HTML [![JavaScript][javascript-badge]][javascript-lang] [![HTML][html-badge]](#) [![GitHub][github-badge]][repo] [![pnpm][pnpm-badge]][pnpm] [![Coffee][buy-me-coffee]][coffee] [![License: MIT][license-badge]][license] [![No AI][noai-badge]](#) HTML-Processor is a JavaScript package which manipulates HTML using the [rehype][rehype] library and plugins. The package provides a default function `processHTML()`, which reads HTML from a string and parses it into a Hast tree (HTML) used by [rehype][rehype]. After the tree has been processed, [rehype-stringify][rehype-stringify] then returns a modified HTML string. The package uses the following Rehype plugins: - [rehype-parse][rehype-parse] to parse the input HTML string to a Hast tree - [rehype-highlight][rehype-highlight] to highlight code - [rehype-remove-empty-attribute][rehype-remove-empty-attribute] - [rehype-unwrap-images][rehype-unwrap-images] to remove unnecessary `
` parent tags from images
- [rehype-stringify][rehype-stringify] to convert the Hast tree back to a string
In addition the following (manual) methods are also used:
- `fixUrls` prepends the input `rootUrl` to relative URLs in links
- `probeImageSizes` to determine the size for images
- `checkListDepth` to determine the depth of a given list (for bullet type)
- `inlineCodeBlocks` checks whether a `
Some paragraph with
a random inline link,
to test.
List of TODOs
Example code
Some paragraph with
a random inline link,
to test.
List of TODOs
Example code ` tag is inline or inside a `` tag
- `inlineLinks` checks whether a link is inline (text only)
- `cleanEmptyTags` removes empty text tags
- `tableHeaders` tags `` elements as being inside a `` or not
Consider the following HTML:
```html
Title
Some code
def functionToSolveEverything():
# TODO: implement
pass
print("Hello World!") can appear anywhere, like
image links:
Title
Some code
def functionToSolveEverything():
# TODO: implement
pass
print("Hello World!") can appear
anywhere, like image links: