I'll take a hit in the second part (remember, I suppose, based on the knowledge that this is a JS Markdown parser):
The lookahead statement (?=\S) probably exists if someone wants to write two asterisks ** or two underscores __, not wanting to highlight the text that comes after it, which is separated by a space (see what I did there? )
** This text will not be bold. ** **This text will be bold.**
** This text will not be in bold. **
This text will be in bold.
source share