@@ -411,88 +411,6 @@ def check_bold_italic(self, md_syntax, md_ignore, md_special):
411
411
self .apply_markdown_both_sides (self .cur_selection , self .md_syntax )
412
412
413
413
414
-
415
-
416
- # try:
417
-
418
- # # Try to remove formatting from start/end of string for each option
419
- # # if none of the options are True then apply the formatting, these
420
- # # need to be in the correct order. Custom logic for each formatting
421
- # # option (headings, lists, etc) should now be easier to
422
- # # differentiate and stop things firing incorrectly.
423
- # self.cur_selection = self.text_area.selection_get()
424
- # # Bold-italic
425
- # if str(self.cur_selection).startswith(constants.bold_italic_md_syntax) and str(self.cur_selection).endswith(constants.bold_italic_md_syntax):
426
- # self.remove_md = str(self.cur_selection).strip(self.md_syntax[0]).strip(self.md_syntax[1])
427
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
428
- # self.text_area.insert(INSERT, self.remove_md)
429
- # return
430
- # # Bold
431
- # if str(self.cur_selection).startswith(constants.bold_md_syntax) and str(self.cur_selection).endswith(constants.bold_md_syntax):
432
- # self.remove_md = str(self.cur_selection).strip(self.md_syntax[0]).strip(self.md_syntax[1])
433
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
434
- # self.text_area.insert(INSERT, self.remove_md)
435
- # return
436
- # # Italic
437
- # if str(self.cur_selection).startswith(constants.italic_md_syntax) and str(self.cur_selection).endswith(constants.italic_md_syntax):
438
- # self.remove_md = str(self.cur_selection).strip(self.md_syntax[0]).strip(self.md_syntax[1])
439
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
440
- # self.text_area.insert(INSERT, self.remove_md)
441
- # return
442
- # # Strikethrough
443
- # if str(self.cur_selection).startswith(constants.strikethrough_md_syntax) and str(self.cur_selection).endswith(constants.strikethrough_md_syntax):
444
- # self.remove_md = str(self.cur_selection).strip(self.md_syntax[0]).strip(self.md_syntax[1])
445
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
446
- # self.text_area.insert(INSERT, self.remove_md)
447
- # return
448
- # #
449
- # #
450
- # # Insert the rest of the button formatting options here.
451
- # #
452
- # #
453
-
454
- # else:
455
- # self.insert_md = f"{self.md_syntax[0]}{self.cur_selection}{self.md_syntax[0]}"
456
-
457
- # except:
458
- # # This needs replacing with logging.
459
- # print("EXCEPTION: Application/removal of markdown formatting failed.")
460
- # pass
461
-
462
-
463
-
464
- # try:
465
- # self.cur_selection = self.text_area.selection_get()
466
- # if len(self.md_syntax) == 2 and self.md_syntax[0] == "**" and self.md_syntax[1] == "__" and str(self.cur_selection)[1] != "*" and str(self.cur_selection)[1] != "_":
467
- # if str(self.cur_selection).startswith(self.md_syntax) == False and str(self.cur_selection).startswith(self.md_ignore) == False and str(self.cur_selection)[0] != "*" and str(self.cur_selection)[0] != "_":
468
- # self.with_md_selection = f"{self.md_syntax[0]}{self.cur_selection}{self.md_syntax[0]}"
469
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
470
- # self.text_area.insert(INSERT, self.with_md_selection)
471
- # return
472
- # else:
473
- # return
474
- # if str(self.cur_selection).startswith(self.md_syntax) == True and str(self.cur_selection).endswith(self.md_syntax) == True and str(self.cur_selection).startswith(self.md_ignore) == False:
475
- # self.without_md_selection = str(self.cur_selection).replace(self.md_syntax[0], "").replace(self.md_syntax[1], "")
476
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
477
- # self.text_area.insert(INSERT, self.without_md_selection)
478
- # return
479
- # elif str(self.cur_selection).startswith(self.md_syntax) == True and str(self.cur_selection).startswith(self.md_ignore) == True:
480
- # return
481
- # elif str(self.cur_selection).startswith(self.md_syntax) == True and str(self.cur_selection).startswith(self.md_ignore) == False:
482
- # self.without_md_selection = str(self.cur_selection).replace(self.md_syntax[0], "").replace(self.md_syntax[1], "")
483
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
484
- # self.text_area.insert(INSERT, self.without_md_selection)
485
- # return
486
- # elif str(self.cur_selection).startswith(self.md_syntax) == False and str(self.cur_selection).startswith(self.md_ignore) == False:
487
- # self.with_md_selection = f"{self.md_syntax[0]}{self.cur_selection}{self.md_syntax[0]}"
488
- # self.text_area.delete(index1=SEL_FIRST, index2=SEL_LAST)
489
- # self.text_area.insert(INSERT, self.with_md_selection)
490
- # return
491
- # except:
492
- # # This needs replacing with logging.
493
- # print("EXCEPTION: Application/removal of markdown formatting failed.")
494
- # pass
495
-
496
414
class Lexer (MarkdownLexer ):
497
415
"""Extend MarkdownLexer to add markup for bold-italic.
498
416
0 commit comments