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
base: master
from

Conversation

Projects
None yet
2 participants
@tsl0922
Contributor

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,}/

This comment has been minimized.

@gettalong

gettalong Sep 9, 2016

Owner

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

This comment has been minimized.

@tsl0922

tsl0922 Sep 9, 2016

Contributor

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.

This comment has been minimized.

@tsl0922

tsl0922 Sep 10, 2016

Contributor

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

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

This comment has been minimized.

@gettalong

gettalong Sep 9, 2016

Owner

Here is the same problem as in the last line.

@tsl0922 tsl0922 force-pushed the tsl0922:gfm-codeblock branch 2 times, most recently from a4083cb to 3d7293e Sep 9, 2016

@tsl0922 tsl0922 force-pushed the tsl0922:gfm-codeblock branch from 3d7293e to 2dc33d5 Sep 10, 2016

@gettalong

This comment has been minimized.

Owner

gettalong commented Sep 10, 2016

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

@gettalong

This comment has been minimized.

Owner

gettalong commented Nov 13, 2016

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

@gettalong gettalong closed this Nov 13, 2016

@tsl0922 tsl0922 deleted the tsl0922:gfm-codeblock branch Jun 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment