Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Htmltomd #596

Merged
merged 3 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Scripts/Miscellaneous/HTML_to_Markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Python script to convert an HTML file into a Markdown file

A simple Python script that uses 'html2text' module to parse a HTML file into
markdown file.

### Prerequisites

You will need to install 'html2text' module.

### How to run the script

First you have to go to the 'HTML_to_Markdown' directory. Run the following
command once you are in project directory

`cd Scripts/Miscellaneous/HTML_to_Markdown`

For Python3: `python3 main.py`

### Screenshot/GIF showing the sample use of the script

![Screenshot](Screenshot.png)

## _Author Name_

Adesh Choudhar

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions Scripts/Miscellaneous/HTML_to_Markdown/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<title>README</title>
</head>
<body>
<h1>Python script to convert an HTML file into a Markdown file</h1>
<p>A simple Python script that uses 'html2text' module to parse a HTML file into markdown file.</p>

<h3>Prerequisites</h3>
<p>You will need to install 'html2text' module.</p>

<h3>How to run the script</h3>
<p>First you have to go to the 'HTML_to_Markdown' directory. Run the following command once you are in project directory</p>

<code>cd Scripts/Miscellaneous/HTML_to_Markdown</code>

<p>For Python3: <code>python3 main.py</code></p>

<h3>Screenshot/GIF showing the sample use of the script</h3>
<img src="Screenshot.png" alt="Screenshot">

<h2><em>Author Name</em></h2>
<p>Adesh Choudhar</p>

</body>
</html>
21 changes: 21 additions & 0 deletions Scripts/Miscellaneous/HTML_to_Markdown/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Importing required libraries/modules
import os
import html2text

# Empty string to add html source to it
html = ""

# Reading index.html file line by line
for line in open("index.html").readlines():
# Adding lines of html file to 'html'
html += line.strip()

# Using 'html2text' function in 'html2text'
markdown = html2text.html2text(html)

# Created the README file for this project using index.html and main.py files

# Opening a new file
with open("README.md", "w") as file:
# Writing into the README.md file
file.write(markdown)
1 change: 1 addition & 0 deletions Scripts/Miscellaneous/HTML_to_Markdown/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html2text==2020.1.16