Skip to content

Commit 0548100

Browse files
committed
Update docstring with removed comments.
1 parent d2f8e40 commit 0548100

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

tkintermd/tkintermd_frame.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def __init__(self, master, **kwargs):
6363
self.bold_btn.pack(side="left", padx=0, pady=0)
6464
self.italic_btn = tk.Button(self.top_bar, text="Italic", command=lambda: self.check_bold_italic(constants.italic_md_syntax, constants.italic_md_ignore, constants.italic_md_special))
6565
self.italic_btn.pack(side="left", padx=0, pady=0)
66-
# # Currently has issues, needs constants adjusting.
6766
self.bold_italic_btn = tk.Button(self.top_bar, text="Bold Italic", command=lambda: self.check_bold_italic(constants.bold_italic_md_syntax, constants.bold_italic_md_ignore, constants.bold_italic_md_special))
6867
self.bold_italic_btn.pack(side="left", padx=0, pady=0)
6968
# self.heading_btn = tk.Button(self.top_bar, text="Heading")
@@ -353,6 +352,7 @@ def apply_markdown_both_sides(self, selection, md_syntax):
353352
"""Apply markdown to both sides of a selection.
354353
355354
Args:
355+
selection (str): Text selection from the editor.
356356
md_syntax (tuple): Tuple of markdown strings to apply.
357357
"""
358358
self.md_syntax = md_syntax
@@ -366,6 +366,7 @@ def remove_markdown_both_sides(self, selection, md_syntax):
366366
"""Remove markdown from both sides of a selection.
367367
368368
Args:
369+
selection (str): Text selection from the editor.
369370
md_syntax (tuple): Tuple of markdown strings to remove.
370371
"""
371372
self.md_syntax = md_syntax
@@ -376,20 +377,34 @@ def remove_markdown_both_sides(self, selection, md_syntax):
376377
return
377378

378379
def check_bold_italic(self, md_syntax, md_ignore, md_special):
380+
"""Specific checks for bold, italic and bold-italic markdown syntax.
381+
382+
This will ignore items in the md_ignore variable and then deal with
383+
special syntax individually before applying or removing the markdown
384+
formatting.
385+
386+
- If string starts with anything in md_ignore do
387+
nothing and return from the function.
388+
- If the formatting requires special items which can't go in md_ignore
389+
because they cause issues with markdown being applied incorrectly do
390+
nothing and return from the function.
391+
- Apply or remove the markdown once we reach the end.
392+
393+
Args:
394+
selection (str): Text selection from the editor.
395+
md_syntax (tuple): Tuple of markdown strings to remove.
396+
md_ignore (tuple): Tuple of markdown strings to ignore.
397+
md_special (tuple): Tuple of special markdown strings to ignore that
398+
cause unexpected issues when included in md_ignore.
399+
"""
379400
self.md_syntax = md_syntax
380401
self.md_ignore = md_ignore
381402
self.md_special = md_special
382403
self.cur_selection = self.text_area.selection_get()
383-
# Ignore items in the md_ignore variable and then deal with special
384-
# syntax individually. If string starts with anything in md_ignore do
385-
# nothing and return from the function.
386404
if str(self.cur_selection).startswith(self.md_ignore) or str(self.cur_selection).endswith(self.md_ignore):
387405
return
388-
# If the formatting requires special items which can't go in md_ignore
389-
# because they cause issues with markdown being applied incorrectly.
390406
elif str(self.cur_selection).startswith(self.md_special) and str(self.cur_selection).endswith(self.md_special) and not str(self.cur_selection).startswith(self.md_syntax) and not str(self.cur_selection).startswith(self.md_syntax):
391-
return
392-
# Apply or remove the markdown once we reach this stage.
407+
return
393408
elif str(self.cur_selection).startswith(self.md_syntax) and str(self.cur_selection).endswith(self.md_syntax):
394409
self.remove_markdown_both_sides(self.cur_selection, self.md_syntax)
395410
else:

0 commit comments

Comments
 (0)