Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Jun 29, 2020

Conversation

RunDevelopment
Copy link
Member

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 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
@RunDevelopment RunDevelopment deleted the c-improved-macro-expr branch June 29, 2020 11:10
@RunDevelopment
Copy link
Member Author

@blotfi Right now!

@blotfi
Copy link

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 commented Jun 29, 2020

@blotfi Right now!

you mean if i download
https://prismjs.com/download.html#themes=prism&languages=clike+c+cpp+json&plugins=line-numbers+file-highlight+keep-markup

I will find the modification (for C and CPP) ?

@RunDevelopment
Copy link
Member Author

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 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 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 pushed a commit to TankerHQ/prismjs that referenced this pull request Sep 11, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants