traitement des urls
This commit is contained in:
parent
3317bb7de6
commit
9859ec4f63
3 changed files with 24 additions and 7 deletions
|
@ -38,3 +38,17 @@ run:
|
|||
artifacts:
|
||||
paths:
|
||||
- dist/*
|
||||
|
||||
release_job:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG # Run this job when a tag is created manually
|
||||
script:
|
||||
- echo "Running the release job."
|
||||
release:
|
||||
tag_name: $CI_COMMIT_TAG
|
||||
name: 'Release $CI_COMMIT_TAG'
|
||||
description: 'Release created using the release-cli.'
|
||||
assets:
|
||||
- name:
|
|
@ -8,7 +8,7 @@ License:
|
|||
import re
|
||||
|
||||
|
||||
def replace_title_with_list(text: str) -> str:
|
||||
def replace_title_with_list(text: str, depth=2) -> str:
|
||||
r"""Replace all titles in the text with a numbered list.
|
||||
|
||||
The titles are defined by a hashtag symbol followed by one or more
|
||||
|
@ -37,8 +37,8 @@ def replace_title_with_list(text: str) -> str:
|
|||
matches = re.findall(pattern, text, re.MULTILINE)
|
||||
for match in matches:
|
||||
nb_hashtag = len(match)
|
||||
if nb_hashtag > 1:
|
||||
text = re.sub(match, ' ' * (nb_hashtag-1)+'-', text, count=1)
|
||||
if nb_hashtag >= depth:
|
||||
text = re.sub(match, ' ' * (nb_hashtag-depth)+'-', text, count=1)
|
||||
text = re.sub('\n\n', '\n', text)
|
||||
pattern_url = \
|
||||
r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"
|
||||
|
|
|
@ -3,8 +3,11 @@ from markdown_fix_freeplane.markdown_utils import replace_title_with_list
|
|||
|
||||
def test_replace_title_with_list():
|
||||
assert (replace_title_with_list(
|
||||
'# This is a title\n# Another title') ==
|
||||
'- This is a title\n- Another title')
|
||||
'# This is a title\n# Another title', depth=2) ==
|
||||
'# This is a title\n# Another title')
|
||||
assert (replace_title_with_list(
|
||||
'# This is a title\n## Another title') ==
|
||||
'- This is a title\n - Another title')
|
||||
'# This is a title\n## Another title', depth=2) ==
|
||||
'# This is a title\n- Another title')
|
||||
assert (replace_title_with_list(
|
||||
'# This is a title\n## Another title\n### Yet another title', depth=2) ==
|
||||
'# This is a title\n- Another title\n - Yet another title')
|
||||
|
|
Loading…
Reference in a new issue