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

C/C++: Improved macros and expressions #2440

Merged
merged 1 commit into from Jun 29, 2020

Conversation

@RunDevelopment
Copy link
Member

@RunDevelopment RunDevelopment commented Jun 28, 2020

This can be seen as an extension of #2320.

Macro expressions after the directive are now highlighted. I also added some highlighting for macro-specific syntaxes like \ at line ends and the concatenation operator.

@blotfi
Copy link

@blotfi blotfi commented Jun 29, 2020

when will it be possible to download the prismjs that includes this #2440 enhancement?

@RunDevelopment RunDevelopment merged commit 8a72fa6 into PrismJS:master Jun 29, 2020
1 check passed
@RunDevelopment RunDevelopment deleted the c-improved-macro-expr branch Jun 29, 2020
@RunDevelopment
Copy link
Member Author

@RunDevelopment RunDevelopment commented Jun 29, 2020

@blotfi Right now!

@blotfi
Copy link

@blotfi blotfi commented Jun 29, 2020

just to be more precise, it must be valid in C language (and therefore in C++ language) #2440 enhancement
thanks

@blotfi
Copy link

@blotfi blotfi commented Jun 29, 2020

@RunDevelopment
Copy link
Member Author

@RunDevelopment RunDevelopment commented Jun 29, 2020

you mean if i download [...] I will find the modification (for C and CPP) ?

Yes.

it must be valid in C language

Macro expressions will be highlighted as C code in C and as C++ code in C++. You can see this with #define macros that contain C++ keywords.

C:
image

C++:
image

Is that what you meant?

@blotfi
Copy link

@blotfi blotfi commented Jun 29, 2020

I am testing now, 2 min
I see you put:

		'directive-hash': /^#/,
		'punctuation': /##|\\(?=[\r\n])/,
		'expression': {
			pattern: /\S[\s\S]*/,
			inside: Prism.languages.c

@blotfi
Copy link

@blotfi blotfi commented Jun 29, 2020

Works great
Thanks

I will open another issue for #include <xc.h>
it works well with file
<pre data-src="code/TP0/cmde.c"></pre>
but not if it is included in the html

<pre data-start="0" ><code class="language-cpp line-numbers">
#include <xc.h>
return;
#ifdef NON
void list()
{
}

image

quentinvernot added a commit to TankerHQ/prismjs that referenced this issue Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants