Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Commit ad49949

Browse files
HTML to Text
1 parent 0053379 commit ad49949

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Python script to convert an HTML file into a Markdown file
2+
3+
A simple Python script that uses 'html2text' module to parse a HTML file into
4+
markdown file.
5+
6+
### Prerequisites
7+
8+
You will need to install 'html2text' module.
9+
10+
### How to run the script
11+
12+
First you have to go to the 'HTML_to_Markdown' directory. Run the following
13+
command once you are in project directory
14+
15+
`cd Scripts/Miscellaneous/HTML_to_Markdown`
16+
17+
For Python3: `python3 main.py`
18+
19+
### Screenshot/GIF showing the sample use of the script
20+
21+
![Screenshot](Screenshot.png)
22+
23+
## _Author Name_
24+
25+
Adesh Choudhar
26+
246 KB
Loading[フレーム]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>README</title>
5+
</head>
6+
<body>
7+
<h1>Python script to convert an HTML file into a Markdown file</h1>
8+
<p>A simple Python script that uses 'html2text' module to parse a HTML file into markdown file.</p>
9+
10+
<h3>Prerequisites</h3>
11+
<p>You will need to install 'html2text' module.</p>
12+
13+
<h3>How to run the script</h3>
14+
<p>First you have to go to the 'HTML_to_Markdown' directory. Run the following command once you are in project directory</p>
15+
16+
<code>cd Scripts/Miscellaneous/HTML_to_Markdown</code>
17+
18+
<p>For Python3: <code>python3 main.py</code></p>
19+
20+
<h3>Screenshot/GIF showing the sample use of the script</h3>
21+
<img src="Screenshot.png" alt="Screenshot">
22+
23+
<h2><em>Author Name</em></h2>
24+
<p>Adesh Choudhar</p>
25+
26+
</body>
27+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Importing required libraries/modules
2+
import os
3+
import html2text
4+
5+
# Empty string to add html source to it
6+
html = ""
7+
8+
# Reading index.html file line by line
9+
for line in open("index.html").readlines():
10+
# Adding lines of html file to 'html'
11+
html += line.strip()
12+
13+
# Using 'html2text' function in 'html2text'
14+
markdown = html2text.html2text(html)
15+
16+
# Created the README file for this project using index.html and main.py files
17+
18+
# Opening a new file
19+
file = open("README.md", "w")
20+
21+
# Writing into the README.md file
22+
file.write(markdown)
23+
24+
# Closing the file
25+
file.close()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
html2text==2020年1月16日

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /