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
#pragma #define not keywords (C++) and dspic reserved registers #2439
Comments
but I need to let the property be evaluated as an expression |
Ok. Basically, you want 2 things: First. You need to highlight some global constants/variables. The easiest way to achieve this is by modifying the C++ language definition. Run the following code after you loaded Prism and before you do any highlighting (e.g. by appending it your Prism.languages.insertBefore('cpp', 'constant', {
'dspic-register': /\b(?:_LATB15|_LATB12|...)\b/
}); The above will highlight all your registers with the Secondly:
What do you mean by "be evaluated", we only do highlighting? |
#ifdef in one color
or
so the expression should be colored (20000 as number in blue..) |
yes sorry I mean syntax highlighting but as expression (numbers)
see the pdf file here I am using this slightly modified css to acheive this but it is not perfect as the pdf files (from CLion) |
this works but not every where for example in the #define property it is not highlighted (see my previous post) |
I see. So for directives, we need 2 changes: We need to include the |
With #2440, macro expressions are now highlighted. (This will also highlight your registers in macros accordingly.) After #2440, you should be able to style your C++ code similar to your screenshots (they were very helpful btw!). If you want 100% accuracy: With Custom class, you can add additional classes to tokens, so you could add a special class just for semicolons: Prism.plugins.customClass.add(({content, type, language}) => {
if (content === ';' && type === 'punctuation' && language === 'cpp') {
return 'semicolon';
}
}); It might take some time for #2440 to get merged, so you might want to branch it. |
yes, that's correct thanks |
Both will work. <script src="prism.js"></script>
<script>/* The insertBefore calls */</script> or /* PrismJS 1.20.0
https://prismjs.com/download.html#... */
...
/* The insertBefore calls */ |
The issue seems to have been resolved but I forgot to close it. |
Language
C++ for dspic Microchip microcontrollers
Additional resources
I would like to add reserved registers names to be displayed with a special colors
Can I put a .json containing these reserved registers (example _LATB15, _LATB12, _PLLPRE, _PLLPOST... which are in a .h file) to be displayed in another color
we can have C++ instruction like:
compilation directives (#ifndef #endif) should be in a color, its text in another color
while is a keyword
OSCCONbits.COSC is register reserved keyword
I tried "Highlight Keywords" plugin but #xxxx is not recognised as keyword
The text was updated successfully, but these errors were encountered: