esteinmann / chatgpt-convdown

GNU General Public License v3.0
56 stars 7 forks source link

Format code blocks. #30

Open mattjoyce opened 1 year ago

mattjoyce commented 1 year ago

Enhancement Request

GPT will often show code in a specific style. As this plugin saves as markdown, it would be nice to detect gpt code blocks and format the code in the save document using markdown backticks to indicate code.

here is a typical gpt code response, with content section shown.

<div class="bg-black rounded-md mb-4">
<div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"><span>python</span><button class="flex ml-auto gap-2"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div><div class="p-4 overflow-y-auto">

<code class="!whitespace-pre hljs language-python">
<span class="hljs-built_in">print</span>(<span class="hljs-string">"Hello, World!"</span>)
</code>

</div></div>