Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.

Conversation

@juliusknorr
Copy link
Collaborator

@juliusknorr juliusknorr commented May 31, 2022

🚧

Adding auto linking without full GFM:

import {fromMarkdown} from 'mdast-util-from-markdown'

import {
  gfmAutolinkLiteral,
} from 'micromark-extension-gfm-autolink-literal'
import {
  gfmAutolinkLiteralFromMarkdown,
} from 'mdast-util-gfm-autolink-literal'

// ...
			.use(function() {
				return function(tree) {
					if (!autolink) {
						return
					}
					if (useMarkdown) {
						visit(tree, (node) => node.type === 'text', (node, index, parent) => {
							const subtree = fromMarkdown(node.value, {
								extensions: [gfmAutolinkLiteral],
								mdastExtensions: [gfmAutolinkLiteralFromMarkdown]
							})
							parent.children = [
								...parent.children.slice(0, index),
								...subtree.children,
								...parent.children.slice(index + 1),
							]
						})
					}
				}
			})

Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
@juliusknorr
Copy link
Collaborator Author

@Cacodaimon Since you worked on the initial markdown implementation, do you remember if there was a concrete use case for disabling the remark options individually in addition to the generic on/off switch for markdown? With the switch to micromark in remark this seems to be no longer possible, only a subset may be turned off through:

https://github.com/micromark/micromark#case-turn-off-constructs

I'd drop that option if there is no case where that might be relevant for the talk implementation.

One reason I could think of would be to be able to reuse the auto link feature with plain text only, which apparently is another tricky thing to solve with the new remark version, so I'm currently thinking if for plain text only we might revert to the old manual approach from https://github.com/juliushaertl/vue-richtext/blob/v0.3.3/src/RichText.vue#L111-L137 without using unified/remark.

Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
@juliusknorr juliusknorr merged commit 5564ce9 into master Aug 12, 2022
@juliusknorr juliusknorr deleted the vite branch August 12, 2022 14:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants