You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/05/28 12:34:10 UTC

[GitHub] [airflow] sweco opened a new issue #16138: doc_md code block collapsing lines

sweco opened a new issue #16138:
URL: https://github.com/apache/airflow/issues/16138


   **Apache Airflow version**: 2.0.0 - 2.1.0
   
   **Kubernetes version**: N/A
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: Docker on MacOS (but also AWS ECS deployed)
   - **OS** (e.g. from /etc/os-release): MacOS Big Sur 11.3.1
   - **Kernel** (e.g. `uname -a`): Darwin Kernel Version 20.4.0
   - **Install tools**:
   - **Others**:
   
   **What happened**:
   
   When a code block is a part of a DAG's `doc_md`, it does not render correctly in the Web UI, but collapses all the lines into one line instead.
   
   **What you expected to happen**:
   
   The multi line code block be rendered with line breaks preserved.
   
   **How to reproduce it**:
   Create a DAG with `doc_md` containing a code block:
   
   ````python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
   ```
   Code block
   does not
   respect
   newlines
   ```
   """
   
   dag = DAG(
       dag_id='test',
       doc_md=DOC_MD
   )
   ````
   
   The rendered documentation looks like this:
   <img src="https://user-images.githubusercontent.com/11132999/119981579-19a70600-bfbe-11eb-8036-7d981ae1f232.png" width="50%"/>
   
   **Anything else we need to know**: N/A
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851258391


   I will look into this @kaxil 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk closed issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #16138:
URL: https://github.com/apache/airflow/issues/16138


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy edited a comment on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy edited a comment on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851401276


   @sweco to create a code block, you have to leave a blank line between each line. See [PEP 257](https://www.python.org/dev/peps/pep-0257/) and [Markdown guidelines](https://www.markdownguide.org/basic-syntax/) for more details.
   
   This is how I did it:
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       Code block
   
       <s>does not</s> now
   
       respect
   
       newlines
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc-2](https://user-images.githubusercontent.com/9834450/120181457-63396000-c20d-11eb-9818-25e050804ab2.png)
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       `Code block`
   
      <s>`does not`</s> `now`
   
       `respect`
   
       `newlines`
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc](https://user-images.githubusercontent.com/9834450/120181913-fa9eb300-c20d-11eb-868f-e710501cd264.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy edited a comment on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy edited a comment on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851401276


   @sweco to create a code block, you have to leave a blank line between each line. See [PEP 257](https://www.python.org/dev/peps/pep-0257/) and [Markdown guidelines](https://www.markdownguide.org/basic-syntax/) for more details.
   
   This is how I did it:
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       Code block
   
       <del>does not</del> now
   
       respect
   
       newlines
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc-2](https://user-images.githubusercontent.com/9834450/120181457-63396000-c20d-11eb-9818-25e050804ab2.png)
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       `Code block`
   
      <del>`does not`</del> `now`
   
       `respect`
   
       `newlines`
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc](https://user-images.githubusercontent.com/9834450/120181913-fa9eb300-c20d-11eb-868f-e710501cd264.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy edited a comment on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy edited a comment on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851401276


   @sweco to create a code block, you have to leave a blank line between each line. See [PEP 257](https://www.python.org/dev/peps/pep-0257/) and [Markdown guidelines](https://www.markdownguide.org/basic-syntax/) for more details.
   
   This is how I did it:
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       Code block
   
       does 
   
       respect
   
       newlines
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc-2](https://user-images.githubusercontent.com/9834450/120181457-63396000-c20d-11eb-9818-25e050804ab2.png)
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       `Code block`
   
      `does`
   
       `respect`
   
       `newlines`
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc](https://user-images.githubusercontent.com/9834450/120181913-fa9eb300-c20d-11eb-868f-e710501cd264.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851404403


   @kaxil consider closing this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-850386672


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] Dr-Denzy commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
Dr-Denzy commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851401276


   @sweco to create a code block, you have to leave a blank line between each line. See [PEP 257](https://www.python.org/dev/peps/pep-0257/) and [Markdown guidelines](https://www.markdownguide.org/basic-syntax/) for more details.
   
   This is how I did it:
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       Code block
   
       ~~does not~~ now
   
       respect
   
       newlines
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc-2](https://user-images.githubusercontent.com/9834450/120181457-63396000-c20d-11eb-9818-25e050804ab2.png)
   
   ```python
   from airflow import DAG
   
   DOC_MD = """\
   # Markdown code block
   
   Inline `code` works well.
   
       `Code block`
   
       ~~` does not`~~ `now`
   
       `respect`
   
       `newlines`
   
   """
   
   dag = DAG(
       dag_id='md-doc',
       doc_md=DOC_MD
   )
   
   ```
   ![md-doc](https://user-images.githubusercontent.com/9834450/120181913-fa9eb300-c20d-11eb-868f-e710501cd264.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] uranusjr commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
uranusjr commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851688673


   The cause is [the Markdown-HTML rendering function](https://github.com/apache/airflow/blob/9c8391a13f6ba29749675cf23f2f874f96b0cc8c/airflow/www/utils.py#L343-L350) uses `lstrip()`, so all leading indentations are just gone. It should be modified to use a more sophisticated method, such as `textwrap.dedent()` (I didn’t think entirely though whether changing to the function would just work).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] sweco commented on issue #16138: doc_md code block collapsing lines

Posted by GitBox <gi...@apache.org>.
sweco commented on issue #16138:
URL: https://github.com/apache/airflow/issues/16138#issuecomment-851416191


   Hey @Dr-Denzy, thank you for looking into this, but I believe that what you managed to produce are not multi-line code blocks but rather:
   
   - In the first case just regular paragraphs
   - In the second case, regular paragraphs each with inline (one-line) code
   
   If I'm right, these are not code blocks. According to the Markdown Guide, you can create a code block in two ways: [classic code block](https://www.markdownguide.org/basic-syntax/#code-blocks) and [fenced code block](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks).
   
   ### Classic code block
   
   A classic code block is created by indenting a block by 4 spaces (Bitbucket requires this to be 8 spaces), but it does not seem to work with either 4 or 8 spaces.
   
   ```python
   DOC_MC = """\
   # Markdown code block
   
   Inline `code` works well.
   
       Code block
       does not
       respect
       newlines
   
   """
   ```
   
   Normally this would look as in the Markdown guide, but Airflow just creates a normal paragraph.
   
   <img width="40%" src="https://user-images.githubusercontent.com/11132999/120184077-d7293780-c210-11eb-9505-e43a9c8a64db.png" />
   
   ### Fenced code block
   Created by delimiting the code block by three backticks (that's what I used in the first example):
   
   ````python
   DOC_MC = """\
   # Markdown code block
   
   Inline `code` works well.
   
   ```
   Code block
   does not
   respect
   newlines
   ```
   """
   ````
   
   This creates a `code` element in the HTML DOM but it joins the lines:
   <img width="40%" src="https://user-images.githubusercontent.com/11132999/120184471-50288f00-c211-11eb-86b2-92bc53dcf076.png" />
   <img width="40%" src="https://user-images.githubusercontent.com/11132999/120184765-a39add00-c211-11eb-8c9a-e63b818842d8.png" />


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org