Skip to content

Instantly share code, notes, and snippets.

@mbigras
Last active August 17, 2025 16:27
Show Gist options
  • Save mbigras/9fb38cd4e81a55a9c6b72dd7c8adc07c to your computer and use it in GitHub Desktop.
Save mbigras/9fb38cd4e81a55a9c6b72dd7c8adc07c to your computer and use it in GitHub Desktop.

Revisions

  1. mbigras revised this gist Nov 4, 2024. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -1,55 +1,55 @@
    # Nested code blocks

    > Nested code blocks clarify technical documentation but rendering them with markdown is tricky.
    > Nested code blocks organize technical documentation; but rendering them in Markdown is tricky. Luckily GitHub worked around the vague specification by making 4 space indentation "just work".
    ## Overview

    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating that format with markdown is tricky.
    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating that format in Markdown is tricky.

    The following are the main features about GCP documentation that I like:
    The following are the main organizational and formatting features about GCP documentation which I like:

    1. Headings name a procedure.
    1. Numerical lists describe the ordered steps of a procedure.
    1. Nested code blocks illustrate commands in a step.
    1. Nested bullets and/or nested paragraphs add relevant details about a given step.

    The important technique is _nesting_. When you nest your steps, commands, and details you organize complicated procedures as clear and manageable chunks. But problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 3 spaces of indentation and code fences.
    The most important technique is _nesting_. When you nest your steps, commands, and details, you organize complicated procedures into clear and manageable chunks. But problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 4 spaces of indentation and code fences.

    ## GCP example

    Consider the following example from the [Using Pub/Sub with Cloud Run tutorial](https://cloud.google.com/run/docs/tutorials/pubsub#setting-up-gcloud):
    Consider the following example from [Using Pub/Sub with Cloud Run tutorial](https://cloud.google.com/run/docs/tutorials/pubsub#setting-up-gcloud) page:

    ### Set up gcloud defaults

    To configure `gcloud` with defaults for your Cloud Run service:

    1. Set your default project:

    ```
    gcloud config set project $PROJECT_ID
    ```
    ```
    gcloud config set project $PROJECT_ID
    ```
    Replace `$PROJECT_ID` with the name of the project you created for this tutorial.
    Replace `$PROJECT_ID` with the name of the project you created for this tutorial.
    1. If you are using Cloud Run (fully managed), configure `gcloud` for your chosen region:
    ```
    gcloud config set run/region $REGION
    ```
    ```
    gcloud config set run/region $REGION
    ```
    Replace `$REGION` with the supported Cloud Run region of your choice.
    Replace `$REGION` with the supported Cloud Run region of your choice.
    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    Replace the following:
    Replace the following:
    1. `$CLUSTER_NAME` with the name you used for your cluster
    1. `$REGION` with the supported cluster location of your choice
    1. `$CLUSTER_NAME` with the name you used for your cluster
    1. `$REGION` with the supported cluster location of your choice
    ## Discussion
    @@ -63,4 +63,4 @@ The procedure is clear and ergonomic for readers for the following reasons:
    ## Implementation
    Sadly, this nested format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 3 spaces of indentation and code fences.
    Rendering nested code blocks in Markdown used to be really difficult; but luckily GitHub worked around the vague specification by making 4 space indentation "just work".
  2. mbigras revised this gist Apr 26, 2023. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,12 @@ Google Cloud Platform (GCP) technical documentation is formatted well enough; ho

    The following are the main features about GCP documentation that I like:

    * Headings name a procedure.
    * Numerical lists describe the ordered steps of a procedure.
    * Nested code blocks illustrate commands in a step.
    * Nested bullets and/or nested paragraphs add relevant details about a given step.
    1. Headings name a procedure.
    1. Numerical lists describe the ordered steps of a procedure.
    1. Nested code blocks illustrate commands in a step.
    1. Nested bullets and/or nested paragraphs add relevant details about a given step.

    The important technique is _nesting_. When you nest your steps, commands, and details you organize complicated procedures as clear and manageable chunks.
    The important technique is _nesting_. When you nest your steps, commands, and details you organize complicated procedures as clear and manageable chunks. But problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 3 spaces of indentation and code fences.

    ## GCP example

    @@ -48,18 +48,18 @@ To configure `gcloud` with defaults for your Cloud Run service:

    Replace the following:

    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    1. `$CLUSTER_NAME` with the name you used for your cluster
    1. `$REGION` with the supported cluster location of your choice

    ## Discussion

    The procedure is clear and ergonomic for readers for the following reasons:

    * Foremost, the procedure is organized into manageable steps. Sometimes multiple commands belong in one step. The nested code blocks handle the situation fine.
    * Copy and paste is easy. I can select all or double click on a given command to copy and paste into my terminal.
    * There are no additional spaces or comments in the code blocks.
    * The variables are clear.
    * The difference between the description of a step, the actual command to run, and important details is clear.
    1. Foremost, the procedure is organized into manageable steps. Sometimes multiple commands belong in one step. The nested code blocks handle the situation fine.
    1. Copy and paste is easy. I can select all or double click on a given command to copy and paste into my terminal.
    1. There are no additional spaces or comments in the code blocks.
    1. The variables are clear.
    1. The difference between the description of a step, the actual command to run, and important details is clear.

    ## Implementation

  3. Max Bigras revised this gist Jul 19, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    ## Overview

    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating that GCP format with markdown is tricky.
    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating that format with markdown is tricky.

    The following are the main features about GCP documentation that I like:

  4. Max Bigras revised this gist Jul 19, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Nested code blocks

    > Nested code blocks clarify technical documentation but rendering nest code blocks with markdown is tricky.
    > Nested code blocks clarify technical documentation but rendering them with markdown is tricky.
    ## Overview

  5. Max Bigras revised this gist Jul 19, 2022. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,19 @@
    # Nested code blocks

    > Use nested code blocks for clear technical documentation.
    > Nested code blocks clarify technical documentation but rendering nest code blocks with markdown is tricky.
    ## Overview

    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating it with markdown is tricky.
    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating that GCP format with markdown is tricky.

    The following are the main features I like:
    The following are the main features about GCP documentation that I like:

    * Headings name a procdure
    * Numbered lists describe steps in a procedure
    * Nested code blocks illustrate commands in a given step
    * Nested bullets and/or nested paragraphs add important points about a given step
    * Headings name a procedure.
    * Numerical lists describe the ordered steps of a procedure.
    * Nested code blocks illustrate commands in a step.
    * Nested bullets and/or nested paragraphs add relevant details about a given step.

    The important technique is: _nesting_. Nesting steps, commands, and details organizes complicated procedures into clear chunks.
    The important technique is _nesting_. When you nest your steps, commands, and details you organize complicated procedures as clear and manageable chunks.

    ## GCP example

  6. Max Bigras revised this gist Mar 18, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Nested Code Blocks
    # Nested code blocks

    > Use nested code blocks for clear technical documentation.
    @@ -15,11 +15,11 @@ The following are the main features I like:

    The important technique is: _nesting_. Nesting steps, commands, and details organizes complicated procedures into clear chunks.

    ## GCP Example
    ## GCP example

    Consider the following example from the [Using Pub/Sub with Cloud Run tutorial](https://cloud.google.com/run/docs/tutorials/pubsub#setting-up-gcloud):

    ### Setting up gcloud defaults
    ### Set up gcloud defaults

    To configure `gcloud` with defaults for your Cloud Run service:

  7. Max Bigras revised this gist Dec 11, 2021. 1 changed file with 0 additions and 31 deletions.
    31 changes: 0 additions & 31 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -64,34 +64,3 @@ The procedure is clear and ergonomic for readers for the following reasons:
    ## Implementation

    Sadly, this nested format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 3 spaces of indentation and code fences.

    Consider this markdown source:

    ```
    1. If you are using Cloud Run (fully managed), configure gcloud for your chosen region:
    ```
    gcloud config set run/region $REGION
    ```
    Replace `$REGION` with the supported Cloud Run region of your choice.
    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    Replace the following:
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    ```

    The following points are important:

    * Use the number `1.` for numbered lists because it makes adding new steps easier.
    * Use a newline, 3 spaces for indendation, and code fences for nested code blocks.
    * It's not clear why 3 spaces instead of 4 spaces or a tab. Sometimes 4 or a tab will cause a space to appear in front of all the commands like ` echo foo`.
    * Use a newline and 3 spaces for indentation for nested lists and/or paragraphs.
  8. Max Bigras revised this gist Apr 14, 2021. 1 changed file with 30 additions and 29 deletions.
    59 changes: 30 additions & 29 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -25,31 +25,31 @@ To configure `gcloud` with defaults for your Cloud Run service:

    1. Set your default project:

    ```
    gcloud config set project $PROJECT_ID
    ```
    ```
    gcloud config set project $PROJECT_ID
    ```

    Replace `$PROJECT_ID` with the name of the project you created for this tutorial.
    Replace `$PROJECT_ID` with the name of the project you created for this tutorial.

    1. If you are using Cloud Run (fully managed), configure `gcloud` for your chosen region:

    ```
    gcloud config set run/region $REGION
    ```
    ```
    gcloud config set run/region $REGION
    ```

    Replace `$REGION` with the supported Cloud Run region of your choice.
    Replace `$REGION` with the supported Cloud Run region of your choice.

    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:

    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```

    Replace the following:
    Replace the following:

    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice

    ## Discussion

    @@ -63,34 +63,35 @@ The procedure is clear and ergonomic for readers for the following reasons:

    ## Implementation

    Sadly, this nested format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 4 spaces of indentation and code fences.
    Sadly, this nested format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 3 spaces of indentation and code fences.

    Consider this markdown source:

    ```
    1. If you are using Cloud Run (fully managed), configure gcloud for your chosen region:
    ```
    gcloud config set run/region $REGION
    ```
    ```
    gcloud config set run/region $REGION
    ```
    Replace `$REGION` with the supported Cloud Run region of your choice.
    Replace `$REGION` with the supported Cloud Run region of your choice.
    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    Replace the following:
    Replace the following:
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    ```

    The following points are important:

    * Use the number `1.` for numbered lists because it makes adding new steps easier.
    * Use a newline, 4 spaces for indendation, and code fences for nested code blocks.
    * Use a newline and 4 spaces for indentation for nested lists and/or paragraphs.
    * Use a newline, 3 spaces for indendation, and code fences for nested code blocks.
    * It's not clear why 3 spaces instead of 4 spaces or a tab. Sometimes 4 or a tab will cause a space to appear in front of all the commands like ` echo foo`.
    * Use a newline and 3 spaces for indentation for nested lists and/or paragraphs.
  9. @max-standard max-standard revised this gist Nov 4, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ To configure `gcloud` with defaults for your Cloud Run service:
    ## Discussion
    The procedure is clear and ergonomic for readers. I like this format for the following reasons:
    The procedure is clear and ergonomic for readers for the following reasons:
    * Foremost, the procedure is organized into manageable steps. Sometimes multiple commands belong in one step. The nested code blocks handle the situation fine.
    * Copy and paste is easy. I can select all or double click on a given command to copy and paste into my terminal.
    @@ -63,7 +63,7 @@ The procedure is clear and ergonomic for readers. I like this format for the fol
    ## Implementation
    Sadly, this format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 4 spaces of indentation and code fences.
    Sadly, this nested format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 4 spaces of indentation and code fences.
    Consider this markdown source:
  10. @max-standard max-standard revised this gist Nov 4, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,11 @@ The following are the main features I like:

    The important technique is: _nesting_. Nesting steps, commands, and details organizes complicated procedures into clear chunks.

    ## GCP Example

    Consider the following example from the [Using Pub/Sub with Cloud Run tutorial](https://cloud.google.com/run/docs/tutorials/pubsub#setting-up-gcloud):

    ## Setting up gcloud defaults
    ### Setting up gcloud defaults

    To configure `gcloud` with defaults for your Cloud Run service:

  11. @max-standard max-standard created this gist Nov 4, 2020.
    94 changes: 94 additions & 0 deletions nested-code-blocks.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    # Nested Code Blocks

    > Use nested code blocks for clear technical documentation.
    ## Overview

    Google Cloud Platform (GCP) technical documentation is formatted well enough; however, emulating it with markdown is tricky.

    The following are the main features I like:

    * Headings name a procdure
    * Numbered lists describe steps in a procedure
    * Nested code blocks illustrate commands in a given step
    * Nested bullets and/or nested paragraphs add important points about a given step

    The important technique is: _nesting_. Nesting steps, commands, and details organizes complicated procedures into clear chunks.

    Consider the following example from the [Using Pub/Sub with Cloud Run tutorial](https://cloud.google.com/run/docs/tutorials/pubsub#setting-up-gcloud):

    ## Setting up gcloud defaults

    To configure `gcloud` with defaults for your Cloud Run service:

    1. Set your default project:

    ```
    gcloud config set project $PROJECT_ID
    ```
    Replace `$PROJECT_ID` with the name of the project you created for this tutorial.
    1. If you are using Cloud Run (fully managed), configure `gcloud` for your chosen region:
    ```
    gcloud config set run/region $REGION
    ```
    Replace `$REGION` with the supported Cloud Run region of your choice.
    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    Replace the following:
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    ## Discussion
    The procedure is clear and ergonomic for readers. I like this format for the following reasons:
    * Foremost, the procedure is organized into manageable steps. Sometimes multiple commands belong in one step. The nested code blocks handle the situation fine.
    * Copy and paste is easy. I can select all or double click on a given command to copy and paste into my terminal.
    * There are no additional spaces or comments in the code blocks.
    * The variables are clear.
    * The difference between the description of a step, the actual command to run, and important details is clear.
    ## Implementation
    Sadly, this format favors the reader more than the writer. Problems arise when combining numerical lists, bulleted lists, code blocks, and paragraphs. The key technique is: use 4 spaces of indentation and code fences.
    Consider this markdown source:
    ```
    1. If you are using Cloud Run (fully managed), configure gcloud for your chosen region:

    ```
    gcloud config set run/region $REGION
    ```
    Replace `$REGION` with the supported Cloud Run region of your choice.
    1. If you are using Cloud Run for Anthos on Google Cloud, configure `gcloud` for your cluster:
    ```
    gcloud config set run/cluster $CLUSTER_NAME
    gcloud config set run/cluster_location $REGION
    ```
    Replace the following:
    * `$CLUSTER_NAME` with the name you used for your cluster
    * `$REGION` with the supported cluster location of your choice
    ```

    The following points are important:

    * Use the number `1.` for numbered lists because it makes adding new steps easier.
    * Use a newline, 4 spaces for indendation, and code fences for nested code blocks.
    * Use a newline and 4 spaces for indentation for nested lists and/or paragraphs.