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

Multi line coloration #142

Open
Wyrdix opened this issue Jan 21, 2025 · 2 comments
Open

Multi line coloration #142

Wyrdix opened this issue Jan 21, 2025 · 2 comments

Comments

@Wyrdix
Copy link

Wyrdix commented Jan 21, 2025

I would like to add coloration to a syntax like so :

<MD>

<SEPARATOR>

<MD>

Where can be replaced by any markdown part and is a predefined string

In the end i tried to modify the coloration to have it only works if the SEPARATOR is present in its own paragraph (which means with empty line before and after).

But it seems like it's not possible to have a coloration around multiple lines ?

As an example heres what i've tried :

grammarRules: [
			{
				name: 'question',
				type: 'inline',
				definition: {
					match: '(\n *\n#\\?#( +|\n))',
					name: 'markup.inline.question',
					captures: {
						'1': { name: 'marker.definition.question.inline' }
					}
				}
			}
		],

(with the corresponding colors options that works when it's not multiline regex)

Don't know if it's a bug or a features

@BearToCode
Copy link
Owner

Hello, sorry for the late reply but I'm currently very busy and I don't have much time to dedicate to open-source at the moment.

Anyway, I'm not sure I understood what you trying to achieve: do you want to change the color of the separator, or what else?
Writing complex grammar / highlight rules is not an easy thing to do, and I'm not the right person to help you with that. You can find some info here, but I suggest you also look into some languages examples.

Another thing: only providing a grammar rule is not enough: grammar rules are used to parse the text into tokens, but they do not specify how they should be colored. You also need a highlighting rule that targets that specific token. Here is an example from the emoji plugin, which highlights text like :emoji::

const grammar = {
name: 'emoji',
type: 'inline',
definition: {
match: ':(?:\\+1|[-\\w]+):',
name: 'markup.emoji.markdown'
}
} satisfies GrammarRule;
const highlighting = {
light: {
scope: 'markup.emoji',
settings: {
foreground: '#3bf'
}
},
dark: {
scope: 'markup.emoji',
settings: {
foreground: '#4dacfa'
}
}
} satisfies HighlightingRule;

@Wyrdix
Copy link
Author

Wyrdix commented Jan 25, 2025

Hi, don't worry for the delay for now i removed the rules as it wasn't working properly

Yes I want to color the separator when it's between two empty lines (because in other cases it would be a paragraph and "harder" to parse)

And yeah i knew for the coloration it was what i meant at the end of my message with "color options" being put

I'll check your link, maybe there some shiki thing i didn't know about

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

No branches or pull requests

2 participants