An open API service indexing awesome lists of open source software.

https://github.com/mhackfly/markdown2html

markdown2html is a Python script that converts a Markdown file to HTML, transforms <h3> tags into <a href> tags to create an index, and identifies special tags to highlight code.
https://github.com/mhackfly/markdown2html

convert html-css markdown markdown2html pygmentize pygments python

Last synced: 5 months ago
JSON representation

markdown2html is a Python script that converts a Markdown file to HTML, transforms <h3> tags into <a href> tags to create an index, and identifies special tags to highlight code.

Awesome Lists containing this project

README

          

## markdown2html

**Description**

`markdown2html.py` is a Python script that converts a Markdown file to HTML. It performs the following tasks:

1. It transforms `

` tags into `` tags, creating sections with unique identifiers.
2. These anchors are added to a `sections.html` file.
3. In the `index` file, you can add links to other files by inserting a hyphen (`-`)
before the file name (e.g., `[-my PDF](document.pdf)`).
4. The script identifies special code blocks delimited by ``.
These blocks define code display areas with attributes and highlight the code using Pygments,
a syntax highlighting tool.
5. It creates the HTML file by integrating the `markdown2html.css` and `markdown.css` files.
6. `markdown2html.css` defines the style for the HTML page, while `markdown.css` styles the Markdown file.

**Usage**

1. Create a directory with the files `markdown2html.py`, `markdown2html.css`, and `markdown.css`.
2. Execute the Python script with your Markdown file:
```
python3 markdown2html.py my_file.md
```
3. A directory named `my_file` will be created, containing three files:
- `article.html`: the main HTML file.
- `article.md`: a copy of the Markdown file.
- `sections.html`: an index of links created using `###` and `[-...]()` tags.

**Dependency**

- Pygments: Download and install it or use `pip install Pygments`.
Example usage: `pygmentize -S paraiso-dark -f html -a .codehilite`

**Program Tags**

- Attributes must be placed between ``.
- The first series of attributes (`number-...`) customizes line numbers.
- The `box-...` series relates to the box and code appearance.
- The last attributes in the list (`language` and `theme`) correspond to Pygments options.
- In the "tags" section, when specifying the `code` attribute, you can provide either an
existing file name or if you want to write the code directly, you can do so as follows:

```

```

With the existing file:

```

```

**Examples**

[micro66](https://www.micro66.fr/github/markdown2html/example/article.html)

```

```

In the "Examples" section, many attributes are listed without values.
These attributes are optional and are used to customize the appearance of the code block.
If an attribute is not specified, the program will use default values.
You can experiment with different values to achieve the desired look for your code block.

Feel free to experiment with different values for your code block appearance! 😊