Skip to content

GFM: be more clever on parsing fenced codeblock#369

Closed
tsl0922 wants to merge 1 commit into
gettalong:masterfrom
tsl0922:gfm-codeblock
Closed

GFM: be more clever on parsing fenced codeblock#369
tsl0922 wants to merge 1 commit into
gettalong:masterfrom
tsl0922:gfm-codeblock

Conversation

@tsl0922

@tsl0922 tsl0922 commented Sep 6, 2016

Copy link
Copy Markdown
Contributor

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
Comment thread lib/kramdown/parser/gfm.rb Outdated

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

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

@gettalong

Copy link
Copy Markdown
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.

2 participants