‹›
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 returnedMatch
object will only contain what is explicitly matched in the pattern, and extension pattern groups now start withm.group(1)
. -
The
handleMatch
method 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 todata
that 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.
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
tag
with a text attribute ofgroup(3)
-
SimpleTagInlineProcessor
–Return element of type
tag
with a text attribute ofgroup(2)
-
SubstituteTagPattern
–Return an element of type
tag
with no children. -
SubstituteTagInlineProcessor
–Return an element of type
tag
with 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
img
element 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
img
element. -
ShortImageReferenceInlineProcessor
–Short form of image reference:
![ref]
. -
AutolinkInlineProcessor
–Return a link Element given an auto-link (
<http://example/com>
). -
AutomailInlineProcessor
–Return a
mailto
link 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][^<>@ ]*( [^<>]*)?|' # Tag
r'!--(?:(?!<!--|-->).)*--|' # Comment
r'[?](?:(?!<[?]|[?]>).)*[?]|' # Processing instruction
r'!\[CDATA\[(?:(?!<!\[CDATA\[|\]\]>).)*\]\]' # `CDATA`
')>)'
)
‹›
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.Markdown
and is available asself.md
on 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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return a ElementTree element from the given match and the
-
getCompiledRegExp
–Return a compiled regular expression.
-
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.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.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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return string content of
group(2)
of a matching pattern. -
getCompiledRegExp
–Return a compiled regular expression.
-
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.SimpleTextPattern.handleMatch(m: re.Match[str]) -> str
¶
Return string content of group(2)
of a matching pattern.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return string content of
group(1)
of a matching pattern. -
getCompiledRegExp
–Return a compiled regular expression.
-
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.SimpleTextInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[str, int, int]
¶
Return string content of group(1)
of a matching pattern.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–If the character matched by
group(1)
of a pattern is inESCAPED_CHARS
-
getCompiledRegExp
–Return a compiled regular expression.
-
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.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.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.SimpleTagPattern(pattern: str, tag: str)
¶
Bases: Pattern
Return element of type tag
with a text attribute of group(3)
of a Pattern.
Parameters:
Methods:
-
handleMatch
–Return
Element
of typetag
with the string ingroup(3)
of a -
getCompiledRegExp
–Return a compiled regular expression.
-
type
–Return class name, to define pattern type
-
unescape
–Return unescaped text given text with an inline placeholder.
Attributes:
-
tag
–The tag of the rendered element.
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.SimpleTagPattern.tag
instance-attribute
¶
The tag of the rendered element.
Defined Value:
self.tag = tag
‹›
markdown.inlinepatterns.SimpleTagPattern.handleMatch(m: re.Match[str]) -> etree.Element
¶
Return Element
of type tag
with the string in group(3)
of a
matching pattern as the Element’s text.
‹›
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.SimpleTagInlineProcessor(pattern: str, tag: str)
¶
Bases: InlineProcessor
Return element of type tag
with a text attribute of group(2)
of a Pattern.
Parameters:
Methods:
-
handleMatch
–Return
Element
of typetag
with the string ingroup(2)
of a -
getCompiledRegExp
–Return a compiled regular expression.
-
type
–Return class name, to define pattern type
-
unescape
–Return unescaped text given text with an inline placeholder.
Attributes:
-
tag
–The tag of the rendered element.
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.tag
instance-attribute
¶
The tag of the rendered element.
Defined Value:
self.tag = tag
‹›
markdown.inlinepatterns.SimpleTagInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element, int, int]
¶
Return Element
of type tag
with the string in group(2)
of a
matching pattern as the Element’s text.
‹›
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.SubstituteTagPattern(pattern: str, tag: str)
¶
Bases: SimpleTagPattern
Return an element of type tag
with no children.
Parameters:
Methods:
-
handleMatch
–Return empty
Element
of typetag
. -
getCompiledRegExp
–Return a compiled regular expression.
-
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
-
tag
–The tag of the rendered element.
‹›
markdown.inlinepatterns.SubstituteTagPattern.handleMatch(m: re.Match[str]) -> etree.Element
¶
Return empty Element
of type tag
.
‹›
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.SubstituteTagInlineProcessor(pattern: str, tag: str)
¶
Bases: SimpleTagInlineProcessor
Return an element of type tag
with no children.
Parameters:
Methods:
-
handleMatch
–Return empty
Element
of typetag
. -
getCompiledRegExp
–Return a compiled regular expression.
-
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
-
tag
–The tag of the rendered element.
‹›
markdown.inlinepatterns.SubstituteTagInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element, int, int]
¶
Return empty Element
of type tag
.
‹›
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.BacktickInlineProcessor(pattern: str)
¶
Bases: InlineProcessor
Return a <code>
element containing the escaped matching text.
Methods:
-
handleMatch
–If the match contains
group(3)
of a pattern, then return acode
-
getCompiledRegExp
–Return a compiled regular expression.
-
type
–Return class name, to define pattern type
-
unescape
–Return unescaped text given text with an inline placeholder.
Attributes:
-
tag
–The tag of the rendered element.
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
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.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.DoubleTagPattern(pattern: str, tag: str)
¶
Bases: SimpleTagPattern
Return a ElementTree element nested in tag2 nested in tag1.
Useful for strong emphasis etc.
Parameters:
Methods:
-
handleMatch
–Return
Element
in following format: -
getCompiledRegExp
–Return a compiled regular expression.
-
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
-
tag
–The tag of the rendered element.
‹›
markdown.inlinepatterns.DoubleTagPattern.handleMatch(m: re.Match[str]) -> etree.Element
¶
Return Element
in following format:
<tag1><tag2>group(3)</tag2>group(4)</tag2>
where group(4)
is optional.
‹›
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.DoubleTagInlineProcessor(pattern: str, tag: str)
¶
Bases: SimpleTagInlineProcessor
Return a ElementTree element nested in tag2 nested in tag1.
Useful for strong emphasis etc.
Parameters:
Methods:
-
handleMatch
–Return
Element
in following format: -
getCompiledRegExp
–Return a compiled regular expression.
-
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
-
tag
–The tag of the rendered element.
‹›
markdown.inlinepatterns.DoubleTagInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element, int, int]
¶
Return Element
in following format:
<tag1><tag2>group(2)</tag2>group(3)</tag2>
where group(3)
is optional.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
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).
-
getCompiledRegExp
–Return a compiled regular expression.
-
type
–Return class name, to define pattern type
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
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.HtmlInlineProcessor.unescape(text: str) -> str
¶
Return unescaped text given text with an inline placeholder.
‹›
markdown.inlinepatterns.HtmlInlineProcessor.backslash_unescape(text: str) -> str
¶
Return text with backslash escapes undone (backslashes are restored).
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
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.
-
getCompiledRegExp
–Return a compiled regular expression.
-
type
–Return class name, to define pattern type
-
unescape
–Return unescaped text given text with an inline placeholder.
Attributes:
-
PATTERNS
–The various strong and emphasis patterns handled by this processor.
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
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.AsteriskProcessor.build_element(m: re.Match[str], builder: str, tags: str, index: int) -> etree.Element
¶
Element builder.
‹›
markdown.inlinepatterns.AsteriskProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Parse patterns.
‹›
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.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.Markdown
and is available asself.md
on 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:
-
PATTERNS
–The various strong and emphasis patterns handled by this processor.
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
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.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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return an
a
Element
or(None, None, None)
. -
getLink
–Parse data between
()
of[Text]()
allowing recursive()
. -
getText
–Parse the content between
[]
of the start of an image or link -
getCompiledRegExp
–Return a compiled regular expression.
-
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.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.LinkInlineProcessor.getLink(data: str, index: int) -> tuple[str, str | None, int, bool]
¶
Parse data between ()
of [Text]()
allowing recursive ()
.
‹›
markdown.inlinepatterns.LinkInlineProcessor.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.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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return an
img
Element
or(None, None, None)
. -
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
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ImageInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element | None, int | None, int | None]
¶
Return an img
Element
or (None, None, None)
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return
Element
returned bymakeTag
method or(None, None, None)
. -
evalId
–Evaluate the id portion of
[ref][id]
. -
makeTag
–Return an
a
Element
. -
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
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
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.ReferenceInlineProcessor.evalId(data: str, index: int, text: str) -> tuple[str | None, int, bool]
¶
Evaluate the id portion of [ref][id]
.
If [ref][]
use [ref]
.
‹›
markdown.inlinepatterns.ReferenceInlineProcessor.makeTag(href: str, title: str, text: str) -> etree.Element
¶
Return an a
Element
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
evalId
–Evaluate the id of
[ref]
. -
getCompiledRegExp
–Return a compiled regular expression.
-
handleMatch
–Return
Element
returned bymakeTag
method 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
a
Element
.
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ShortReferenceInlineProcessor.evalId(data: str, index: int, text: str) -> tuple[str, int, bool]
¶
Evaluate the id of [ref]
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
makeTag
–Return an
img
Element
. -
getCompiledRegExp
–Return a compiled regular expression.
-
handleMatch
–Return
Element
returned bymakeTag
method 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]
.
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ImageReferenceInlineProcessor.makeTag(href: str, title: str, text: str) -> etree.Element
¶
Return an img
Element
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
evalId
–Evaluate the id of
[ref]
. -
getCompiledRegExp
–Return a compiled regular expression.
-
handleMatch
–Return
Element
returned bymakeTag
method 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
img
Element
.
Attributes:
-
ANCESTOR_EXCLUDES
(Collection[str]
) –A collection of elements which are undesirable ancestors. The processor will be skipped if it
‹›
markdown.inlinepatterns.ShortImageReferenceInlineProcessor.evalId(data: str, index: int, text: str) -> tuple[str, int, bool]
¶
Evaluate the id of [ref]
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return an
a
Element
ofgroup(1)
. -
getCompiledRegExp
–Return a compiled regular expression.
-
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.AutolinkInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element, int, int]
¶
Return an a
Element
of group(1)
.
‹›
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.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.Markdown
and is available asself.md
on the class instance.
Methods:
-
handleMatch
–Return an
Element
containing amailto
link ofgroup(1)
. -
getCompiledRegExp
–Return a compiled regular expression.
-
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.AutomailInlineProcessor.handleMatch(m: re.Match[str], data: str) -> tuple[etree.Element, int, int]
¶
Return an Element
containing a mailto
link of group(1)
.
‹›
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.