Skip to content

Commit

Permalink
Merge pull request #30 from hoefling/enable-directive-regex-flags
Browse files Browse the repository at this point in the history
Respect directive regex flags
  • Loading branch information
krassowski committed Mar 21, 2023
2 parents cceaeab + 3e332ee commit aa851a3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11']

os: [ubuntu-latest]
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
include:
- os: ubuntu-20.04
python-version: 3.6
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion docstring_to_markdown/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def looks_like_rst(value: str) -> bool:
if (section + '\n' + '-' * len(section) + '\n') in value:
return True
for directive in RST_DIRECTIVES:
if re.search(directive.pattern, value):
if re.search(directive.pattern, value, directive.flags):
return True
# allow "text::" or "text ::" but not "^::$" or "^:::$"
return bool(re.search(r'(\s|\w)::\n', value) or '\n>>> ' in value)
Expand Down
1 change: 1 addition & 0 deletions tests/test_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ def test_looks_like_rst_recognises_rst():
assert looks_like_rst('the following code::\n\n\tcode')
assert looks_like_rst('See Also\n--------\n')
assert looks_like_rst('.. versionadded:: 0.1')
assert looks_like_rst('Description.\n\n:param spam: eggs.\n')


def test_looks_like_rst_ignores_plain_text():
Expand Down

0 comments on commit aa851a3

Please sign in to comment.