Repository: facelessuser/pymdown-extensions

Issue:
remove "language" from css class
Hi, 

Question relating to 'pymdownx.highlight':

Is there a way to remove the prefix string "language" in "language-mylanguage"?

I can set `css_class:''`, but I see no option to set the prefix instead of `prefix:'language-'` to `prefix:''`

Highlight.js does support class='mylanguage', without the need to specify class='language-mylanguage'

Thanks

Discussion:
facelessuser: @gir-bot lgtm

Patch:
diff --git a/docs/src/markdown/about/changelog.md b/docs/src/markdown/about/changelog.md
index 4e6fe523..3af67be7 100644
--- a/docs/src/markdown/about/changelog.md
+++ b/docs/src/markdown/about/changelog.md
@@ -2,6 +2,8 @@
 
 ## 7.2
 
+- **NEW**: Highlight: add new option `language_prefix` which controls the prefix applied to language classes when
+  Pygments is not being used.
 - **NEW**: Add new extension called SaneHeaders which restricts hash headers to only evaluate if the hashes (`#`) are
   followed by a space. Allows extensions like MagicLink to have issues links at the start of a line.
 - **NEW**: Highlight option `linenums` now defaults to `None` and accepts `None`, `True`, or `False`. `None` is
diff --git a/docs/src/markdown/extensions/highlight.md b/docs/src/markdown/extensions/highlight.md
index 74cc59f2..c1a7cf6b 100644
--- a/docs/src/markdown/extensions/highlight.md
+++ b/docs/src/markdown/extensions/highlight.md
@@ -106,6 +106,7 @@ Option                    | Type   | Default               | Description
 `linenums_class`          | string | `#!py3 'linenums'`    | Controls the name of the line number class when Pygments is not used.
 `extend_pygments_lang`    | list   | `#!py3 []`            | A list of extended languages to add.  See [Extended Pygments Lexer Options](#extended-pygments-lexer-options) for more info.
 `legacy_no_wrap_code`     | bool   | `#!py3 False`         | A temporary option provided during the transition period to the new output format. From now on, all block code under `pre` elements will be wrapped in a `code` element as well under Pygments 2.4+. This disables this format. This option will be removed in the future.
+`language_prefix`         | string | `#!py3 'language-'`   | Controls the prefix applied to the language class when Pygments is not used. By default, uses the HTML5 `language-`.
 
 !!! new "New 6.2"
     `legacy_no_wrap_code` was added in `6.3`, but is only provided to help transition to the format when using Pygments 2.4+. This option will be removed in the future.
diff --git a/pymdownx/highlight.py b/pymdownx/highlight.py
index aff651c4..1bcc021b 100644
--- a/pymdownx/highlight.py
+++ b/pymdownx/highlight.py
@@ -88,6 +88,10 @@ DEFAULT_CONFIG = {
         False,
         'Do not wrap block code under pre elements with code elements - Default: False'
     ],
+    'language_prefix': [
+        'language-',
+        'Controls the language prefix for non-Pygments code blocks. - Defaults: "language-"'
+    ],
     '_enabled': [
         True,
         'Used internally to communicate if extension has been explicitly enabled - Default: False'
@@ -184,7 +188,7 @@ class Highlight(object):
     def __init__(
         self, guess_lang=True, pygments_style='default', use_pygments=True,
         noclasses=False, extend_pygments_lang=None, linenums=None, linenums_special=-1,
-        linenums_style='table', linenums_class='linenums', wrapcode=True
+        linenums_style='table', linenums_class='linenums', wrapcode=True, language_prefix='language-'
     ):
         """Initialize."""
 
@@ -197,6 +201,7 @@ class Highlight(object):
         self.linenums_special = linenums_special
         self.linenums_class = linenums_class
         self.wrapcode = wrapcode
+        self.language_prefix = language_prefix
 
         if extend_pygments_lang is None:  # pragma: no cover
             extend_pygments_lang = []
@@ -305,7 +310,7 @@ class Highlight(object):
             code = self.escape(src)
             classes = class_names + ([css_class] if css_class else [])
             if language:
-                classes.append('language-%s' % language)
+                classes.append(self.language_prefix + language)
             class_str = ''
             if len(classes):
                 class_str = ' '.join(classes)
@@ -314,7 +319,7 @@ class Highlight(object):
             classes = class_names
             linenums = self.linenums_style if linenums_enabled else False
             if language:
-                classes.append('language-%s' % language)
+                classes.append(self.language_prefix + language)
             class_str = ''
             if linenums:
                 classes.append(self.linenums_class)
@@ -364,7 +369,8 @@ class HighlightTreeprocessor(Treeprocessor):
                     linenums_special=self.config['linenums_special'],
                     linenums_class=self.config['linenums_class'],
                     extend_pygments_lang=self.config['extend_pygments_lang'],
-                    wrapcode=not self.config['legacy_no_wrap_code']
+                    wrapcode=not self.config['legacy_no_wrap_code'],
+                    language_prefix=self.config['language_prefix']
                 )
                 placeholder = self.md.htmlStash.store(
                     code.highlight(
diff --git a/pymdownx/inlinehilite.py b/pymdownx/inlinehilite.py
index 6ba319d9..ba76e919 100644
--- a/pymdownx/inlinehilite.py
+++ b/pymdownx/inlinehilite.py
@@ -126,6 +126,7 @@ class InlineHilitePattern(InlineProcessor):
             self.pygments_style = config['pygments_style']
             self.use_pygments = config['use_pygments']
             self.noclasses = config['noclasses']
+            self.language_prefix = config['language_prefix']
 
     def highlight_code(self, src, language, classname=None, md=None):
         """Syntax highlight the inline code block."""
@@ -138,7 +139,8 @@ class InlineHilitePattern(InlineProcessor):
                 pygments_style=self.pygments_style,
                 use_pygments=self.use_pygments,
                 noclasses=self.noclasses,
-                extend_pygments_lang=self.extend_pygments_lang
+                extend_pygments_lang=self.extend_pygments_lang,
+                language_prefix=self.language_prefix
             ).highlight(src, language, self.css_class, inline=True)
             el.text = self.md.htmlStash.store(el.text)
         else:
diff --git a/pymdownx/superfences.py b/pymdownx/superfences.py
index 9e8cd2c2..0a63dbc7 100644
--- a/pymdownx/superfences.py
+++ b/pymdownx/superfences.py
@@ -441,6 +441,7 @@ class SuperFencesBlockPreprocessor(Preprocessor):
             self.linenums_class = config.get('linenums_class', 'linenums')
             self.linenums_special = config.get('linenums_special', -1)
             self.wrapcode = not config.get('legacy_no_wrap_code', False)
+            self.language_prefix = config.get('language_prefix', 'language-')
 
     def clear(self):
         """Reset the class variables."""
@@ -795,7 +796,8 @@ class SuperFencesBlockPreprocessor(Preprocessor):
             linenums_special=self.linenums_special,
             linenums_class=self.linenums_class,
             extend_pygments_lang=self.extend_pygments_lang,
-            wrapcode=self.wrapcode
+            wrapcode=self.wrapcode,
+            language_prefix=self.language_prefix
         ).highlight(
             src,
             language,


Test patch:
diff --git a/tests/test_extensions/test_highlight.py b/tests/test_extensions/test_highlight.py
index 1f39be50..bc15383b 100644
--- a/tests/test_extensions/test_highlight.py
+++ b/tests/test_extensions/test_highlight.py
@@ -127,6 +127,43 @@ class TestNoClassNoPygments(util.MdCase):
         )
 
 
+class TestCustomLangPrefixNoPygments(util.MdCase):
+    """Test custom language prefix."""
+
+    extension = ['pymdownx.highlight', 'pymdownx.superfences', 'pymdownx.inlinehilite']
+    extension_configs = {
+        'pymdownx.highlight': {
+            'language_prefix': 'lang-',
+            'use_pygments': False
+        }
+    }
+
+    def test_custom_prefix_no_pygments(self):
+        """Test with custom prefix and no Pygments."""
+
+        self.check_markdown(
+            r'''
+            ```python
+            import test
+            test.test()
+            ```
+            ''',
+            r'''
+            <pre class="highlight"><code class="lang-python">import test
+            test.test()</code></pre>
+            ''',  # noqa: E501
+            True
+        )
+
+    def test_custom_prefix_no_pygments_inline(self):
+        """Test with custom prefix and no Pygments with inline code."""
+
+        self.check_markdown(
+            '`#!python import test`',
+            '<p><code class="highlight lang-python">import test</code></p>'
+        )
+
+
 class TestNoPygments(util.MdCase):
     """Test no Pygments."""