TYP: loosen types of to_markdown, align to docs
Docs already allowed pathlib.Path objects and such
code runs, but failed mypy typechecks. This fixes it.

- [x] closes #46211 
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

As for code checks, I only ran the `typing` tests (from the provided container config in `.devcontainer.json`):

```bash
$ ./ci/code_checks.sh typing
mypy --version
mypy 0.931
Performing static analysis using mypy
Success: no issues found in 1363 source files
Performing static analysis using mypy DONE
```

Please let me know if an entry to the `vX.X.X.rst` file should be made (and which version). This change doesn't feel worth mentioning though. thanks @alexpovel 