{"id":23177404,"url":"https://github.com/lazypanda10117/docsify-pdf-embed","last_synced_at":"2025-08-18T11:32:43.714Z","repository":{"id":50747200,"uuid":"156131466","full_name":"lazypanda10117/docsify-pdf-embed","owner":"lazypanda10117","description":"A simple plugin for embedding PDF in Docsify.","archived":false,"fork":false,"pushed_at":"2023-10-02T01:14:39.000Z","size":280,"stargazers_count":55,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-12T13:48:24.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lazypanda10117.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-11-04T22:30:50.000Z","updated_at":"2024-12-12T08:34:27.000Z","dependencies_parsed_at":"2024-01-12T12:55:51.174Z","dependency_job_id":"bed6686c-881e-407e-8185-48156ceb5b4d","html_url":"https://github.com/lazypanda10117/docsify-pdf-embed","commit_stats":null,"previous_names":["lazypanda10117/docsify-pdf-embed-plugin"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazypanda10117%2Fdocsify-pdf-embed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazypanda10117%2Fdocsify-pdf-embed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazypanda10117%2Fdocsify-pdf-embed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lazypanda10117%2Fdocsify-pdf-embed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lazypanda10117","download_url":"https://codeload.github.com/lazypanda10117/docsify-pdf-embed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230227812,"owners_count":18193375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-18T06:34:44.788Z","updated_at":"2024-12-18T06:34:45.352Z","avatar_url":"https://github.com/lazypanda10117.png","language":"JavaScript","readme":"# Docsify PDF Embed Plugin\nA simple plugin for embedding PDF in Docsify with the use of PDFObject.js\n\n#### Simple Installation:\n\nTo use, simply put these 2 lines below where you import the `docsify.min.js` file.\n\n```html\n\u003c!-- PDFObject.js is a required dependency of this plugin --\u003e\n\u003cscript src=\"//cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js\"\u003e\u003c/script\u003e \n\u003c!-- This is the source code of the pdf embed plugin --\u003e\n\u003cscript src=\"path-to-file/docsify-pdf-embed.js\"\u003e\u003c/script\u003e\n\u003c!-- or use this if you are not hosting the file yourself --\u003e\n\u003cscript src=\"//unpkg.com/docsify-pdf-embed-plugin/src/docsify-pdf-embed.js\"\u003e\u003c/script\u003e\n```\n\n\n\nThen, whenever you want to embed a PDF, type the following in the `.md` file that you want to put in:\n\n```markdown\n### Here are some of your previous markdown contents\nblah blah blah\n\n```pdf\n\tpath-to-the-pdf-file\n(``` to close the codeblock)\n```\n\n\n\n![docsify pdf embed plugin demo](resources/docsify-pdf-embed-plugin-demo.png)\n\n\n\n#### Remarks for users who have defined custom markdown parsing rules:\n\nIf you have custom parsing rules for code section of the markdown file (shown below), then you need to follow the next section.\n\n```javascript\nwindow.$docsify = {\n    name: 'some name',\n    repo: 'some git repository',\n    homepage: 'some_homepage.md',\n    notFoundPage: 'some_404_page.md',\n    markdown: {\n \t//If you have defined the follow section, \n        //then you need to follow the steps in the next section.\n        //(only the code section matters in this plugin)\n        /* SECTION START\n        \t\n            code: function(code, lang){\n            \tsome custom functions here\n            \treturn some_custom_results;\n            }\n        \t\n        SECTION END */\n    }\n}\n```\n\n\n\n#### Quick fix for the above problem:\n\nPut the block of code inside the `code: function(code, lang){ //put it here }` (the part that is mentioned above). Then put your previously defined custom parsing rules for markdown code section in the section mentioned in the comment block below.\n\n```javascript\nvar renderer_func = function(code, lang, base=null) { \n\tvar pdf_renderer = function(code, lang, verify) {\n\t\tfunction unique_id_generator(){\n\t\t\tfunction rand_gen(){\n\t\t\t\treturn Math.floor((Math.random()+1) * 65536).toString(16).substring(1);\n\t\t\t}\n\t\t\treturn rand_gen() + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + rand_gen() + rand_gen();\n\t\t}\n\t\tif(lang \u0026\u0026 !lang.localeCompare('pdf', 'en', {sensitivity: 'base'})){\n\t\t\tif(verify){\n\t\t\t\treturn true;\n\t\t\t}else{\n\t\t\t\tvar divId = \"markdown_code_pdf_container_\" + unique_id_generator().toString();\n\t\t\t\tvar container_list = new Array();\n\t\t\t\tif(localStorage.getItem('pdf_container_list')){\n\t\t\t\t\tcontainer_list = JSON.parse(localStorage.getItem('pdf_container_list'));\t\n\t\t\t\t}\n\t\t\t\tcontainer_list.push({\"pdf_location\": code, \"div_id\": divId});\n\t\t\t\tlocalStorage.setItem('pdf_container_list', JSON.stringify(container_list));\n\t\t\t\treturn (\n\t\t\t\t\t'\u003cdiv style=\"margin-top:'+ PDF_MARGIN_TOP +'; margin-bottom:'+ PDF_MARGIN_BOTTOM +';\" id=\"'+ divId +'\"\u003e'\n\t\t\t\t\t\t+ '\u003ca href=\"'+ code + '\"\u003e Link \u003c/a\u003e to ' + code +\n\t\t\t\t\t'\u003c/div\u003e'\n\t\t\t\t);\n\t\t\t} \n\t\t}\n\t\treturn false;\n\t}\n\tif(pdf_renderer(code, lang, true)){\n\t   return pdf_renderer(code, lang, false);\n\t}\n\t/* SECTION START: Put other custom code rendering functions here\n\t\ti.e. If the language of the code block is LaTex, \n\t\tput the code below to replace original code block with the text: \n\t\t'Using LaTex is much better than handwriting!' inside a div container.\n\n\t\tif (lang == \"latex\") {\n\t\t\treturn ('\u003cdiv class=\"container\"\u003eUsing LaTex is much better than handwriting!\u003c/div\u003e');\n\t\t}\n\n\tSECTION END */\n\treturn (base ? base : this.origin.code.apply(this, arguments));\n}\n```\n\n\n\nCongrats! Now you have PDF embedding functionality for your use cases of Docsify.\n\n\n\n__Acknowledgement__:\n\n\u003e Thanks to [njleonzhang](https://github.com/njleonzhang/docsify-edit-on-github/)'s Docsify edit on GitHub plugin for being an inspiration\n","funding_links":[],"categories":["Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazypanda10117%2Fdocsify-pdf-embed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazypanda10117%2Fdocsify-pdf-embed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazypanda10117%2Fdocsify-pdf-embed/lists"}