Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay Markdown Rendering Until Display #91

Open
ssig33 opened this issue Jan 4, 2025 · 3 comments
Open

Delay Markdown Rendering Until Display #91

ssig33 opened this issue Jan 4, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@ssig33
Copy link

ssig33 commented Jan 4, 2025

This software currently renders markdown content to HTML upon receiving a message through the API, and stores it in contentHTML. The PostContent component directly uses contentHTML, which restricts flexibility for developers wanting to adjust rendering settings later. Additionally, preserving both markdown and HTML seems inefficient, though this approach does reduce display load.

I believe storing only markdown in the database and rendering HTML upon display offers greater benefits. While I'm not fully acquainted with the software's specifications, I understand that there might be scenarios where only contentHTML is persisted, and content is not. In such cases, continuity by using existing contentHTML might be necessary. But, delaying rendering maximaizes expandability.

In order to clarify my problem awareness, I will show below what I actually tried to do and what happened. I aimed to extend src/text.ts by integrating markdown-it-highlightjs. The task was straightforward, and I quickly achieved my goal. However, I realized syntax highlighting does not apply to pre-existing posts.

If you agree with my standpoint, I intend to proceed with drafting a pull request. I would appreciate your thoughts.

@dahlia dahlia added the enhancement New feature or request label Jan 4, 2025
@dahlia
Copy link
Owner

dahlia commented Jan 4, 2025

That's a fair point. One thing that I'm concerned about is that during Markdown rendering, we're performing database lookups and HTTP requests to expand the mention syntax (to verify that the mentioned actor actually exists). I'm not sure how performing database lookups and HTTP requests on every render will affect performance. Maybe we need to separate dealing with the mention syntax into a separate step from Markdown rendering. 🤔

Or, as a quick and dirty solution, maybe we could add a button to the administration dashboard that rerenders the Markdown of all past posts. 😅

@ssig33
Copy link
Author

ssig33 commented Jan 4, 2025

I completely overlooked the fact that the existence of actor is resolved at the time of rendering.

I think that adding a “re-render” button to the admin console is a simple and good idea that would at least completely solve my problem.

@dahlia
Copy link
Owner

dahlia commented Jan 4, 2025

If you make a patch to add the re-render button, I'm going to happily review it as soon as possible!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants