Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indentation when code block is in a list #345

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Jan 27, 2025

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
Copy link
Member

@Mpdreamz Mpdreamz left a comment

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
5 of 6 checks passed
@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