I'm trying to add a few words to the javascript highlighting dynamically.
I added a custom section in the js.js file to highlight my own keywords. This works fine.
When I try to add a few words dynamically. It adds them to the list, but they do not highlight.
the regular expression that is returned is an object with properties
re.source will give you the source or regular expression search string
re.flags will give you the modifiers such as gi
originalsource=re.source
you can edit the source string with string functions to include your own words by inserting some new words between the | delimiters for example the source might look like (\b)(dynamic1|dynamic2)(\b)
which you can modify to your own newstring using regular string functions
I'm trying to add a few words to the javascript highlighting dynamically.
I added a custom section in the js.js file to highlight my own keywords. This works fine.
When I try to add a few words dynamically. It adds them to the list, but they do not highlight.
Does anybody know how to get the added words to be seen by the highlighter?
I finally figured it out
Just go into js.js and add your own section for example:
When you run editarea again it will highlight those words.
Now there is a place to write new dynamic words
to read out the dynamic words use
the regular expression that is returned is an object with properties
re.source will give you the source or regular expression search string
re.flags will give you the modifiers such as gi
you can edit the source string with string functions to include your own words by inserting some new words between the | delimiters for example the source might look like
(\b)(dynamic1|dynamic2)(\b)which you can modify to your own newstring using regular string functions
(\b)(dynamic1|dynamic2|dynamic3|dynamic4)(\b)then reset the regular expression
editAreaLoader.syntax.js.keywords_reg_exp.dynamic = new RegExp(newsource,"gi");the new dynamic words should now highlight.
Last edit: daniel savage 2016-10-06