mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
bugdown: Use our local copy of fenced_code
And wire it up to our local copy of codehilite. This fixes highlighting in
fenced code blocks, e.g.
~~~~ .js
var x = function () {
return "hi";
};
~~~~
(imported from commit 0efb0c9b98a3acdf55e18bb1918af7960f3425be)
This commit is contained in:
@@ -4,7 +4,7 @@ import traceback
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from zephyr.lib.avatar import gravatar_hash
|
from zephyr.lib.avatar import gravatar_hash
|
||||||
from zephyr.lib.bugdown import codehilite
|
from zephyr.lib.bugdown import codehilite, fenced_code
|
||||||
|
|
||||||
class Gravatar(markdown.inlinepatterns.Pattern):
|
class Gravatar(markdown.inlinepatterns.Pattern):
|
||||||
def handleMatch(self, match):
|
def handleMatch(self, match):
|
||||||
@@ -76,10 +76,11 @@ def convert(md):
|
|||||||
_md_engine = markdown.Markdown(
|
_md_engine = markdown.Markdown(
|
||||||
safe_mode = 'escape',
|
safe_mode = 'escape',
|
||||||
output_format = 'html',
|
output_format = 'html',
|
||||||
extensions = ['fenced_code', 'nl2br',
|
extensions = ['nl2br',
|
||||||
codehilite.makeExtension(configs=[
|
codehilite.makeExtension(configs=[
|
||||||
('force_linenos', False),
|
('force_linenos', False),
|
||||||
('guess_lang', False)]),
|
('guess_lang', False)]),
|
||||||
|
fenced_code.makeExtension(),
|
||||||
Bugdown()])
|
Bugdown()])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ Dependencies:
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
import markdown
|
import markdown
|
||||||
from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension
|
from zephyr.lib.bugdown.codehilite import CodeHilite, CodeHiliteExtension
|
||||||
|
|
||||||
# Global vars
|
# Global vars
|
||||||
FENCED_BLOCK_RE = re.compile( \
|
FENCED_BLOCK_RE = re.compile( \
|
||||||
@@ -130,7 +130,7 @@ class FencedBlockPreprocessor(markdown.preprocessors.Preprocessor):
|
|||||||
# is enabled, so we call it to highlite the code
|
# is enabled, so we call it to highlite the code
|
||||||
if self.codehilite_conf:
|
if self.codehilite_conf:
|
||||||
highliter = CodeHilite(m.group('code'),
|
highliter = CodeHilite(m.group('code'),
|
||||||
linenos=self.codehilite_conf['force_linenos'][0],
|
force_linenos=self.codehilite_conf['force_linenos'][0],
|
||||||
guess_lang=self.codehilite_conf['guess_lang'][0],
|
guess_lang=self.codehilite_conf['guess_lang'][0],
|
||||||
css_class=self.codehilite_conf['css_class'][0],
|
css_class=self.codehilite_conf['css_class'][0],
|
||||||
style=self.codehilite_conf['pygments_style'][0],
|
style=self.codehilite_conf['pygments_style'][0],
|
||||||
|
|||||||
Reference in New Issue
Block a user