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

Restructures MarkdownParseOptions to expose extension selectors. #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vitorpamplona
Copy link
Contributor

I have a need to add my own custom extensions to the parser and thought this could be a good generalization for everyone else.

This opens up MarkdownParseOptions to some flexibility in enabling or disabling extensions.

Copy link
Owner

@halilozercan halilozercan left a comment

Choose a reason for hiding this comment

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

Sorry for reviewing the PR half a year late.

import org.commonmark.ext.autolink.AutolinkExtension
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension
import org.commonmark.ext.gfm.tables.TablesExtension

/**
* Allows configuration of the Markdown parser
*
* @param autolink Detect plain text links and turn them into Markdown links.
Copy link
Owner

Choose a reason for hiding this comment

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

need to update kdoc.

public data class MarkdownParseOptions(
val autolink: Boolean
) {
public data class MarkdownParseOptions(val extensions: List<Extension>) {
Copy link
Owner

Choose a reason for hiding this comment

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

since richtext-commonmark and richtext-markdown are now separate modules I'm not as opposed to exposing commonmark details as I had been before, but I still would prefer if extensions were exposed as a value class.

value class MarkdownExtension private constructor(internal val value: Int) {
  companion object {
    val Tables = ...
    val AutoLink = ...
    ...
  }
}

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.

2 participants