sawmac / display-markdown

JS Rendering of Markdown Files
29 stars 16 forks source link

Fails loading markdown other than README.md #3

Open adhuliya opened 6 years ago

adhuliya commented 6 years ago

Markdown files with other than default name fails to load using the global variable file declared in the <head> element:

<script>
var file = "other.md";
</script>

When the following line in render.js tests the condition,

var file = file || "README.md";

the first access to the file object is always undefined (due to hoisting), hence README.md is chosen by default.

Changing the above line to:

var file = this.file || "README.md";

solves the issue for me. (Notice the use of this)