741 mermaid = ( |
741 mermaid = ( |
742 "<script type='text/javascript' id='Mermaid-script'" |
742 "<script type='text/javascript' id='Mermaid-script'" |
743 " src='https://unpkg.com/mermaid@8/dist/mermaid.min.js'>\n" |
743 " src='https://unpkg.com/mermaid@8/dist/mermaid.min.js'>\n" |
744 "</script>\n" |
744 "</script>\n" |
745 ) |
745 ) |
|
746 if e5App().usesDarkPalette(): |
|
747 mermaid_initialize = ( |
|
748 "<script>mermaid.initialize({" |
|
749 "theme: 'dark', " |
|
750 "startOnLoad:true" |
|
751 "});</script>" |
|
752 ) |
|
753 else: |
|
754 mermaid_initialize = ( |
|
755 "<script>mermaid.initialize({" |
|
756 "theme: 'default', " |
|
757 "startOnLoad:true" |
|
758 "});</script>" |
|
759 ) |
746 else: |
760 else: |
747 mermaid = "" |
761 mermaid = "" |
|
762 mermaid_initialize = "" |
748 |
763 |
749 htmlFormat = Preferences.getEditor("PreviewMarkdownHTMLFormat").lower() |
764 htmlFormat = Preferences.getEditor("PreviewMarkdownHTMLFormat").lower() |
750 body = markdown.markdown(text, extensions=extensions, |
765 body = markdown.markdown(text, extensions=extensions, |
751 output_format=htmlFormat.lower()) |
766 output_format=htmlFormat.lower()) |
|
767 if e5App().usesDarkPalette(): |
|
768 style = ( |
|
769 PreviewerHTMLStyles.css_markdown_dark + |
|
770 PreviewerHTMLStyles.css_pygments_dark |
|
771 ) |
|
772 else: |
|
773 style = ( |
|
774 PreviewerHTMLStyles.css_markdown_light + |
|
775 PreviewerHTMLStyles.css_pygments_light |
|
776 ) |
752 |
777 |
753 if htmlFormat == "xhtml1": |
778 if htmlFormat == "xhtml1": |
754 head = ( |
779 head = ( |
755 '''<!DOCTYPE html PUBLIC "-//W3C//DTD''' |
780 '''<!DOCTYPE html PUBLIC "-//W3C//DTD''' |
756 ''' XHTML 1.0 Transitional//EN"\n''' |
781 ''' XHTML 1.0 Transitional//EN"\n''' |
775 '''<style type="text/css">''' |
800 '''<style type="text/css">''' |
776 '''{2}''' |
801 '''{2}''' |
777 '''</style>\n''' |
802 '''</style>\n''' |
778 '''</head>\n''' |
803 '''</head>\n''' |
779 '''<body>\n''' |
804 '''<body>\n''' |
780 ).format( |
805 ).format(mathjax, mermaid, style) |
781 mathjax, mermaid, |
|
782 PreviewerHTMLStyles.css_markdown + |
|
783 PreviewerHTMLStyles.css_pygments |
|
784 ) |
|
785 |
806 |
786 foot = '''\n</body>\n</html>\n''' |
807 foot = '''\n</body>\n</html>\n''' |
787 |
808 |
788 return head + body + foot |
809 return head + body + mermaid_initialize + foot |