actualNoteContentPart: ## Example case: Building the Note2PDF plugin
  One plugin authored primarily by Phind was the [Note2PDF plugin](https://public.amplenote.com/qzwwT9QTh9LUF93iZoUauwZd) . To start, I queried "Example convert [markdown text]()  to download PDF in Javascript." The code returned initially by Phind (not shown because it wasn't very useful) didn't work because it expected to be able to download and wave an npm package, which isn't possible in a dynamically loaded plugin environment. 
  
  So, in [the "ask a follow up question" section](https://images.amplenote.com/b456a2e4-d93b-11ed-b6ce-f2e3384d8128/50a1c807-c14d-4f75-9389-37a1383ed9aa.png) , located at the bottom of every Phind result, I clarified the initial prompt with "Rewrite the markdown to plugin implementation to use libraries that can be loaded by the browser dynamically, by fetching the scripts from a CDN." This gave something very close to workable:
  
  
  First version of Note2PDF plugin, as generated by AI
  
  
  From here, I asked Phind two more follow up questions:
  "Rewrite the above example without using the marked library." I submitted this follow up question because the code above didn't work the first time I tried it, and why debug a problem when you can easily swap in a substitute library that might Just Work? Phind substituted the showdown library, which succeeded on converting Markdown to HTML on its first try. 💫
  "Rewrite the above example without using the pdfkit library." As with the above, the library didn't work when I first tried it, so I asked for an alternate library. Phind rewrote it using js2pdf and so far that has successfully generated a PDF from Javascript
  How did I know to ask those follow up questions? I took the initial code I was given (in the screenshot above), [broke it into a couple methods within my plugin](https://images.amplenote.com/b456a2e4-d93b-11ed-b6ce-f2e3384d8128/2484108f-07cf-498c-a2f1-79bf94a83fe9.png) , [opened Chrome Web Inspector](https://developer.chrome.com/docs/devtools/) , and [tried running the plugin on the note](https://images.amplenote.com/b456a2e4-d93b-11ed-b6ce-f2e3384d8128/8341d764-8cc1-44f1-977a-619c5b3f81be.png)  where I was building the plugin. I could see in Chrome Web Inspector that [there were ambiguous Javascript errors being generated upon running the code](https://images.amplenote.com/b456a2e4-d93b-11ed-b6ce-f2e3384d8128/97033a72-fcf1-4136-ade2-966b318eac9a.png) . Since the error mentioned the "marked" library, I asked Phind to replace that library with something else. When the other library (pdfkit) also ended up generating an exception, it too was replaced for a library that worked on first try.
  
  Along the way, to get a peek at what these unknown libraries were returning, I added console.log statements to see what the plugin was seeing:
  
  
  Upon inserting console.log statements, you can view the "Console" tab in Chrome Inspector to see what objects are being returned by libraries
  
  
  These statements will allow you to dig in to the objects that your code is receiving, so you can diagnose which steps within the conversion process are working correctly, and which aren't:
  
  
  Viewing Javascript variables as revealed by console.log
  
  
  As is evident by this output, the step that converts markdown to HTML is working like a charm. The step that converts HTML to a PDF seems to work, though one could click-to-expand any of those visible methods (addPage, setPage, etc) to confirm that the PDF was rendered correctly. The only remaining problem here is the download step. And the solution to the download problem is to reference the [Amplenote Plugin API docs](https://www.amplenote.com/help/developing_amplenote_plugins)  and discover the applicable method for downloading a saved file. ✨
processedNoteContent: ---
  title: Guide to Building/Developing Plugins (Beginner ...
  headers: ## Example case: Building the Note2PDF plugin
  ---
  Example case: Building the Note2PDF plugin
  One plugin authored primarily by Phind was the [Note2PDF plugin](https://public.amplenote.com)`
   . To start, I queried "Example convert [markdown text]()
    to download PDF in Javascript." The code returned initially by Phind (not shown because it wasn't very useful) didn't work because it expected to be able to download and wave an npm package, which isn't possible in a dynamically loaded plugin environment. So, in [the "ask a follow up question" section](https://images.amplenote.com)`
   , located at the bottom of every Phind result, I clarified the initial prompt with "Rewrite the markdown to plugin implementation to use libraries that can be loaded by the browser dynamically, by fetching the scripts from a CDN." This gave something very close to workable: First version of Note2PDF plugin, as generated by AI From here, I asked Phind two more follow up questions:
  "Rewrite the above example without using the marked library." I submitted this follow up question because the code above didn't work the first time I tried it, and why debug a problem when you can easily swap in a substitute library that might Just Work? Phind substituted the showdown library, which succeeded on converting Markdown to HTML on its first try. 💫
  "Rewrite the above example without using the pdfkit library." As with the above, the library didn't work when I first tried it, so I asked for an alternate library. Phind rewrote it using js2pdf and so far that has successfully generated a PDF from Javascript
  How did I know to ask those follow up questions? I took the initial code I was given (in the screenshot above), [broke it into a couple methods within my plugin](https://images.amplenote.com)`
   , [opened Chrome Web Inspector](https://developer.chrome.com)`
   , and [tried running the plugin on the note](https://images.amplenote.com)`
    where I was building the plugin. I could see in Chrome Web Inspector that [there were ambiguous Javascript errors being generated upon running the code](https://images.amplenote.com)`
   . Since the error mentioned the "marked" library, I asked Phind to replace that library with something else. When the other library (pdfkit) also ended up generating an exception, it too was replaced for a library that worked on first try. Along the way, to get a peek at what these unknown libraries were returning, I added console.log statements to see what the plugin was seeing: Upon inserting console.log statements, you can view the "Console" tab in Chrome Inspector to see what objects are being returned by libraries These statements will allow you to dig in to the objects that your code is receiving, so you can diagnose which steps within the conversion process are working correctly, and which aren't: Viewing Javascript variables as revealed by console.log As is evident by this output, the step that converts markdown to HTML is working like a charm. The step that converts HTML to a PDF seems to work, though one could click-to-expand any of those visible methods (addPage, setPage, etc) to confirm that the PDF was rendered correctly. The only remaining problem here is the download step. And the solution to the download problem is to reference the [Amplenote Plugin API docs](https://www.amplenote.com)`
    and discover the applicable method for downloading a saved file. ✨
noteTitle: Guide to Building/Developing Plugins (Beginner to Advanced)