Skip to content

allow custom cmark options and extensions when converting Markdown#23

Open
QuietMisdreavus wants to merge 3 commits intoswiftlang:mainfrom
QuietMisdreavus:custom-cmark-opts
Open

allow custom cmark options and extensions when converting Markdown#23
QuietMisdreavus wants to merge 3 commits intoswiftlang:mainfrom
QuietMisdreavus:custom-cmark-opts

Conversation

@QuietMisdreavus
Copy link
Copy Markdown
Contributor

Bug/issue #, if applicable: n/a

Summary

Currently, swift-markdown uses a static set of options and extensions when converting Markdown source. However, there are several options and unused extensions in cmark-gfm that could be used. This PR adds a new ConvertOptions type to wrap the existing ParseOptions type with additional information that is passed to cmark-gfm when converting.

Dependencies

None

Testing

markdown-tool has been extended to allow custom extensions (and to allow disabling the default extensions). With the following Markdown file, run swift run markdown-tool dump-tree test.md. Compare the results with no flags, when adding --no-default-extensions, when adding --extension autolink, and with both.

There is ~~some stricken text~~ here, and a link to http://example.com.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@QuietMisdreavus
Copy link
Copy Markdown
Contributor Author

@swift-ci Please test

nighthawk added a commit to maparoni/down-gfm that referenced this pull request Mar 12, 2022
Changes:

- Removes embedded `cmark` in favour of [`apple/swift-cmark`](https://github.com/apple/swift-cmark)
- Removes AST code in favour of [`apple/swift-markdown`](https://github.com/apple/swift-markdown)
- Removes DebugVisitor in favour of `document.debugDescription()` from `swift-markdown`
- Support tasklist/checkbox

Later:

- Restore ordered list starts, depends on: swiftlang/swift-markdown#22
- Restore various Down options, depends on: swiftlang/swift-markdown#23
@QuietMisdreavus
Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main to resolve a merge conflict.

@QuietMisdreavus
Copy link
Copy Markdown
Contributor Author

Rebased to resolve merge conflict.

@swift-ci Please test

CreatureSurvive added a commit to CreatureSurvive/swift-markdown that referenced this pull request Dec 31, 2023
CreatureSurvive added a commit to CreatureSurvive/swift-markdown that referenced this pull request Dec 31, 2023
@m-y-n-o-n-a
Copy link
Copy Markdown

When will this pr be merged?

@LiYanan2004
Copy link
Copy Markdown

LiYanan2004 commented Oct 17, 2024

Any updates for this PR?

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.

3 participants