diff --git a/runbot/common.py b/runbot/common.py
index 9360883d..b66f1bcf 100644
--- a/runbot/common.py
+++ b/runbot/common.py
@@ -212,8 +212,15 @@ def pseudo_markdown(text):
text = re_icon.sub('', text)
# links
- re_links = re.compile(rf'{escape}\[(.+?){escape}\]{escape}\(((http|/).+?{escape})\)')
- text = re_links.sub('\\g<1>', text)
+ re_links = re.compile(
+ rf'{escape}\[(?P.+?){escape}\]{escape}\((?P(?:http|\/).+?{escape})(?: (?P\w+))?\)'
+ )
+ def compile_url(match):
+ groups = match.groupdict()
+ target = groups.get('target')
+ target_tag = f' target="{target}"' if target else ''
+ return f'{groups["name"]}'
+ text = re_links.sub(compile_url, text)
def code_replace(match):
return f'{codes[int(match.group(1))]}
'
diff --git a/runbot/tests/__init__.py b/runbot/tests/__init__.py
index e4410f29..f21d1caf 100644
--- a/runbot/tests/__init__.py
+++ b/runbot/tests/__init__.py
@@ -16,3 +16,4 @@ from . import test_commit
from . import test_upgrade
from . import test_dockerfile
from . import test_host
+from . import test_utils
diff --git a/runbot/tests/test_build_config_step.py b/runbot/tests/test_build_config_step.py
index a5e29b01..a0ec2f0e 100644
--- a/runbot/tests/test_build_config_step.py
+++ b/runbot/tests/test_build_config_step.py
@@ -209,7 +209,6 @@ class TestCodeowner(TestBuildConfigStepCommon):
])
self.config_step._run_codeowner(self.parent_build)
logs = self.parent_build.log_ids
- print
self.assertEqual(
logs[2]._markdown(),
'Adding team_01, team_py to reviewers for file server/core/addons/module1/some/__init__.py',
diff --git a/runbot/tests/test_utils.py b/runbot/tests/test_utils.py
new file mode 100644
index 00000000..9712bb17
--- /dev/null
+++ b/runbot/tests/test_utils.py
@@ -0,0 +1,49 @@
+from odoo.tests.common import TransactionCase, Like
+
+from odoo.addons.runbot.common import pseudo_markdown
+
+
+class TestUtils(TransactionCase):
+
+ def test_md_formatting(self):
+ self.assertEqual(
+ pseudo_markdown(
+ "**strong** ~~delete~~ __italic__ \n"
+ ),
+ "strong "
+ "delete "
+ "italic "
+ "
\n"
+ )
+
+ def test_md_icons(self):
+ self.assertEqual(
+ pseudo_markdown(
+ "@icon-star"
+ ),
+ ''
+ )
+
+ def test_md_urls(self):
+ # Basic
+ self.assertEqual(
+ pseudo_markdown(
+ "[name](https://runbot.odoo.com)"
+ ),
+ 'name'
+ )
+ # Test with target
+ self.assertEqual(
+ pseudo_markdown(
+ "[name](https://runbot.odoo.com fp)"
+ ),
+ 'name'
+ )
+
+ # Everything at once
+ self.assertEqual(
+ pseudo_markdown(
+ "[@icon-star](https://runbot.odoo.com _blank)"
+ ),
+ ''
+ )