{"id":16939804,"url":"https://github.com/rivy/js-user.markdown-render","last_synced_at":"2026-04-16T07:33:43.937Z","repository":{"id":145940533,"uuid":"89400953","full_name":"rivy/js-user.markdown-render","owner":"rivy","description":"User script to render local markdown files","archived":false,"fork":false,"pushed_at":"2023-11-13T07:26:55.000Z","size":5009,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T06:11:09.162Z","etag":null,"topics":["js-user","markdown","renderer","userscript"],"latest_commit_sha":null,"homepage":null,"language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rivy.png","metadata":{"files":{"readme":"README.mkd","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-25T19:56:04.000Z","updated_at":"2023-11-09T02:03:11.000Z","dependencies_parsed_at":"2023-11-12T02:28:54.067Z","dependency_job_id":"98645668-e874-45b1-814d-52f2074974e1","html_url":"https://github.com/rivy/js-user.markdown-render","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rivy/js-user.markdown-render","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivy%2Fjs-user.markdown-render","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivy%2Fjs-user.markdown-render/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivy%2Fjs-user.markdown-render/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivy%2Fjs-user.markdown-render/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rivy","download_url":"https://codeload.github.com/rivy/js-user.markdown-render/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rivy%2Fjs-user.markdown-render/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31876520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["js-user","markdown","renderer","userscript"],"created_at":"2024-10-13T21:05:32.635Z","updated_at":"2026-04-16T07:33:43.922Z","avatar_url":"https://github.com/rivy.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\n## editors ## (emacs/sublime) -*- coding: utf8-nix; tab-width: 4; mode: markdown; indent-tabs-mode: nil; basic-offset: 2; st-word_wrap: 'true' -*- ## (jEdit) :tabSize=4:indentSize=4:mode=markdown: ## (notepad++) vim:tabstop=4:syntax=markdown:expandtab:smarttab:softtabstop=2 ## modeline (see \u003chttps://archive.is/djTUD\u003e@@\u003chttp://webcitation.org/66W3EhCAP\u003e)\ntitle: README\ntags: markdown, browser, render, UserJS, greasemonkey, tampermonkey\n---\n\n\u003c!DOCTYPE markdown\u003e\u003c!-- markdownlint-disable no-inline-html --\u003e\n\u003cmeta charset=\"utf-8\" content=\"text/markdown\" lang=\"en\"\u003e\n\u003c!-- spell-checker:words greasemonkey tampermonkey Github Github's --\u003e\n\u003c!-- spell-checker:ignore markdownlint TLDR userscript kata --\u003e\n\u003c!-- markdownlint-disable first-header-h1 first-line-h1 header-increment no-inline-html ul-style --\u003e\n\n## `markdown-render`\n\n`markdown-render` is a user javascript, running in-browser, which automatically renders raw local markdown files (eg, \"file://PATH/TO/file.mkd\") into HTML.\n\n\u003cstyle\u003e\nkbd\n{\n  /* modified from https://auth0.github.io/kbd/ */\n  font-family: Consolas, \"Lucida Console\", monospace;\n  display: inline-block;\n  border-radius: 3px;\n  padding: 0px 4px;\n  box-shadow: 1px 1px 1px #777;\n  margin: 2px;\n  font-size: 0.9em;\n  line-height: 1.1;\n  vertical-align: text-bottom;\n  background: #eee;\n  font-weight: 500;\n  color: #555;\n  cursor: pointer;\n  font-variant: small-caps;\n  font-weight: 600;\n\n  /* This two work */\n  /* letter-spacing: 0.5px; */\n  letter-spacing: 1px;\n\n  /* Prevent selection */\n  -webkit-touch-callout: none;\n  -webkit-user-select: none;\n  -khtml-user-select: none;\n  -moz-user-select: none;\n  -ms-user-select: none;\n  user-select: none;\n}\n\u003c/style\u003e\n\n## Setup\n\n1. Setup the browser userscript manager\n   - install the TamperMonkey extension from [TamperMonkey](http://tampermonkey.net/index.php)\n     - for Chrome, it may, alternatively, be installed via the [Chrome web store](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)\n     - for Firefox, it may, alternatively, be installed via [Firefox Add-ons](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey)\n\n2. Enable TamperMonkey scripting of file URLs\n   - Chrome\n     1. open \u003ckbd\u003echrome://extensions\u003c/kbd\u003e\n     2. for the TamperMonkey extension, ENABLE the \u003ckbd\u003eAllow access to file URLs\u003c/kbd\u003e option\n     - for more detailed explanation, see the [TamperMonkey FAQ](http://tampermonkey.net/faq.php#Q204) or [video](http://fastly.tampermonkey.net/images/animated/allow_access_to_file_urls.gif)\u003csup\u003e\u003csmall\u003e [`@`](https://archive.is/ZGnZc)\u003c/small\u003e\u003c/sup\u003e\n   - Firefox ... not needed\n\n3. Install the `markdown-render` userscript\n   1. open \u003chttps://github.com/rivy/js-user.markdown-render/raw/master/dist/markdown-render.user.js\u003e\n   2. CLICK \u003ckbd\u003eInstall\u003c/kbd\u003e in the TamperMonkey installation dialog\n\n\u003e _Optional_ \u0026ac; For best results when reading files with leading HTML/XML-like elements, enable access to all local files for TamperMonkey scripts.\n\u003e\n\u003e \u003cdiv style=\"background:rgba(0, 0, 0, 0.1); font-size:0.8em; line-height:1.4;\"\u003e\n\u003e\n\u003e 1. Open the TamperMonkey Dashboard by clicking on \u003ckbd\u003eDashboard\u003c/kbd\u003e in the TamperMonkey drop-down list from the browser toolbar\n\u003e 2. Select the \u003ckbd\u003eSettings\u003c/kbd\u003e tab\n\u003e 3. In the \u003ckbd\u003eSecurity\u003c/kbd\u003e section, for \u003ckbd\u003eAllow scripts to access local files:\u003c/kbd\u003e, select \u003ckbd\u003eAll local files\u003c/kbd\u003e, and click the \u003ckbd\u003eSave\u003c/kbd\u003e button\n\u003e\n\u003e \u003c/div\u003e\n\u003e\n\u003e This allows `markdown-render` to re-read any local file which may have been misread (and mangled) as HTML/XML instead of 'text/plain'. Notably, this allows _any_ user script to access _any local file_, so use with care.\n\n\u003c!--{blockquote:.--info}--\u003e\n\n## Known Limitations\n\n#### Incorrect interpretation of files with initial HTML tags\n\n- TLDR; when possible, avoid initial HTML/XML-like elements within the markdown file.\n\nWhile most markdown files are correctly interpreted, those with leading HTML/XML-like elements are problematic. Both Chrome and Firefox will interpret and parse a file as HTML if it contains any initial HTML content, even if the file extension is not \".htm\", \".html\", or \".xml\". This interpretation and parsing of the file happens during loading and results in an irretrievable garbling of file contents and a subsequent inability to correctly render the file.\n\nBoth Chrome and Firefox, through various techniques and some extra, manually enabled, user permissions, can be coerced into re-reading the file as text. But the techniques are workarounds and can't expected to work for all future browser versions.\n\nA \"workaround\" is to always use initial content without HTML elements, such as a DOCTYPE declaration (eg, `\u003c!DOCTYPE markdown\u003e` [uppercase 'DOCTYPE' preferred for widest compatibility]). A DOCTYPE declaration works for all browsers and is completely valid markdown. Alternatively, using YAML front matter elements will also prevent the destructive as-HTML interpretation of the file.\n\nAs of 2019-08, Firefox now interprets leading XML elements (eg, `\u003c!DOCTYPE ...\u003e`) as HTML elements, leading to misinterpretation of the file. Chrome still reads the file as pure text.\n\nFor Firefox, any non-HTML/XML character sequence will stimulate a \"text/plain\" interpretation of the file. So, YAML or title text first in the file will work. Notably, for Github's markdown, initial YAML will appear as a table of values at the top of the converted page. Additionally `\u0026nbsp;\u003c!--{style=\"display:none\"}--\u003e\u003c!DOCTYPE markdown\u003e` or `📖\u003c!--{style=\"display:none\"}--\u003e\u003c!DOCTYPE markdown\u003e` will also work although either add an initial blank line, or line with a character, for parsers which don't implement 'markdown-it-decorate' comment-style attribute application.\n\n`\u003c!DOCTYPE markdown\u003e` is currently the best option for Chrome; for Firefox ... the kata is a work-in-progress, but the file _can_ be re-read if the content-type is not \"text/plain\" (or \"text/markdown\"); possibly testing for \"text/html\" and re-reading in that case would be best. Firefox makes the most mistakes, but it's less used and can easily re-read the file (in no noticeable with an SSD), using `\u003c!DOCTYPE markdown\u003e` is likely the best option.\n\n#### Edge isn't usable\n\n- TLDR; use Chrome or Firefox as default handlers for files with markdown file extensions.\n\nMS Edge won't open and render local files, except for files with specific extensions (eg, \".html\"). And there is no current method to enable reading and rendering of new file types / extensions (eg, all the markdown extensions). So, while the script _may_ actually work, it's impossible to test or use at this moment. If a markdown file is opened, it will be pushed to whichever application is setup as the default handler. Luckily, either of the more capable Chrome or Firefox browsers _can_ be set as the default handler for files with the various markdown extensions, which ultimately solves the problem.\n\n## Build\n\n- use NodeJS v16 or earlier; NodeJS v17+ causes build errors and won't package the script\n- recipe:\n\n```shell\nnpm install ## or `npm clean-install` (to use \"package-lock.json\" deps)\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frivy%2Fjs-user.markdown-render","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frivy%2Fjs-user.markdown-render","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frivy%2Fjs-user.markdown-render/lists"}