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

support GFM-style code blocks #21

Merged
merged 2 commits into from
Mar 16, 2022
Merged

support GFM-style code blocks #21

merged 2 commits into from
Mar 16, 2022

Conversation

Roguelazer
Copy link

This allows you to use GitHub-flavored markdown's way of specifying the programming language for highlighting a code block, and thus improves compatibility when rendering READMEs from non-Phabricator projects. I doubt there are any real cases where someone did ```python and expected anything else?

if (preg_match('/^\s*```/', $text)) {
// Look for GFM-style ```langname blocks and handle them
if (preg_match('/\A\s*``` *([a-z]+)\n/', $text, $matches)) {
Copy link
Member

Choose a reason for hiding this comment

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

this code uses ^ elsewhere rather than \A.

Copy link
Author

Choose a reason for hiding this comment

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

I don't think it makes a difference unless PCRE_MULTILINE is set; I can change it if you prefer

@Roguelazer Roguelazer merged commit 4112528 into easypost-patches Mar 16, 2022
@Roguelazer
Copy link
Author

This is sent upstream at https://we.phorge.it/D25034 fwiw

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.

2 participants