volca / markdown-preview

Markdown Preview Plus -- Enables Chrome to render markdown files as HTML
https://chrome.google.com/webstore/detail/markdown-preview-plus/febilkbfcbhebfnokafefeacimjdckgl
MIT License
237 stars 73 forks source link

Support for server MIME type rather than file extension? #136

Closed davidpcaldwell closed 1 year ago

davidpcaldwell commented 2 years ago

GitHub wikis use Markdown but do not include the .md in their URLs. So GitHub wiki links will have URLs like MyPageName rather than MyPageName.md.

When serving these wikis locally for development and authoring, and using Markdown Preview Plus to browse them, this will result in broken links.

One can thus rewrite the local server to emulate GitHub serve the *.md pages locally - in other words, to serve MyPageName.md when MyPageName is requested. But then Markdown Preview Plus won't recognize the file as a Markdown file.

I'm currently handling this by modifying the local server to redirect to MyPageName.md, but it'd be even better if Markdown Preview Plus would render files served with test/markdown even if they had no file extension.

I'm not an expert on Chrome extensions so not sure what the possibilities are here. I believe by browsing manifest.json I see that MPP is using file extension to determine whether to handle requests. Not sure whether MIME type can be used in conjunction with that.

volca commented 2 years ago

Please check the response headers for the content-type for the MIME type. see my screenshot. You can find it in the DevTools of Chrome.

截屏2022-08-26 14 55 47