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

Add autolink (linkify) functionality to Markdown #101

Merged
merged 2 commits into from
Oct 24, 2022

Conversation

morrisseyai
Copy link
Contributor

PR updates the commonmark-java dependency to 0.20.0 and introduces autolink (linkify) functionality.

I have added MarkdownParseOptions which allows consumers of the library to control whether or not the autolink functionality is enabled. Addresses #95

Note: autolink is enabled with the new MarkdownParseOptions defaults, which means there is a minor (but worth mentioning) behaviour change here.

Short demo:

device-2022-10-22-135749.mp4

)
)
.build()
}

val astRootNode by produceState<AstNode?>(null, text) {
val astRootNode by produceState<AstNode?>(null, text, options) {
Copy link
Owner

Choose a reason for hiding this comment

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

parser should be a key to this produceState since it can change according to options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I had used options as the key for parser above, and for some reason re-used the same key here instead of using parser 🤦

val autolink: Boolean
) {
public companion object {
public fun getDefaults(): MarkdownParseOptions = MarkdownParseOptions(
Copy link
Owner

Choose a reason for hiding this comment

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

nit; you can make this a Default val instead of re-allocating with every function call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Adds MarkdownParseOptions which allows consumers of the library to control whether or not the autolink functionality is enabled.

Note the behaviour change: autolink is enabled with the new MarkdownParseOptions defaults.
@morrisseyai morrisseyai force-pushed the feature/autolink-markdown branch from 2eef844 to 9556d65 Compare October 24, 2022 09:55
@halilozercan halilozercan merged commit f8ed70e into halilozercan:main Oct 24, 2022
@halilozercan
Copy link
Owner

Thanks 🎉

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