LeaVerou / md-block

A custom element for rendering stylable (light DOM) Markdown

Home Page:https://md-block.verou.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

external md file not loading

uinguzero opened this issue · comments

With just a simple md-block from the demo, everything works,

but when i try to load an external md file using

  <script type="module" src="https://md-block.verou.me/md-block.js"></script>
<md-block src="output.md">
	`output.md` was *not* found
</md-block>

with output.md on the smae level as my htm file it always shows output.md was not found
I've also tried
./output.md
or the full path
/home/user/tmp/output.md

How are you running the page? What URL from? What's the file structure? Thanks!

It is just a standalone html page, which i run in brave, but tested in other browsers as well, like firefox.

code:
https://pastebin.com/zCLrPSyX

If i copy the content of my output.md file inside the block, it works perfectly, but it does not import it like the code above

@LeaVerou any news?
I've tried the demo on the website, and there it works, but when i just put the same code in an stand alone htm file that is running locally on my computer, it doesn't work.

md-block uses fetch() behind the scenes, and I can't remember if that's one of the APIs that don't work under file:// (the protocol used when you just open an HTML file with a browser). Try using a local server (localhost) and I think it will solve the problem. In general you'll find more and more things don't work under file://, it's considered unsafe, so browsers are not running many newer APIs on that.

@LeaVerou you are correct.
When running the page through a local webserver it displays the content of a sourced MD file correctly

When running the page through a local webserver it displays the content of a sourced MD file correctly