Skip to content

Commit ac96f3c

Browse files
Merge pull request prathimacode-hub#578 from tanvi355/issue#548
HTML to markdown
2 parents 2850e6f + c3f99a6 commit ac96f3c

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed
Loading
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Script Name
2+
3+
HTML to Markdown
4+
5+
## Short description of script
6+
7+
This script can be used to convert any file with HTML code into markdown(.md) format.
8+
9+
## Setup instructions
10+
11+
- Install the required packages by running the command `pip install -r requirements.txt`
12+
- Download the script.
13+
- To run the script use the command `python html_to_markdown.py`
14+
- Enter the path of HTML i.e. the location where it is present on your local machine.
15+
- The script will create a markdown file named `markdown_file.md` in the location where the script was present.
16+
17+
18+
## Input and Output
19+
20+
- Sample HTML file
21+
22+
![Input](Images/sample%20html%20file.png)
23+
24+
- Output markdown file
25+
26+
![Output](Images/output.png)
27+
28+
## Author(s)
29+
30+
[Tanvi Bugdani](https://github.com/tanvi355)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#import markdownify
2+
import markdownify
3+
4+
#taking html file as input
5+
try:
6+
html_file = input('Enter HTML file path: ')
7+
html = open(html_file, "r")
8+
except:
9+
print('No file selected')
10+
11+
#creating a new markdown file
12+
with open('markdown_file.md', 'w') as md_file:
13+
#convert html code to markdown format
14+
for data in html:
15+
md_file.write(markdownify.markdownify(data))
16+
md_file.write("\n")
17+
md_file.close()
18+
19+
print('Conversion successfull')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
markdownify==0.9.0

0 commit comments

Comments
 (0)