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

Github-Flavored Markdown #409

Merged
merged 261 commits into from
Feb 8, 2020
Merged

Github-Flavored Markdown #409

merged 261 commits into from
Feb 8, 2020

Conversation

colinodell
Copy link
Member

@colinodell colinodell commented Feb 4, 2020

This pull request adds complete GFM support to this library.

It will be an optional extension bundled with this library that anyone can easily use without needing to manually install and register external extensions.

Background

Historically, this library has tried to avoid including any functionality not present in the CommonMark spec. This included all features of Github-Flavored Markdown, such as tables. Due to popular demand, we did eventually release those as standalone packages under the league/* Packagist namespace. The idea was this would ensure proper separation and allow us to gradually develop and refactor those features over time.

However, the burden to maintain those various extensions as completely separate packages has been difficult. Changes to the core parser were not automatically tested against those other extensions either. And perhaps the biggest problem was not having a single extension unifying all the GFM-related extensions together.

Bundled Extensions

The following extensions will be added to this library once 1.3.0 is released:

  • GithubFlavoredMarkdownExtension, a brand new extension which includes all of the following:
    • AutolinkExtension (from league/commonmark-ext-autolink)
    • DisallowedRawHtmlExtension (new extension)
    • StrikethroughExtension (from league/commonmark-ext-strikethrough)
    • TableExtension (from league/commonmark-ext-table)
    • TaskListExtension (from league/commonmark-ext-task-list)

Two other extensions are also being included in this PR, even though they're not part of the GFM spec:

  • SmartPunctExtension (from league/commonmark-ext-smartpunct)
  • InlinesOnlyExtension (from league/commonmark-ext-inlines-only)

Those two extensions are not part of the GFM spec, but they do provide useful functionality based on the core library and so including them here meets the goal of reducing the maintenance burden.

Deprecation and Migration

The following packages will be deprecated once league/commonmark 1.3.0 is released:

  • league/commonmark-extras (basically was a meta-package for most of the GFM extensions below)
  • league/commonmark-ext-autolink
  • league/commonmark-ext-smartpunct
  • league/commonmark-ext-strikethrough
  • league/commonmark-ext-table
  • league/commonmark-ext-task-list
  • league/commonmark-ext-smartpunct
  • league/commonmark-ext-inlines-only

Users of those packages may continue to use them, but support for issues and future compatibility will not be provided. Users will therefore be strongly encouraged to switch to the built-in GFM support provided in 1.3.0

Switching should be relatively painless for most people - the general gist is:

  • Upgrade to league/commonmark 1.3
  • Replace any references to the League\CommonMark\Ext\ namespace in your code to League\CommonMark\Extension\
  • Remove the deprecated packages from your composer.json

Extension Changes

For the most part, all of the extensions were imported as-is into this codebase with a single code-level change to the namespace:

-namespace League\CommonMark\Ext\{extension-name-here};
+namespace League\CommonMark\Extension\{extension-name-here};

A small number of other changes were made to specific extensions to align their behavior with the GFM spec, which may affect how some Markdown is parsed:

  • Tables
    • Table captions are no longer supported (they are not part of the GFM spec)
    • Tables with a mismatched number of columns now behave properly
    • Tables use the 'align' attribute for alignment instead of hard-coded CSS
    • Escaped pipe characters are now handled properly
  • Task Lists
    • The rendered <input> elements no longer look like <input /> (with that closing slash)

dakota and others added 30 commits July 30, 2015 09:58
…ecated and Cursor::getNextNonSpacePosition() can instead be used.
…date

Added support for league/commonmark 0.16
Better parsing of escapes in cell
@colinodell colinodell added the enhancement New functionality or behavior label Feb 4, 2020
@colinodell colinodell self-assigned this Feb 4, 2020
@GrahamCampbell
Copy link
Member

Doesn't GFM have emojis?

@colinodell
Copy link
Member Author

Doesn't GFM have emojis?

Great question! Emojis are actually implemented outside of their Markdown stack and are not part of the GFM spec extensions. Based on that, I think it makes sense to keep the :emoji: syntax outside of the GFM extension unless the GFM spec includes them one day.

@GrahamCampbell
Copy link
Member

GrahamCampbell commented Feb 4, 2020

Ah, interesting. I wonder what other features they have that are outside of the spec, other than the at mentions, and issue/commit links?

@colinodell colinodell merged commit a13ee46 into master Feb 8, 2020
@colinodell colinodell deleted the gfm-extensions branch February 8, 2020 22:57
@glensc
Copy link
Contributor

glensc commented Feb 10, 2020

@colinodell the 1.3.0 is released, could you put the migration things to docs as well? I was expecting something about it in 1.3.0 release notes:

@colinodell
Copy link
Member Author

I've added information to the tag's release notes to help point people in the right direction. I also plan to release one more minor/bugfix release of each individual package with a Composer suggests line pointing people to the same instructions to help spread the word.

Copy link

@j4kim j4kim left a comment

Choose a reason for hiding this comment

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

Typo in docs

docs/1.0/customization/extensions.md Show resolved Hide resolved
Copy link

@j4kim j4kim left a comment

Choose a reason for hiding this comment

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

Extensions docs copy-paste does not work

docs/1.0/customization/extensions.md Show resolved Hide resolved
docs/1.0/customization/extensions.md Show resolved Hide resolved
docs/1.0/customization/extensions.md Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality or behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet