Improve regex that replaces ".md" in help filenames 

The issue I was seeing with "gemdir.md" being changed to "gir.md" instead of "gemdir" is fixed by the first commit here by escaping the ".". I think adding the dollar sign to anchor this replacement to the end improves it more, but that case is probably rare, so I made that change in a separate commit so that it'd be easy for you to take just one. Or I'm happy to squash, let me know! :heart_eyes: