eric6/QScintilla/MarkupProviders/__init__.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
permissions
-rw-r--r--

Updated copyright for 2021.

5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Package providing various markup providers.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import Preferences
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 def getMarkupProvider(editor):
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 Public method to get a markup provider for the given editor.
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 @param editor reference to the editor to get the markup provider for
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 @type Editor
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 @return markup provider
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @rtype MarkupBase
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 if editor is not None:
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 fn = editor.getFileName()
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 if fn:
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 extension = os.path.normcase(os.path.splitext(fn)[1][1:])
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 else:
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 extension = ""
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
31 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
32 extension in Preferences.getEditor(
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
33 "PreviewHtmlFileNameExtensions") or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
34 editor.getLanguage() == "HTML"
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
35 ):
5397
fee5485e67f4 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
36 from .HtmlProvider import HtmlProvider
fee5485e67f4 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
37 return HtmlProvider()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
38 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
39 extension in Preferences.getEditor(
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
40 "PreviewMarkdownFileNameExtensions") or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
41 editor.getLanguage().lower() == "markdown"
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
42 ):
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 from .MarkdownProvider import MarkdownProvider
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 return MarkdownProvider()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
45 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
46 extension in Preferences.getEditor(
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
47 "PreviewRestFileNameExtensions") or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
48 editor.getLanguage().lower() == "restructuredtext"
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
49 ):
5397
fee5485e67f4 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
50 from .RestructuredTextProvider import RestructuredTextProvider
fee5485e67f4 Continued implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5394
diff changeset
51 return RestructuredTextProvider()
5394
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 # no supported markup provider identified
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 from .MarkupBase import MarkupBase
b2c6179184f6 Started implementing a format button bar and provider classes for various markup languages.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 return MarkupBase()

eric ide

mercurial