Add Markdown Support to NetJournal Web Journal
Now it's time to address the user experience. Nobody wants a journal that only supports text + emoji + ASCII art.
So, thinking about it, the best solution would be Markdown.
Inspiration
I asked GPT, and it gave a great example.
https://devv.ai/zh/search?threadId=dbr3kt6te3uo
The core code is this little snippetPractice
Copy this snippet into our index.html, add a card that shows the rendered effect of the Markdown text we're currently typing.
We can also integrate this rendering effect into the display list.
During debugging, I found an issue. If I write relatively complex content in my journal, it will contain symbols like [] ! () #, along with line breaks.
When I call the API in index.html to query a single record, it reports an error about the JSON format. But when I use loadKV to query everything, it works fine.
I looked at the code and found that the loadKV implementation uses the API's qryAll command. It first uses JSON.parse to build a preliminary JSON structure, fills the data structure with some JS syntax, and then uses JSON.stringify to convert it to JSON data before returning it via HTTP.
But the implementation of the API's qry command bluntly concatenates JSON-formatted strings directly.
I think this crude approach doesn't handle strings with complex content well when inserting them into the JSON format.After changing it to the same approach as qryAll, the problem was resolved.
========
The End
Github: https://github.com/crazypeace/url-Shorten-Worker/
Demo: https://journal.crazypeace.workers.dev/journaljournal



