[PR #718] [MERGED] Show Plain Text in Preview for Unrecognized Languages (#698) #864

Closed
opened 2026-03-03 00:23:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BoostIO/BoostNote-App/pull/718
Author: @guneskaan
Created: 12/13/2020
Status: Merged
Merged: 12/14/2020
Merged by: @Rokt33r

Base: masterHead: blank-code-block-unknown-languages


📝 Commits (2)

  • 519b802 Preview Plain Text for Unrecognized Languages
  • 511c30f Re-sructure If Block

📊 Changes

1 file changed (+19 additions, -15 deletions)

View changed files

📝 src/components/atoms/MarkdownPreviewer.tsx (+19 -15)

📄 Description

Fixed #698.

Currently, we display invisible text when the language specified for the code block is not recognized.
This is because in MarkdownPreviewer.tsx: rehypeCodeMirrorAttacher(), there is an edge case where if language is not null but there is no mime found for this language that can be found in CodeMirror.findModeByName, we set node.children to [].

Fix this case by returning early before the node.children = cmResult assignment.

Tested with following languages after applying the change above:
java -> rendered with java highlighting
123f (made up language) -> rendered as plain text
(empty) -> rendered as plain text


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BoostIO/BoostNote-App/pull/718 **Author:** [@guneskaan](https://github.com/guneskaan) **Created:** 12/13/2020 **Status:** ✅ Merged **Merged:** 12/14/2020 **Merged by:** [@Rokt33r](https://github.com/Rokt33r) **Base:** `master` ← **Head:** `blank-code-block-unknown-languages` --- ### 📝 Commits (2) - [`519b802`](https://github.com/BoostIO/BoostNote-App/commit/519b8024307d7f9d027cde7ce8c85b621347aba0) Preview Plain Text for Unrecognized Languages - [`511c30f`](https://github.com/BoostIO/BoostNote-App/commit/511c30fd5bb9b4e27abcdf31b1755cad850f241d) Re-sructure If Block ### 📊 Changes **1 file changed** (+19 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src/components/atoms/MarkdownPreviewer.tsx` (+19 -15) </details> ### 📄 Description Fixed #698. Currently, we display invisible text when the language specified for the code block is not recognized. This is because in `MarkdownPreviewer.tsx: rehypeCodeMirrorAttacher()`, there is an edge case where if language is not null but there is no mime found for this language that can be found in `CodeMirror.findModeByName`, we set `node.children` to `[]`. Fix this case by returning early before the `node.children = cmResult` assignment. Tested with following languages after applying the change above: java -> rendered with java highlighting 123f (made up language) -> rendered as plain text (empty) -> rendered as plain text --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 00:23:32 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/BoostNote-App#864
No description provided.