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

GFM: be more clever on parsing fenced codeblock #369

Closed
wants to merge 1 commit into from

Conversation

tsl0922
Copy link
Contributor

@tsl0922 tsl0922 commented Sep 6, 2016

This pr adds support for fenced code block with whitespace before the ```

source:

  ```js
  console.log("hello");
  ```

github result:

  console.log("hello");

kramdown result:

<p><code>js
  console.log("hello");
 </code></p>

@gettalong gettalong self-assigned this Sep 9, 2016
@gettalong gettalong added the bug label Sep 9, 2016
@@ -85,8 +85,8 @@ def parse_atx_header_gfm_quirk
true
end

FENCED_CODEBLOCK_START = /^[~`]{3,}/
FENCED_CODEBLOCK_MATCH = /^(([~`]){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^\1\2*\s*?\n/m
FENCED_CODEBLOCK_START = /^\s*?[~`]{3,}/
Copy link
Owner

Choose a reason for hiding this comment

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

\s*? is not correct since after testing I found that only a maximum of three spaces is allowed by GFM on Github.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it can be more strictly here, changed to [ ]{,3}. More than 3 spaces will be identified as normal code block at github, so does kramdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[ ]{,3} failed travis test for 1.8.7, changed it to [ ]{0,3}

@tsl0922 tsl0922 force-pushed the gfm-codeblock branch 2 times, most recently from a4083cb to 3d7293e Compare September 10, 2016 00:34
@gettalong
Copy link
Owner

Thanks for the changes - this looks good to me now! I will include it for the next release.

@gettalong
Copy link
Owner

Thanks for the pull request - will be in the next release.

@gettalong gettalong closed this Nov 13, 2016
@tsl0922 tsl0922 deleted the gfm-codeblock branch June 2, 2017 09:09
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.

None yet

2 participants