Skip to content

Fix indentation when code block is in a list - #345

Merged
reakaleek merged 2 commits into
mainfrom
nested-codeblock-indentation
Jan 27, 2025
Merged

reakaleek merged 2 commits into
mainfrom
nested-codeblock-indentation

Conversation

@reakaleek

@reakaleek reakaleek commented Jan 27, 2025 •

Copy link
Copy Markdown
Member

Details

Using .EnableTrackTrivia() on the MarkdownPipeline causes extra whitespace on code blocks if they are not at the beginning of the document, e.g. in a list. The white space from the beginning of the document until the code block gets added.

Change

This change strips the indent of the code block.

Markdown

```json
{
  "key": "value"
}
```

  ```json
  {
    "key": "value"
  }
  ```

1. this is a list
   ```json
      {
        "key": "value"
      }
   ```
   1. this is a sub-list
      ```json
      {
        "key": "value"
      }
      ```

Result

image

@reakaleek reakaleek self-assigned this Jan 27, 2025
@reakaleek reakaleek added the fix label Jan 27, 2025
@reakaleek
reakaleek requested a review from a team January 27, 2025 08:36
@reakaleek
reakaleek marked this pull request as ready for review January 27, 2025 08:36

@Mpdreamz Mpdreamz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to reevaluate if we really need track trivia.

I added it to aid with ensuring line and column numbers are correct for the error message reporting but not 100÷ convinced this is needed.

@reakaleek
reakaleek merged commit 69fdd21 into main Jan 27, 2025
@reakaleek
reakaleek deleted the nested-codeblock-indentation branch January 27, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants