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

Add CommonMark markdown rendering option #687

Merged
merged 10 commits into from
May 26, 2023
Merged

Add CommonMark markdown rendering option #687

merged 10 commits into from
May 26, 2023

Conversation

bakerkretzmar
Copy link
Collaborator

@bakerkretzmar bakerkretzmar commented May 19, 2023

Adds the option to use league/commonmark to parse and render markdown. This can be enabled by setting the commonmark config to any value. To configure the CommonMark environment or add extensions, the commonmark config can be set to an array with config and extensions keys:

// config.php

return [
    'commonmark' => [
        'config' => ['enable_em' => false],
        'extensions' => [new AttributesExtension],
    ],
];

The default configuration includes 4 extensions: attributes, smart punctuation, strikethrough, and tables. Extensions can easily be added or removed by overriding the commonmark.extensions config key.

Two other things:

  • I'm not sure MarkdownParserContract is strictly necessary, and I wouldn't mind getting rid of it if we can, I just needed something to bind to.
  • Changing MarkdownParser to take a MarkdownParserContract in its constructor instead of a JigsawMarkdownParser is not technically a breaking change, right? We're widening that type, so all possible existing scenarios there will keep working, and the $parser property is not typed, so it could technically contain anything right now, which is also still the case. If someone's reaching into the underlying parser to do anything funky that would almost definitely break if they enabled this new parser, but it's optional so I think that's fine.

@bakerkretzmar bakerkretzmar self-assigned this May 19, 2023
github-actions bot and others added 4 commits May 19, 2023 18:41
1) src/Loaders/CollectionDataLoader.php (trailing_comma_in_multiline, unary_operator_spaces, not_operator_with_successor_space)
2) src/PathResolvers/CollectionPathResolver.php (trailing_comma_in_multiline, unary_operator_spaces, not_operator_with_successor_space)
3) tests/CommonMarkTest.php (class_definition, ternary_operator_spaces)
… and TableExtension by default, and add test for overriding (adding/removing) extensions
1) src/Console/InitCommand.php (operator_linebreak)
2) tests/CommonMarkTest.php (no_unused_imports)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant