elvirbrk / NoteHighlight2016

Source code syntax highlighting for OneNote 2016 and OneNote for O365 . NoteHighlight 2013 port for OneNote 2016 (32-bit and 64-bit)
GNU General Public License v2.0
3.79k stars 393 forks source link

How to add a custom language? #122

Open AndyReifman opened 4 years ago

AndyReifman commented 4 years ago

I'm trying to define a custom language for highlighting. I created a example.lang file and added it to CodingRoad\NoteHighlight2016\highlight\langDefs

Then in my ribbon.xml file I added the line:

<button id="buttonExample" label="Example" size="large" screentip="Enter example Code" onAction="AddInButtonClicked" tag="example" image="Other.png" visible="true"/>

However that doesn't seem to have worked and when I try to click OK on the code snippet window I get an error that says

System.IO.FileNotFoundException: Can not find outputFile. at
GeneratehighlightContent.GenerateHighLight.GenerateHighLightCode(HighlightParameter parameter) at NoteHighlightAddin.MainForm.btnCodeHighLight_click(Object sender, EventArgs e)

Is it even possible to add a custom language?

abfab96 commented 4 years ago

I am also having this issue. I attempted it the same way that Andy did. Any help? I'm trying to add the DAX language to my notehighlight2016

neman-pcas commented 3 years ago

I just did the exact same thing in my attempt to create a definition for XQuery. I copied and modified the haskell.lang definition (no particular reason for that choice), pasting in examples from VB and MSSQL to see what I could figure out. It exploded in an identical manner. I then copied xml.lang, made no changes, and it worked exactly as expected. This tells me the Categories line in the .lang probably influences what sections are expected and what's expected in the sections. Now I need to figure out what's appropriate for XQuery.

Test copying a language file as close to possible as the language you want to create and modify with help from other examples.

Update: The error might be related to an unescaped character. Changing the XML delimiter: Delimiter= { [[<!\-\-]],[[\-\->]] }

to the XQuery delimiter Delimiter= { [[(:],[[:)]] } caused the same error.

Escaping the (, ), and : by preceding each with \ Delimiter= { [[\(\:]],[[\:\)]] } fixed it.

Hope that helps!