-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Stan syntax updates #3410
Comments
Sounds about right at a glance. You willing to work on a PR for this, @spinkney ? |
@joshgoebel I can take a stab, it doesn't look too hard. |
I have a fork with the updates https://github.com/spinkney/highlight.js/blob/main/src/languages/stan.js. The build runs. However, when I try to test with the developer.html |
You ned to build it:
|
We also now have Thoughts? |
Thanks, do you have any pointers how to add suffixes that are valid for a list of words? So I have a bunch of distributions and they can have different suffixes. I don't want to have 5 |
Actually we often prefer it this way (for maintenance and readability) - if the number of variations is smaller - and that would definitely be the case with 5. If there are a lot more than 5 then you'd need to use a custom mode and use regex to do the matching. |
For example:
Breaking this out is more trouble than it's worth because keywords and modes don't behave exactly the same so it's better to just have the longer list of keywords.... which compression will smash and keyword look-up is |
ok but then I'll have to do it for every distribution and when a new |
there's also |
You can build portions of the keyword list programmatically if it will save a lot of time/thinking: const DISTRIBUTIONS = ["normal", "abnormal", ...];
const expanded = DISTRIBUTIONS.flatMap(name => [
`${name}_lupdf`,
`${name}_qd`,
]
) Very little magic, no regex, and it's still a simple array when finished. |
Do I just reference expanded? I'm not getting the list built out from this and I assume it's something silly. vscode is also complaining about flatMap Property 'flatMap' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2019' or later.ts(2550) |
Dunno, it's newish... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap I'd suggest doing as it says: |
Well after expanding you're probably going to add it back into the larger list with destructuring, etc... |
Great, things are looking good. I'm just having trouble getting a different color for control flow keywords I've tried putting it in keywords and having it broken out in the contains section. Right now the |
PR is in and ready for review |
@joshgoebel this almost gets me the UDFs and the language defined distributions but the UDF distributions have a different color than the distributions in keywords. I want both of them the same color as the {
className: 'built_in',
begin: '\\s*(' + hljs.IDENT_RE + ')(?=\\()',
keywords: DISTRIBUTIONS.concat(DISTRIBUTIONS_EXPANDED)
} Edit: I got it with: {
className: 'built_in',
begin: '\\s*(' + hljs.IDENT_RE + ')(?=\\()',
built_in: DISTRIBUTIONS.concat(DISTRIBUTIONS_EXPANDED)
} |
Information
Description
Lots of updates to Stan over the last few months
Type updates:
array[]
is now a valid keywordcomplex
is a valid keyword literalThe higher order functions that are valid are:
It's probably easier to just have all the functions. You can view the updated recent pr request in the rouge library
Long list of functions
# Integer-Valued Basic FunctionsThe BNF grammars page was updated. I see that this is referenced in the prism stan code. The updated file is stan bnf grammars 2.28.
The text was updated successfully, but these errors were encountered: