In gitGraph, add support branch names that only have a single
character.
The branch regex is checking for a starting character, and an
ending character, so it currently needs at least two characters.
I've wrapped everything except the first character in a `()?` to fix
this.
There are some really complicated regexes that do match what
valid git branches are (see https://stackoverflow.com/a/12093994), but
I'm reluctant to add them in, since it will be a pain to test all
the different edgecases.
Hopefully https://github.com/mermaid-js/mermaid/pull/3432 might be used
in the future to make a better gitgraph parser!
jison throws an error if a branch name starts with an unusual prefix.
For example, a branch named `branch/test-branch` will throw a
parse error, since jison thinks it's a `branch` command, and not
a branch id.
An easy fix is to use the `(?=\s|$)` regex to ensure that only
'branch ' or 'branch\n' will be parsed as the branch command.
Fixes: https://github.com/mermaid-js/mermaid/issues/3362
gitGraph does not support branch names that start with a number,
because the gitGraph.jison file parses these as NUM (number) instead.
To fix this, I've changed the NUM parser to only accept strings that
end with whitespace (e.g 1234 is a NUM, but 1234abc is not a NUM).
To do this, I had to move the "skip all whitespace" step to the
end of the parser, but this doesn't seem to have caused any issues,
so it's probably fine.