Logo

dev-resources.site

for different kinds of informations.

The Final Stretch of My Open Source Journey: Part 2

Published at
11/29/2024
Categories
markdown
opensource
webdev
typescript
Author
majd_almnayer_2101
Author
18 person written this
majd_almnayer_2101
open
The Final Stretch of My Open Source Journey: Part 2

For the second week of my final open source course assignment, I decided to contribute once again to Hugging Face's chat-ui!

The issue I created was to add Markdown rendering to user messages that are sent and stored. At the time, user messages were being displayed as unrendered markdown text.

To tackle this, I created an issue detailing my planned approach. I intended to use Marked to conditionally render certain markdown elements into HTML. After diving deep into Marked's documentation, I discovered this was indeed possible - you can simply disable the elements you don't want to render into HTML!

As I started working on the implementation, I noticed something interesting: there was already a MarkdownRenderer component in place. This component was being used to render the LLM's replies from Markdown into HTML. However, it wasn't working properly for my use case.

Strangely, while the Markdown was being converted to HTML, the elements weren't displaying on-screen - they were showing up as strings instead. This behavior was puzzling, as the code appeared correct after multiple reviews. I even started doubting my understanding and created a new empty project with TailwindCSS, copying chunks of HTML and CSS from the chat-ui project to test pieces individually. Everything worked fine in isolation.

After several hours of code review, I finally spotted something unfamiliar in the Markdown Renderer component: a function called escapeHTML was being used to escape HTML, even though DOMPurify was already being used for sanitization right after!

The solution? I deleted this function, and suddenly everything worked perfectly! The markdown was now rendering properly on screen, and I could even edit the response.

The entire process took over 30 hours collectively, and the result was deleting a single line of code! Sometimes the simplest solutions are the hardest to find.

What remains is for me to implement Markdown Rendering to the user messages, and allow the user to modify their previously sent messages as well!

markdown Article's
30 articles in total
Favicon
Converting documents for LLM processing β€” A modern approach
Favicon
Use LateX in Astro.js for Markdown Rendering
Favicon
Markdown Syntax & Features: A Comprehensive 2025 Guide
Favicon
Converting documents for LLM processing β€” A modern approach
Favicon
πŸŽ„ A Christmas Gift for Developers: FileToMarkdown!
Favicon
Callout Blocks in a New Way
Favicon
David Blue's Handy Test Document
Favicon
NanoMD: Lightweight Markdown Editor
Favicon
colorize chatgpt with markdown
Favicon
Turning search results into Markdown for LLMs
Favicon
The Final Stretch of My Open Source Journey: Part 2
Favicon
Asking for feedback on open source CLI tool that exports Markdown to PDF using html and css templates(MDExport)
Favicon
Deep Dive into Microsoft MarkItDown
Favicon
NanoMD: θΌ•ι‡εŒ– Markdown 編輯器
Favicon
obsidian neovim markdown
Favicon
6 free Markdown (.md) WYSIWYG desktop Editors – Part3
Favicon
Cross Platform Blog Publishing Automation: Write Once, Publish Everywhere
Favicon
Getting Started with Blog Automation: A Test Post
Favicon
Transform Your Codebase into Comprehensive Documentation with Markdown
Favicon
Django Day DK 2024: I was there
Favicon
TypeScript and ReactMarkdown: A Tale of Types, Tears, and Triumph
Favicon
Level Up Your GitHub Profile: A Complete Guide to Stand Out and Shine
Favicon
Logseq, un Γ©diteur puissant pour optimiser vos prises de notes
Favicon
Introduction to Markup Languages
Favicon
Boost Your Productivity with VS Code and .vscode for Dev.to Markdown
Favicon
πŸ› οΈ How to Create an Awesome GitHub Profile Using Markdown
Favicon
πŸ› οΈ How to Create an Awesome GitHub Profile Using Markdown
Favicon
Build a static website with Markdown content, using Nuxt and Fusionable (server API approach)
Favicon
Boost Your Productivity with VS Code and .vscode for Dev.to Markdown
Favicon
Today’s new knowledge #8(Markdown)

Featured ones: