Skip to content

Commit

Permalink
Release v3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonZhang2024 committed Jun 24, 2024
1 parent 7d875e6 commit 90ddafd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 140 deletions.
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# ![logo](https://gordonzhang.pythonanywhere.com/static/tkMarker.png) tkMarker

A light weight Markdown editor


A light weight text editor

[![Static Badge](https://img.shields.io/badge/Download%20-%20tkMarker?style=for-the-badge&logo=github&labelColor=black&color=blue&link=https%3A%2F%2Fgit.luolix.top%2FGordonZhang2024%2FtkMarker%2Freleases)](https://github.com/GordonZhang2024/tkMarker/releases)

Expand All @@ -11,16 +9,7 @@ A light weight Markdown editor
![GitHub Repo stars](https://img.shields.io/github/stars/GordonZhang2024/tkMarker)
![GitHub watchers](https://img.shields.io/github/watchers/GordonZhang2024/tkMarker)

[website](https://gordonzhang.pythonanywhere.com/projects/tkMarker/)

## 🚀 Features
- [x] Markdown preview
- [x] Basic markdown syntax support
- [x] GitHub flavored Markdown support (beta)
- [x] Auto refresh
- [x] **It's really fast!**
- [ ] Code highlight
- [ ] Auto complete

![screenshot](https://github.com/GordonZhang2024/tkMarker/assets/159539185/0b343372-8f77-446c-a11c-4b3ced5d31ed)

Expand Down Expand Up @@ -64,7 +53,6 @@ $ tkmarker &
```
You will see the editor.

*Click the <keyboard>Preview</keyboard> Button, then the editor will open the preview in the web browser.*

## License
MIT License
Expand Down
38 changes: 0 additions & 38 deletions src/converter.py

This file was deleted.

55 changes: 2 additions & 53 deletions src/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
"""
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
import webbrowser
import os
from tkinter import filedialog
import uuid

from converter import convert
import get_help

"""
tkMarker
A Markdown editor using tkinter
A light-weight text editor
Copyright (C) 2024 Gordon Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -41,52 +39,13 @@
"""

# Availible filetypes for the file selection window
filetypes = [('Markdown', '*.md'), ("All Files", "*.*")]
filetypes = [('Text', '*.txt'), ("All Files", "*.*")]


def show_project_info():
get_help.show_project_info()


def load_preview():
# Load the preview
markdown_text_for_preview = text.get('1.0', 'end') # Get the text

# Use uuid as the name of the preview file
preview_file = f'{home}/.tkmarker/{file_uuid}'

# Convert the Markdown document to HTML and write to the preview file
html = convert(
markdown_text_for_preview, preview=True, file_path=os.path.split(filename)
)
with open(preview_file, 'w+', encoding='utf-8') as p:
p.write(html)

# Open the preview file in the webbrowser
webbrowser.open_new(preview_file)


def refresh_preview(arg):
# Refresh the preview
markdown_text_for_preview = text.get('1.0', 'end')
preview_file = f'{home}/.tkmarker/{file_uuid}'
html = convert(
markdown_text_for_preview, preview=True, file_path=os.path.split(filename)
)

with open(preview_file, 'w', encoding='utf-8') as p:
p.write(html)


def convert_to_html():
# Convert Markdown document to HTML
markdown_text = text.get('1.0', 'end')
output_file = filedialog.asksaveasfilename(filetypes=[('HTML', '*.html')])
html = convert(markdown_text)
with open(output_file, 'w', encoding='utf-8') as o_file:
o_file.write(html)


def show_popup_menu(event):
# Show the popup menu
edit.post(event.x_root, event.y_root)
Expand Down Expand Up @@ -163,9 +122,6 @@ def new_file():
help_menu = ttk.Menu(editor, tearoff=0)
menubar.add_cascade(label='Help', menu=help_menu)

# Add the 'Preview' button
menubar.add_command(label='Preview', command=load_preview)

# Add the text area
global text
text = ttk.ScrolledText(editor, undo=True, font=('Sans Mono', 15))
Expand All @@ -178,7 +134,6 @@ def new_file():
file.add_command(label='Open...', command=open_file)
file.add_command(label='Save', command=save)
file.add_separator()
file.add_command(label='Convert to HTML', command=convert_to_html)

# Add the "edit" menu
edit.add_command(label='Paste', command=paste)
Expand All @@ -198,12 +153,8 @@ def new_file():
editor.bind('<Control-C>', copy)
editor.bind('<Control-V>', paste)
editor.bind('<Control-S>', save)
editor.bind('<Control-P>', load_preview)
editor.bind('<F1>', show_project_info)
editor.bind('<F5>', load_preview)

# Refresh Automatically
editor.bind('<KeyRelease>', refresh_preview)

editor.mainloop()

Expand All @@ -212,8 +163,6 @@ def new_file():
# Init
# This is the starting point of everything. :)
home = os.path.expanduser('~')
global file_uuid
file_uuid = uuid.uuid1()

# Start the editor
new_file()
34 changes: 0 additions & 34 deletions src/error_generator.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/get_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

"""
tkMarker
A Markdown editor using tkinter
A light-weight text editor
Copyright (C) 2024 Gordon Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -53,7 +53,7 @@ def show_project_info():

description = ttk.Label(
info_page,
text='A Markdown editor using tkinter',
text='A light-weight text editor',
)
description.pack(pady=5)

Expand Down

0 comments on commit 90ddafd

Please sign in to comment.