cartertemm / AI-content-describer

NVDA add-on that provides descriptions for controls and images, powered by GPT4
GNU General Public License v2.0
48 stars 24 forks source link

Rendering Markdown #4

Closed aaronr7734 closed 8 months ago

aaronr7734 commented 12 months ago

There are many situations where I've had GPT4 create tables, organize text into headings and lists, etc. Yes, even for image descriptions. Markdown is the most token efficient way to do this. So I was wondering if for those of us using the browseableMessage if you could come up with a way to render this.

One way I've briefly explored is using Markdown (the python module) to convert GPT's output to html, then displaying that html via isHtml on the browseableMessage. Thoughts?

cartertemm commented 12 months ago

This would be an easy feature to add, or first contribution if someone gets to it before I do. Tasks would include:

mzanm commented 11 months ago

I was trying to work on this, and it was harder than expected. NVDA bundles an incomplete version of html with html.parser missing, which markdown needs. I've tried inserting module path at 0 to make it load the html module I copied, but that doesn't work either. It seems it always imports the bundled html in NVDA. I've thought of modifying the copied html and renaming it and modifying markdown to import it instead, but I'm not sure about it and how it'll be affected by markdown updates, the latest version of markdown that supports 3.7 is 3.4.4 so that might be not an issue. Is there another solution or this solution is acceptable? Thank you.

cartertemm commented 11 months ago

Thanks @mzanm for taking this on.

There is another option that would preserve compatibility with later versions of the markdown module, but it requires pulling in extra dependencies and pieces of the standard library that NVDA does not, along with some annoyingly hacky tampering with sys.modules. Once I have more time, I'll see if I can get it working and let you know the result.