Skip to content

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

Merged
RunDevelopment merged 1 commit into
PrismJS:masterfrom
RunDevelopment:c-improved-macro-expr
Jun 29, 2020
Merged

C/C++: Improved macros and expressions#2440
RunDevelopment merged 1 commit into
PrismJS:masterfrom
RunDevelopment:c-improved-macro-expr

Conversation

@RunDevelopment

Copy link
Copy Markdown
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

blotfi commented Jun 29, 2020

Copy link
Copy Markdown

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
Copy Markdown
Member Author

@blotfi Right now!

@blotfi

blotfi commented Jun 29, 2020

Copy link
Copy Markdown

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

@blotfi

blotfi commented Jun 29, 2020

Copy link
Copy Markdown

@RunDevelopment

Copy link
Copy Markdown
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

blotfi commented Jun 29, 2020

Copy link
Copy Markdown

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

blotfi commented Jun 29, 2020

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants