You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/01/15 11:13:37 UTC

[airflow] branch master updated: Support tables in DAG docs (#13533)

This is an automated email from the ASF dual-hosted git repository.

kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 3558538  Support tables in DAG docs (#13533)
3558538 is described below

commit 3558538883612a10e9ea3521bf864515b6e560c5
Author: Jyoti Dhiman <36...@users.noreply.github.com>
AuthorDate: Fri Jan 15 16:43:22 2021 +0530

    Support tables in DAG docs (#13533)
---
 airflow/www/utils.py    |  2 +-
 tests/www/test_utils.py | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/airflow/www/utils.py b/airflow/www/utils.py
index d1c37f1..265a12f 100644
--- a/airflow/www/utils.py
+++ b/airflow/www/utils.py
@@ -326,7 +326,7 @@ def wrapped_markdown(s, css_class=None):
     if s is None:
         return None
 
-    return Markup(f'<div class="{css_class}" >' + markdown.markdown(s) + "</div>")
+    return Markup(f'<div class="{css_class}" >' + markdown.markdown(s, extensions=['tables']) + "</div>")
 
 
 # pylint: disable=no-member
diff --git a/tests/www/test_utils.py b/tests/www/test_utils.py
index f21a64c..b5088f4 100644
--- a/tests/www/test_utils.py
+++ b/tests/www/test_utils.py
@@ -237,3 +237,20 @@ class TestWrappedMarkdown(unittest.TestCase):
 <strong>bold</strong></p></div>''',
             rendered,
         )
+
+    def test_wrapped_markdown_with_table(self):
+        rendered = wrapped_markdown(
+            """| Job | Duration |
+               | ----------- | ----------- |
+               | ETL | 14m |"""
+        )
+
+        self.assertEqual(
+            (
+                '<div class="None" ><table>\n<thead>\n<tr>\n<th>Job</th>\n'
+                '<th>Duration</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>ETL'
+                '</td>\n<td>14m</td>\n</tr>\n</tbody>\n'
+                '</table></div>'
+            ),
+            rendered,
+        )