-
-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathasciidoc.py
More file actions
28 lines (20 loc) · 754 Bytes
/
asciidoc.py
File metadata and controls
28 lines (20 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations
import re
from typing import TYPE_CHECKING
from .base import BaseFormat
if TYPE_CHECKING:
from commitizen.tags import VersionTag
class AsciiDoc(BaseFormat):
extension = "adoc"
RE_TITLE = re.compile(r"^(?P<level>=+) (?P<title>.*)$")
def parse_version_from_title(self, line: str) -> VersionTag | None:
m = self.RE_TITLE.match(line)
if not m:
return None
# Capture last match as AsciiDoc use postfixed URL labels
return self.tag_rules.search_version(m.group("title"), last=True)
def parse_title_level(self, line: str) -> int | None:
m = self.RE_TITLE.match(line)
if not m:
return None
return len(m.group("level"))