feat: dont underscore numbers when formatting module names
Redo of https://github.com/denoland/deno_doc/pull/655
Contributes to https://github.com/jsr-io/jsr/issues/803
I eventually got here by looking at how the identifier for the file was created:
The identifier replacing all non-characters with underscores seems to be the source so adjusting the regex to allow numbers.
The regex accounts for leading numbers, as they're invalid identifiers. So as long as your moduel doesn't start with a number, you can have numbers or letters in your identifier name.
If need be, can make e.ts that can assert all of the following; leading numbers are replaced, numbers are allowed, and special characters are replaced. I'd be more than happy to expand the test suite to include this. Not sure what makes sense from a practical standpoint though.
Testing strategy includes running the snapshot tests and asserting both the module name is bar123 as well as locally inspecting the generated HTML to see import ... as bar123 from ...