From 5c36ac7bfb45bb660d01c71a61da6279628141c4 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:33:47 +0000 Subject: [PATCH 1/2] Fix multi-line links and incorrect dunder escapes in code --- docstring_to_markdown/__init__.py | 2 +- docstring_to_markdown/rst.py | 8 ++++---- tests/test_rst.py | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docstring_to_markdown/__init__.py b/docstring_to_markdown/__init__.py index 317c724..62fa804 100644 --- a/docstring_to_markdown/__init__.py +++ b/docstring_to_markdown/__init__.py @@ -3,7 +3,7 @@ from .plain import looks_like_plain_text, plain_text_to_markdown from .rst import looks_like_rst, rst_to_markdown -__version__ = "0.14" +__version__ = "0.15" class UnknownFormatError(Exception): diff --git a/docstring_to_markdown/rst.py b/docstring_to_markdown/rst.py index 174f9de..ba50d91 100644 --- a/docstring_to_markdown/rst.py +++ b/docstring_to_markdown/rst.py @@ -1,13 +1,13 @@ from abc import ABC, abstractmethod from enum import IntEnum, auto from types import SimpleNamespace -from typing import Union, List, Dict +from typing import Callable, Match, Union, List, Dict import re class Directive: def __init__( - self, pattern: str, replacement: str, + self, pattern: str, replacement: Union[str, Callable[[Match], str]], name: Union[str, None] = None, flags: int = 0 ): @@ -249,7 +249,7 @@ def inline_markdown(self): ), Directive( pattern=r'`(?P