Skip to content

How to convert a token's type #3476

Answered by UziTech
spifory asked this question in Q&A
Oct 4, 2024 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

That will work but link has sub tokens in token.tokens that the parser uses to render the text.

So it will have to be something like

  try {
		// ![](https://invalid-image.com)
		const image = await fetch(token.href)
	} except {
		token.text = 'link'
		token.type = 'link'
    token.tokens = lexer.inlineTokens(token.text); // This will tell the parser what to output
	}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@spifory
Comment options

@UziTech
Comment options

@spifory
Comment options

Answer selected by spifory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants