mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
@@ -445,7 +445,7 @@ var inline = {
|
|||||||
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
||||||
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
||||||
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
||||||
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
code: /^(`+)(\s*[\s\S]*?[^`]\s*)\1(?!`)/,
|
||||||
br: /^ {2,}\n(?!\s*$)/,
|
br: /^ {2,}\n(?!\s*$)/,
|
||||||
del: noop,
|
del: noop,
|
||||||
emoji: noop,
|
emoji: noop,
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
"expected_output": "<p>Hamlet once said</p>\n<div class=\"codehilite\"><pre><span></span>def func():\n x = 1\n\n y = 2\n\n z = 3\n</pre></div>\n\n\n<p>And all was good.</p>",
|
"expected_output": "<p>Hamlet once said</p>\n<div class=\"codehilite\"><pre><span></span>def func():\n x = 1\n\n y = 2\n\n z = 3\n</pre></div>\n\n\n<p>And all was good.</p>",
|
||||||
"text_content": "Hamlet once said\ndef func():\n x = 1\n\n y = 2\n\n z = 3\n\n\n\nAnd all was good."
|
"text_content": "Hamlet once said\ndef func():\n x = 1\n\n y = 2\n\n z = 3\n\n\n\nAnd all was good."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inline_code_spaces",
|
||||||
|
"input": "` outer ` ``` space ```",
|
||||||
|
"expected_output": "<p><code> outer </code> <code> space </code></p>",
|
||||||
|
"text_content": " outer space "
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "codeblock_backticks",
|
"name": "codeblock_backticks",
|
||||||
"input": "\n```\nfenced code\n```\n\n```inline code```\n",
|
"input": "\n```\nfenced code\n```\n\n```inline code```\n",
|
||||||
|
|||||||
@@ -355,6 +355,24 @@ class InlineHttpsProcessor(markdown.treeprocessors.Treeprocessor):
|
|||||||
continue
|
continue
|
||||||
img.set("src", get_camo_url(url))
|
img.set("src", get_camo_url(url))
|
||||||
|
|
||||||
|
class BacktickPattern(markdown.inlinepatterns.Pattern):
|
||||||
|
""" Return a `<code>` element containing the matching text. """
|
||||||
|
def __init__(self, pattern):
|
||||||
|
# type: (Text) -> None
|
||||||
|
markdown.inlinepatterns.Pattern.__init__(self, pattern)
|
||||||
|
self.ESCAPED_BSLASH = '%s%s%s' % (markdown.util.STX, ord('\\'), markdown.util.ETX)
|
||||||
|
self.tag = 'code'
|
||||||
|
|
||||||
|
def handleMatch(self, m):
|
||||||
|
# type: (Match[Text]) -> Union[Text, Element]
|
||||||
|
if m.group(4):
|
||||||
|
el = markdown.util.etree.Element(self.tag)
|
||||||
|
# Modified to not strip whitespace
|
||||||
|
el.text = markdown.util.AtomicString(m.group(4))
|
||||||
|
return el
|
||||||
|
else:
|
||||||
|
return m.group(2).replace('\\\\', self.ESCAPED_BSLASH)
|
||||||
|
|
||||||
class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
|
||||||
TWITTER_MAX_IMAGE_HEIGHT = 400
|
TWITTER_MAX_IMAGE_HEIGHT = 400
|
||||||
TWITTER_MAX_TO_PREVIEW = 3
|
TWITTER_MAX_TO_PREVIEW = 3
|
||||||
@@ -1346,7 +1364,7 @@ class Bugdown(markdown.Extension):
|
|||||||
for k in ('image_link', 'image_reference', 'automail',
|
for k in ('image_link', 'image_reference', 'automail',
|
||||||
'autolink', 'link', 'reference', 'short_reference',
|
'autolink', 'link', 'reference', 'short_reference',
|
||||||
'escape', 'strong_em', 'emphasis', 'emphasis2',
|
'escape', 'strong_em', 'emphasis', 'emphasis2',
|
||||||
'linebreak', 'strong'):
|
'linebreak', 'strong', 'backtick'):
|
||||||
del md.inlinePatterns[k]
|
del md.inlinePatterns[k]
|
||||||
try:
|
try:
|
||||||
# linebreak2 was removed upstream in version 3.2.1, so
|
# linebreak2 was removed upstream in version 3.2.1, so
|
||||||
@@ -1357,6 +1375,12 @@ class Bugdown(markdown.Extension):
|
|||||||
|
|
||||||
md.preprocessors.add("custom_text_notifications", AlertWordsNotificationProcessor(md), "_end")
|
md.preprocessors.add("custom_text_notifications", AlertWordsNotificationProcessor(md), "_end")
|
||||||
|
|
||||||
|
# Inline code block without whitespace stripping
|
||||||
|
md.inlinePatterns.add(
|
||||||
|
"backtick",
|
||||||
|
BacktickPattern(r'(?:(?<!\\)((?:\\{2})+)(?=`+)|(?<!\\)(`+)(.+?)(?<!`)\3(?!`))'),
|
||||||
|
"_begin")
|
||||||
|
|
||||||
# Custom bold syntax: **foo** but not __foo__
|
# Custom bold syntax: **foo** but not __foo__
|
||||||
md.inlinePatterns.add('strong',
|
md.inlinePatterns.add('strong',
|
||||||
markdown.inlinepatterns.SimpleTagPattern(r'(\*\*)([^\n]+?)\2', 'strong'),
|
markdown.inlinepatterns.SimpleTagPattern(r'(\*\*)([^\n]+?)\2', 'strong'),
|
||||||
|
|||||||
Reference in New Issue
Block a user