‹›
markdown.inlinepatterns
¶
In version 3.0, a new, more flexible inline processor was added, markdown.inlinepatterns.InlineProcessor. The
original inline patterns, which inherit from markdown.inlinepatterns.Pattern or one of its children are still
supported, though users are encouraged to migrate.
The new InlineProcessor provides two major enhancements to Patterns:
-
Inline Processors no longer need to match the entire block, so regular expressions no longer need to start with
r'^(.*?)'and end withr'(.*?)%'. This runs faster. The returnedMatchobject will only contain what is explicitly matched in the pattern, and extension pattern groups now start withm.group(1). -
The
handleMatchmethod now takes an additional input calleddata, which is the entire block under analysis, not just what is matched with the specified pattern. The method now returns the element and the indexes relative todatathat the return element is replacing (usuallym.start(0)andm.end(0)). If the boundaries are returned asNone, it is assumed that the match did not take place, and nothing will be altered indata.This allows handling of more complex constructs than regular expressions can handle, e.g., matching nested brackets, and explicit control of the span “consumed” by the processor.
Modules:
-
util–This module contains various contacts, classes and functions which get referenced and used
Classes:
-
EmStrongItem–Emphasis/strong pattern item.
-
Pattern–Base class that inline patterns subclass.
-
InlineProcessor–Base class that inline processors subclass.
-
SimpleTextPattern–Return a simple text of
group(2)of a Pattern. -
SimpleTextInlineProcessor–Return a simple text of
group(1)of a Pattern. -
EscapeInlineProcessor–Return an escaped character.
-
SimpleTagPattern–Return element of type
tagwith a text attribute ofgroup(3) -
SimpleTagInlineProcessor–Return element of type
tagwith a text attribute ofgroup(2) -
SubstituteTagPattern–Return an element of type
tagwith no children. -
SubstituteTagInlineProcessor–Return an element of type
tagwith no children. -
BacktickInlineProcessor–Return a
<code>element containing the escaped matching text. -
DoubleTagPattern–Return a ElementTree element nested in tag2 nested in tag1.
-
DoubleTagInlineProcessor–Return a ElementTree element nested in tag2 nested in tag1.
-
HtmlInlineProcessor–Store raw inline html and return a placeholder.
-
AsteriskProcessor–Emphasis processor for handling strong and em matches inside asterisks.
-
UnderscoreProcessor–Emphasis processor for handling strong and em matches inside underscores.
-
LinkInlineProcessor–Return a link element from the given match.
-
ImageInlineProcessor–Return a
imgelement from the given match. -
ReferenceInlineProcessor–Match to a stored reference and return link element.
-
ShortReferenceInlineProcessor–Short form of reference:
[google]. -
ImageReferenceInlineProcessor–Match to a stored reference and return
imgelement. -
ShortImageReferenceInlineProcessor–Short form of image reference:
![ref]. -
AutolinkInlineProcessor–Return a link Element given an auto-link (
<http://example/com>). -
AutomailInlineProcessor–Return a
mailtolink Element given an auto-mail link (<foo@example.com>).
Functions:
-
build_inlinepatterns–Build the default set of inline patterns for Markdown.
-
dequote–Remove quotes from around a string.
Attributes:
-
NOIMG–Match not an image. Partial regular expression which matches if not preceded by
!. -
BACKTICK_RE–Match backtick quoted string (
`e=f()`or``e=f("`")``). -
ESCAPE_RE–Match a backslash escaped character (
\<or\*). -
EMPHASIS_RE–Match emphasis with an asterisk (
*emphasis*). -
STRONG_RE–Match strong with an asterisk (
**strong**). -
SMART_STRONG_RE–Match strong with underscore while ignoring middle word underscores (
__smart__strong__). -
SMART_EMPHASIS_RE–Match emphasis with underscore while ignoring middle word underscores (
_smart_emphasis_). -
SMART_STRONG_EM_RE–Match strong emphasis with underscores (
__strong _em__). -
EM_STRONG_RE–Match emphasis strong with asterisk (
***strongem***or***em*strong**). -
EM_STRONG2_RE–Match emphasis strong with underscores (
___emstrong___or___em_strong__). -
STRONG_EM_RE–Match strong emphasis with asterisk (
***strong**em*). -
STRONG_EM2_RE–Match strong emphasis with underscores (
___strong__em_). -
STRONG_EM3_RE–Match strong emphasis with asterisk (
**strong*em***). -
LINK_RE–Match start of in-line link (
[text](url)or[text](<url>)or[text](url "title")). -
IMAGE_LINK_RE–Match start of in-line image link (
or). -
REFERENCE_RE–Match start of reference link (
[Label][3]). -
IMAGE_REFERENCE_RE–Match start of image reference (
![alt text][2]). -
NOT_STRONG_RE–Match a stand-alone
*or_. -
AUTOLINK_RE–Match an automatic link (
<http://www.example.com>). -
AUTOMAIL_RE–Match an automatic email link (
<me@example.com>). -
HTML_RE–Match an HTML tag (
<...>). -
ENTITY_RE–Match an HTML entity (
&(decimal) or&(hex) or&(named)). -
LINE_BREAK_RE–Match two spaces at end of line.
‹›
markdown.inlinepatterns.build_inlinepatterns(md: Markdown, **kwargs: Any) -> util.Registry[InlineProcessor]
¶
Build the default set of inline patterns for Markdown.
The order in which processors and/or patterns are applied is very important - e.g. if we first replace
http://.../ links with <a> tags and then try to replace inline HTML, we would end up with a mess. So, we
apply the expressions in the following order:
-
backticks and escaped characters have to be handled before everything else so that we can preempt any markdown patterns by escaping them;
-
then we handle the various types of links (auto-links must be handled before inline HTML);
-
then we handle inline HTML. At this point we will simply replace all inline HTML strings with a placeholder and add the actual HTML to a stash;
-
finally we apply strong, emphasis, etc.
Return a Registry instance which contains the following collection of classes with their assigned names and priorities.
| Class Instance | Name | Priority |
|---|---|---|
BacktickInlineProcessor(BACKTICK_RE) |
backtick |
190 |
EscapeInlineProcessor(ESCAPE_RE) |
escape |
180 |
ReferenceInlineProcessor(REFERENCE_RE) |
reference |
170 |
LinkInlineProcessor(LINK_RE) |
link |
160 |
ImageInlineProcessor(IMAGE_LINK_RE) |
image_link |
150 |
ImageReferenceInlineProcessor(IMAGE_REFERENCE_RE) |
image_reference |
140 |
ShortReferenceInlineProcessor(REFERENCE_RE) |
short_reference |
130 |
ShortImageReferenceInlineProcessor(IMAGE_REFERENCE_RE) |
short_image_ref |
125 |
AutolinkInlineProcessor(AUTOLINK_RE) |
autolink |
120 |
AutomailInlineProcessor(AUTOMAIL_RE) |
automail |
110 |
SubstituteTagInlineProcessor(LINE_BREAK_RE) |
linebreak |
100 |
HtmlInlineProcessor(HTML_RE) |
html |
90 |
HtmlInlineProcessor(ENTITY_RE) |
entity |
80 |
SimpleTextInlineProcessor(NOT_STRONG_RE) |
not_strong |
70 |
AsteriskProcessor("\*") |
em_strong |
60 |
UnderscoreProcessor("_") |
em_strong2 |
50 |
‹›
markdown.inlinepatterns.NOIMG
module-attribute
¶
Match not an image. Partial regular expression which matches if not preceded by !.
Defined Value:
NOIMG = r'(?<!\!)'
‹›
markdown.inlinepatterns.BACKTICK_RE
module-attribute
¶
Match backtick quoted string (`e=f()` or ``e=f("`")``).
Defined Value:
BACKTICK_RE = r'(?:(?<!\\)((?:\\{2})+)(?=`+)|(?<!\\)(`+)(.+?)(?<!`)\2(?!`))'
‹›
markdown.inlinepatterns.ESCAPE_RE
module-attribute
¶
Match a backslash escaped character (\< or \*).
Defined Value:
ESCAPE_RE = r'\\(.)'
‹›
markdown.inlinepatterns.EMPHASIS_RE
module-attribute
¶
Match emphasis with an asterisk (*emphasis*).
Defined Value:
EMPHASIS_RE = r'(\*)([^\*]+)\1'
‹›
markdown.inlinepatterns.STRONG_RE
module-attribute
¶
Match strong with an asterisk (**strong**).
Defined Value:
STRONG_RE = r'(\*{2})(.+?)\1'
‹›
markdown.inlinepatterns.SMART_STRONG_RE
module-attribute
¶
Match strong with underscore while ignoring middle word underscores (__smart__strong__).
Defined Value:
SMART_STRONG_RE = r'(?<!\w)(_{2})(?!_)(.+?)(?<!_)\1(?!\w)'
‹›
markdown.inlinepatterns.SMART_EMPHASIS_RE
module-attribute
¶
Match emphasis with underscore while ignoring middle word underscores (_smart_emphasis_).
Defined Value:
SMART_EMPHASIS_RE = r'(?<!\w)(_)(?!_)(.+?)(?<!_)\1(?!\w)'
‹›
markdown.inlinepatterns.SMART_STRONG_EM_RE
module-attribute
¶
Match strong emphasis with underscores (__strong _em__).
Defined Value:
SMART_STRONG_EM_RE = r'(?<!\w)(\_)\1(?!\1)(.+?)(?<!\w)\1(?!\1)(.+?)\1{3}(?!\w)'
‹›
markdown.inlinepatterns.EM_STRONG_RE
module-attribute
¶
Match emphasis strong with asterisk (***strongem*** or ***em*strong**).
Defined Value:
EM_STRONG_RE = r'(\*)\1{2}(.+?)\1(.*?)\1{2}'
‹›
markdown.inlinepatterns.EM_STRONG2_RE
module-attribute
¶
Match emphasis strong with underscores (___emstrong___ or ___em_strong__).
Defined Value:
EM_STRONG2_RE = r'(_)\1{2}(.+?)\1(.*?)\1{2}'
‹›
markdown.inlinepatterns.STRONG_EM_RE
module-attribute
¶
Match strong emphasis with asterisk (***strong**em*).
Defined Value:
STRONG_EM_RE = r'(\*)\1{2}(.+?)\1{2}(.*?)\1'
‹›
markdown.inlinepatterns.STRONG_EM2_RE
module-attribute
¶
Match strong emphasis with underscores (___strong__em_).
Defined Value:
STRONG_EM2_RE = r'(_)\1{2}(.+?)\1{2}(.*?)\1'
‹›
markdown.inlinepatterns.STRONG_EM3_RE
module-attribute
¶
Match strong emphasis with asterisk (**strong*em***).
Defined Value:
STRONG_EM3_RE = r'(\*)\1(?!\1)([^*]+?)\1(?!\1)(.+?)\1{3}'
‹›
markdown.inlinepatterns.LINK_RE
module-attribute
¶
Match start of in-line link ([text](url) or [text](<url>) or [text](url "title")).
Defined Value:
LINK_RE = NOIMG + r'\['
‹›
markdown.inlinepatterns.IMAGE_LINK_RE
module-attribute
¶
Match start of in-line image link ( or ).
Defined Value:
IMAGE_LINK_RE = r'\!\['
‹›
markdown.inlinepatterns.REFERENCE_RE
module-attribute
¶
Match start of reference link ([Label][3]).
Defined Value:
REFERENCE_RE = LINK_RE
‹›
markdown.inlinepatterns.IMAGE_REFERENCE_RE
module-attribute
¶
Match start of image reference (![alt text][2]).
Defined Value:
IMAGE_REFERENCE_RE = IMAGE_LINK_RE
‹›
markdown.inlinepatterns.NOT_STRONG_RE
module-attribute
¶
Match a stand-alone * or _.
Defined Value:
NOT_STRONG_RE = r'((^|(?<=\s))(\*{1,3}|_{1,3})(?=\s|$))'
‹›
markdown.inlinepatterns.AUTOLINK_RE
module-attribute
¶
Match an automatic link (<http://www.example.com>).
Defined Value:
AUTOLINK_RE = r'<((?:[Ff]|[Hh][Tt])[Tt][Pp][Ss]?://[^<>]*)>'
‹›
markdown.inlinepatterns.AUTOMAIL_RE
module-attribute
¶
Match an automatic email link (<me@example.com>).
Defined Value:
AUTOMAIL_RE = r'<([^<> !]+@[^@<> ]+)>'
‹›
markdown.inlinepatterns.HTML_RE
module-attribute
¶
Match an HTML tag (<...>).
Defined Value:
HTML_RE = r'(<(\/?[a-zA-Z][^<>@ ]*( [^<>]*)?|!--(?:(?!<!--|-->).)*--)>)'
‹›
markdown.inlinepatterns.ENTITY_RE
module-attribute
¶
Match an HTML entity (& (decimal) or & (hex) or & (named)).
Defined Value:
ENTITY_RE = r'(&(?:\#[0-9]+|\#x[0-9a-fA-F]+|[a-zA-Z0-9]+);)'
‹›
markdown.inlinepatterns.LINE_BREAK_RE
module-attribute
¶
Match two spaces at end of line.
Defined Value:
LINE_BREAK_RE = r' \n'
‹›
markdown.inlinepatterns.Pattern(pattern: str, md: Markdown | None = None)
¶
Base class that inline patterns subclass.
Inline patterns are handled by means of Pattern subclasses, one per regular expression.
Each pattern object uses a single regular expression and must support the following methods:
getCompiledRegExp and
handleMatch.
All the regular expressions used by Pattern subclasses must capture the whole block. For this
reason, they all start with ^(.*) and end with (.*)!. When passing a regular expression on
class initialization, the ^(.*) and (.*)! are added automatically and the regular expression
is pre-compiled.
It is strongly suggested that the newer style markdown.inlinepatterns.InlineProcessor that
use a more efficient and flexible search approach be used instead. However, the older style
Pattern remains for backward compatibility with many existing third-party extensions.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
handleMatch–Return a ElementTree element from the given match.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.Pattern.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.Pattern.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.InlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: Pattern
Base class that inline processors subclass.
This is the newer style inline processor that uses a more efficient and flexible search approach.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return a ElementTree element from the given match and the
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.InlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.InlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.InlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.InlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.InlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | str | None, int | None, int | None]
¶
Return a ElementTree element from the given match and the start and end index of the matched text.
If start and/or end are returned as None, it will be
assumed that the processor did not find a valid region of text.
Subclasses should override this method.
Parameters:
-
m(Match[str]) –A re match object containing a match of the pattern.
-
data(str) –The buffer currently under analysis.
Returns:
‹›
markdown.inlinepatterns.SimpleTextPattern(pattern: str, md: Markdown | None = None)
¶
Bases: Pattern
Return a simple text of group(2) of a Pattern.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return string content of
group(2)of a matching pattern.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.SimpleTextPattern.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SimpleTextPattern.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SimpleTextPattern.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.SimpleTextInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Return a simple text of group(1) of a Pattern.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return string content of
group(1)of a matching pattern.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.SimpleTextInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SimpleTextInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SimpleTextInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.EscapeInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Return an escaped character.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–If the character matched by
group(1)of a pattern is inESCAPED_CHARS
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.EscapeInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.EscapeInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.EscapeInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.EscapeInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.EscapeInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[str | None, int, int]
¶
If the character matched by group(1) of a pattern is in ESCAPED_CHARS
then return the integer representing the character’s Unicode code point (as returned by ord) wrapped
in util.STX and util.ETX.
If the matched character is not in ESCAPED_CHARS, then return None.
‹›
markdown.inlinepatterns.SimpleTagPattern(pattern: str, tag: str)
¶
Bases: Pattern
Return element of type tag with a text attribute of group(3)
of a Pattern.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return
Elementof typetagwith the string ingroup(3)of a
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.SimpleTagPattern.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SimpleTagPattern.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SimpleTagPattern.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.SimpleTagPattern.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor(pattern: str, tag: str)
¶
Bases: InlineProcessor
Return element of type tag with a text attribute of group(2)
of a Pattern.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return
Elementof typetagwith the string ingroup(2)of a
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.SubstituteTagPattern(pattern: str, tag: str)
¶
Bases: SimpleTagPattern
Return an element of type tag with no children.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return empty
Elementof typetag.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.SubstituteTagPattern.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SubstituteTagPattern.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SubstituteTagPattern.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.SubstituteTagPattern.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor(pattern: str, tag: str)
¶
Bases: SimpleTagInlineProcessor
Return an element of type tag with no children.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return empty
Elementof typetag.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.BacktickInlineProcessor(pattern: str)
¶
Bases: InlineProcessor
Return a <code> element containing the escaped matching text.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–If the match contains
group(3)of a pattern, then return acode
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.BacktickInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.BacktickInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.BacktickInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.BacktickInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.BacktickInlineProcessor.tag
instance-attribute
¶
The tag of the rendered element.
Defined Value:
self.tag = 'code'
‹›
markdown.inlinepatterns.BacktickInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | str, int, int]
¶
If the match contains group(3) of a pattern, then return a code
Element which contains HTML escaped text (with
code_escape) as an AtomicString.
If the match does not contain group(3) then return the text of group(1) backslash escaped.
‹›
markdown.inlinepatterns.DoubleTagPattern(pattern: str, tag: str)
¶
Bases: SimpleTagPattern
Return a ElementTree element nested in tag2 nested in tag1.
Useful for strong emphasis etc.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return
Elementin following format:
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.DoubleTagPattern.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.DoubleTagPattern.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.DoubleTagPattern.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.DoubleTagPattern.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor(pattern: str, tag: str)
¶
Bases: SimpleTagInlineProcessor
Return a ElementTree element nested in tag2 nested in tag1.
Useful for strong emphasis etc.
Parameters:
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return
Elementin following format:
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
tag–The tag of the rendered element.
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.HtmlInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Store raw inline html and return a placeholder.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
handleMatch–Store the text of
group(1)of a pattern and return a placeholder string. -
unescape–Return unescaped text given text with an inline placeholder.
-
backslash_unescape–Return text with backslash escapes undone (backslashes are restored).
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.HtmlInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.HtmlInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.HtmlInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.HtmlInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[str, int, int]
¶
Store the text of group(1) of a pattern and return a placeholder string.
‹›
markdown.inlinepatterns.AsteriskProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Emphasis processor for handling strong and em matches inside asterisks.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
build_single–Return single tag.
-
build_double–Return double tag.
-
build_double2–Return double tags (variant 2):
<strong>text <em>text</em></strong>. -
parse_sub_patterns–Parses sub patterns.
-
build_element–Element builder.
-
handleMatch–Parse patterns.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
PATTERNS–The various strong and emphasis patterns handled by this processor.
‹›
markdown.inlinepatterns.AsteriskProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.AsteriskProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.AsteriskProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.AsteriskProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.AsteriskProcessor.PATTERNS
class-attribute
instance-attribute
¶
The various strong and emphasis patterns handled by this processor.
Defined Value:
PATTERNS = [
EmStrongItem(re.compile(EM_STRONG_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'),
EmStrongItem(re.compile(STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'),
EmStrongItem(re.compile(STRONG_EM3_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'),
EmStrongItem(re.compile(STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'),
EmStrongItem(re.compile(EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em')
]
‹›
markdown.inlinepatterns.AsteriskProcessor.build_single(m: re.Match[str], tag: str, idx: int) -> etree.Element
¶
Return single tag.
‹›
markdown.inlinepatterns.AsteriskProcessor.build_double(m: re.Match[str], tags: str, idx: int) -> etree.Element
¶
Return double tag.
‹›
markdown.inlinepatterns.AsteriskProcessor.build_double2(m: re.Match[str], tags: str, idx: int) -> etree.Element
¶
Return double tags (variant 2): <strong>text <em>text</em></strong>.
‹›
markdown.inlinepatterns.AsteriskProcessor.parse_sub_patterns(data: str, parent: etree.Element, last: etree.Element | None, idx: int) -> None
¶
Parses sub patterns.
data: text to evaluate.
parent: Parent to attach text and sub elements to.
last: Last appended child to parent. Can also be None if parent has no children.
idx: Current pattern index that was used to evaluate the parent.
‹›
markdown.inlinepatterns.UnderscoreProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: AsteriskProcessor
Emphasis processor for handling strong and em matches inside underscores.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
handleMatch–Parse patterns.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
build_single–Return single tag.
-
build_double–Return double tag.
-
build_double2–Return double tags (variant 2):
<strong>text <em>text</em></strong>. -
parse_sub_patterns–Parses sub patterns.
-
build_element–Element builder.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
-
PATTERNS–The various strong and emphasis patterns handled by this processor.
‹›
markdown.inlinepatterns.UnderscoreProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.UnderscoreProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.UnderscoreProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Parse patterns.
‹›
markdown.inlinepatterns.UnderscoreProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.UnderscoreProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.UnderscoreProcessor.build_single(m: re.Match[str], tag: str, idx: int) -> etree.Element
¶
Return single tag.
‹›
markdown.inlinepatterns.UnderscoreProcessor.build_double(m: re.Match[str], tags: str, idx: int) -> etree.Element
¶
Return double tag.
‹›
markdown.inlinepatterns.UnderscoreProcessor.build_double2(m: re.Match[str], tags: str, idx: int) -> etree.Element
¶
Return double tags (variant 2): <strong>text <em>text</em></strong>.
‹›
markdown.inlinepatterns.UnderscoreProcessor.parse_sub_patterns(data: str, parent: etree.Element, last: etree.Element | None, idx: int) -> None
¶
Parses sub patterns.
data: text to evaluate.
parent: Parent to attach text and sub elements to.
last: Last appended child to parent. Can also be None if parent has no children.
idx: Current pattern index that was used to evaluate the parent.
‹›
markdown.inlinepatterns.UnderscoreProcessor.build_element(m: re.Match[str], builder: str, tags: str, index: int) -> etree.Element
¶
Element builder.
‹›
markdown.inlinepatterns.UnderscoreProcessor.PATTERNS
class-attribute
instance-attribute
¶
The various strong and emphasis patterns handled by this processor.
Defined Value:
PATTERNS = [
EmStrongItem(re.compile(EM_STRONG2_RE, re.DOTALL | re.UNICODE), 'double', 'strong,em'),
EmStrongItem(re.compile(STRONG_EM2_RE, re.DOTALL | re.UNICODE), 'double', 'em,strong'),
EmStrongItem(re.compile(SMART_STRONG_EM_RE, re.DOTALL | re.UNICODE), 'double2', 'strong,em'),
EmStrongItem(re.compile(SMART_STRONG_RE, re.DOTALL | re.UNICODE), 'single', 'strong'),
EmStrongItem(re.compile(SMART_EMPHASIS_RE, re.DOTALL | re.UNICODE), 'single', 'em')
]
‹›
markdown.inlinepatterns.LinkInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Return a link element from the given match.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return an
aElementor(None, None, None). -
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.LinkInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.LinkInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.LinkInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.LinkInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.LinkInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return an a Element or (None, None, None).
‹›
markdown.inlinepatterns.ImageInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: LinkInlineProcessor
Return a img element from the given match.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link -
handleMatch–Return an
imgElementor(None, None, None).
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ImageInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.ImageInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.ImageInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.ImageInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.ImageInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between () of [Text]() allowing recursive ().
‹›
markdown.inlinepatterns.ReferenceInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: LinkInlineProcessor
Match to a stored reference and return link element.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link -
handleMatch–Return
Elementreturned bymakeTagmethod or(None, None, None). -
evalId–Evaluate the id portion of
[ref][id]. -
makeTag–Return an
aElement.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between () of [Text]() allowing recursive ().
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.getText(data: str, index: int) -> tuple[str, int, bool]
¶
Parse the content between [] of the start of an image or link
resolving nested square brackets.
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return Element returned by makeTag method or (None, None, None).
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: ReferenceInlineProcessor
Short form of reference: [google].
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
handleMatch–Return
Elementreturned bymakeTagmethod or(None, None, None). -
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link -
makeTag–Return an
aElement. -
evalId–Evaluate the id of
[ref].
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return Element returned by makeTag method or (None, None, None).
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between () of [Text]() allowing recursive ().
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.getText(data: str, index: int) -> tuple[str, int, bool]
¶
Parse the content between [] of the start of an image or link
resolving nested square brackets.
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: ReferenceInlineProcessor
Match to a stored reference and return img element.
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
handleMatch–Return
Elementreturned bymakeTagmethod or(None, None, None). -
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link -
evalId–Evaluate the id portion of
[ref][id]. -
makeTag–Return an
imgElement.
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return Element returned by makeTag method or (None, None, None).
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between () of [Text]() allowing recursive ().
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.getText(data: str, index: int) -> tuple[str, int, bool]
¶
Parse the content between [] of the start of an image or link
resolving nested square brackets.
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: ImageReferenceInlineProcessor
Short form of image reference: ![ref].
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
handleMatch–Return
Elementreturned bymakeTagmethod or(None, None, None). -
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
getLink–Parse data between
()of[Text]()allowing recursive(). -
getText–Parse the content between
[]of the start of an image or link -
makeTag–Return an
imgElement. -
evalId–Evaluate the id of
[ref].
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return Element returned by makeTag method or (None, None, None).
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between () of [Text]() allowing recursive ().
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.getText(data: str, index: int) -> tuple[str, int, bool]
¶
Parse the content between [] of the start of an image or link
resolving nested square brackets.
‹›
markdown.inlinepatterns.AutolinkInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Return a link Element given an auto-link (<http://example/com>).
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return an
aElementofgroup(1).
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.AutolinkInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.AutolinkInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.AutolinkInlineProcessor.type() -> str
¶
Return class name, to define pattern type
‹›
markdown.inlinepatterns.AutomailInlineProcessor(pattern: str, md: Markdown | None = None)
¶
Bases: InlineProcessor
Return a mailto link Element given an auto-mail link (<foo@example.com>).
Parameters:
-
pattern(str) –A regular expression that matches a pattern.
-
md(Markdown | None, default:None) –An optional pointer to the instance of
markdown.Markdownand is available asself.mdon the class instance.
Methods:
-
getCompiledRegExp–Return a compiled regular expression.
-
type–Return class name, to define pattern type
-
unescape–Return unescaped text given text with an inline placeholder.
-
handleMatch–Return an
Elementcontaining amailtolink ofgroup(1).
Attributes:
-
ANCESTOR_EXCLUDES(Collection[str]) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.AutomailInlineProcessor.ANCESTOR_EXCLUDES: Collection[str]
class-attribute
instance-attribute
¶
A collection of elements which are undesirable ancestors. The processor will be skipped if it would cause the content to be a descendant of one of the listed tag names.
Defined Value:
ANCESTOR_EXCLUDES: Collection[str] = tuple()
‹›
markdown.inlinepatterns.AutomailInlineProcessor.getCompiledRegExp() -> re.Pattern
¶
Return a compiled regular expression.
‹›
markdown.inlinepatterns.AutomailInlineProcessor.type() -> str
¶
Return class name, to define pattern type

