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

Commit 06c95fe

Browse files
Merge pull request avinashkranjan#1121 from Ayushjain2205/markdown-viewer
Markdown viewer
2 parents b2d2592 + f39f426 commit 06c95fe

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

‎Markdown-viewer/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Markdown viewer
2+
Running this Script opens up a markdown viewer where the user can write markdown files (readme files) and see the preview on a button click.
3+
4+
## Setup instructions
5+
In order to run this script, you need to have Python and pip installed on your system. After you're done installing Python and pip, run the following command from your terminal to install the requirements from the same folder (directory) of the project.
6+
```
7+
pip install -r requirements.txt
8+
```
9+
After satisfying all the requirements for the project, Open the terminal in the project folder and run
10+
```
11+
python viewer.py
12+
```
13+
or
14+
```
15+
python3 viewer.py
16+
```
17+
depending upon the python version. Make sure that you are running the command from the same virtual environment in which the required modules are installed.
18+
19+
## Output
20+
21+
The user can enter the markdown data and see the preview as shown in the sample screenshot below
22+
23+
![Markdown Viewer](https://i.postimg.cc/v8jzWNng/markdown-Viewer.png)
24+
25+
## Author
26+
[Ayush Jain](https://github.com/Ayushjain2205)

‎Markdown-viewer/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
markdown2
2+
tkhtmlview

‎Markdown-viewer/viewer.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# import tkinter as tk
2+
from tkinter import *
3+
from tkinter import font
4+
from tkinter.ttk import *
5+
from markdown2 import Markdown
6+
from tkhtmlview import HTMLLabel
7+
8+
# Function to display markdown on button click
9+
def onKeyUp():
10+
markdown = Markdown()
11+
markdownText = markdown_editor.get("1.0", END)
12+
html = markdown.convert(markdownText)
13+
result.set_html(html)
14+
15+
16+
# Creating tkinter window
17+
window = Tk()
18+
window.title('Markdown viewer')
19+
window.geometry('1200x1000')
20+
window.configure(bg='white')
21+
22+
# Styling font and button
23+
myfont = font.Font(family="Helvetica", size=14)
24+
style = Style()
25+
style.configure('TButton', font=('calibri', 20, 'bold'),
26+
foreground='Blue')
27+
28+
# Placing widgets into Tkinter window
29+
submit_btn = Button(text="View Markdown", command=onKeyUp, style='TButton')
30+
submit_btn.pack(ipadx=30, ipady=6)
31+
32+
markdown_editor = Text(width="1", insertborderwidth=2,
33+
selectborderwidth=2)
34+
markdown_editor.insert(END, '# Add Markdown here')
35+
markdown_editor.pack(fill=BOTH, expand=1, side=LEFT, padx=10, pady=10)
36+
markdown_editor.configure(font=myfont)
37+
38+
result = HTMLLabel(width="1", html="<h1>Markdown Viewer</h1>")
39+
result.pack(fill=BOTH, expand=1, side=RIGHT, padx=10, pady=10)
40+
41+
42+
window.mainloop()

0 commit comments

Comments
(0)

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