[GH-ISSUE #1309] Advanced Editor: .md files not detected as Markdown – requires manual mapping #836

Open
opened 2026-03-02 16:01:43 +03:00 by kerem · 2 comments
Owner

Originally created by @elektrischerwalfisch on GitHub (Apr 7, 2025).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/1309

Hi there,

I noticed that when editing .md (Markdown) files in TinyFileManager, the Ace Editor (Advanced editor view) does not activate Markdown syntax highlighting by default. Instead, it falls back to plain text, while other file types like .js or .php are highlighted correctly.

Upon checking the code, I found that the editor mode is set using this line:

editor.getSession().setMode({
    path: "ace/mode/<?php echo $ext; ?>",
    inline: true
});

However, $ext resolves to 'md' for Markdown files, and Ace does not have a mode called md — it expects 'markdown'. As a result, syntax highlighting doesn't work out of the box for .md files.

Suggested Fix:

A simple conditional mapping like this solves the problem:

if ($ext === 'md') {
    $ext = 'markdown';
}

You could either:

  • Add this line near where $ext is defined,
  • Or apply it just before the editor is initialized.

Why this matters:

Markdown is a very common format for README files, notes, and static content, so it would be great if it worked with proper highlighting by default.

Thanks for your great work on this project! TinyFileManager is incredibly useful and lightweight — really appreciated. 😊

Originally created by @elektrischerwalfisch on GitHub (Apr 7, 2025). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/1309 Hi there, I noticed that when editing `.md` (Markdown) files in TinyFileManager, the Ace Editor (Advanced editor view) does not activate Markdown syntax highlighting by default. Instead, it falls back to plain text, while other file types like `.js` or `.php` are highlighted correctly. Upon checking the code, I found that the editor mode is set using this line: ```js editor.getSession().setMode({ path: "ace/mode/<?php echo $ext; ?>", inline: true }); ``` However, `$ext` resolves to `'md'` for Markdown files, and Ace does **not** have a mode called `md` — it expects `'markdown'`. As a result, syntax highlighting doesn't work out of the box for `.md` files. ### Suggested Fix: A simple conditional mapping like this solves the problem: ```php if ($ext === 'md') { $ext = 'markdown'; } ``` You could either: - Add this line near where `$ext` is defined, - Or apply it just before the editor is initialized. ### Why this matters: Markdown is a very common format for README files, notes, and static content, so it would be great if it worked with proper highlighting by default. Thanks for your great work on this project! TinyFileManager is incredibly useful and lightweight — really appreciated. 😊
Author
Owner

@yucho123987 commented on GitHub (Apr 8, 2025):

Maybe path: "ace/mode/<?php echo $ext == 'md' ? 'markdown' : $ext; ?>", is better, I think.😁

<!-- gh-comment-id:2787896147 --> @yucho123987 commented on GitHub (Apr 8, 2025): Maybe `path: "ace/mode/<?php echo $ext == 'md' ? 'markdown' : $ext; ?>",` is better, I think.😁
Author
Owner

@elektrischerwalfisch commented on GitHub (Apr 9, 2025):

Basically a good idea as it requires less code! But I wonder if eventually ace-editor might become able to recognize md-files correctly in some future releases, which would make this modification obsolete again.
So it might be more sustainable to mark this modification as a temporay fix to be easily found & removed again in the future. Currently I use this:

            <?php 
                /***********************************************
                 * Fix for ace editor:
                 * map .md extension to markdown mode
                 * needed because currently (2025/04/09) ace editor doesn't recognize 'md')
                 ***********************************************/
                if ($ext === 'md') {
                    $ext = 'markdown';
                }
            ?>
<!-- gh-comment-id:2788548880 --> @elektrischerwalfisch commented on GitHub (Apr 9, 2025): Basically a good idea as it requires less code! But I wonder if eventually ace-editor might become able to recognize md-files correctly in some future releases, which would make this modification obsolete again. So it might be more sustainable to mark this modification as a temporay fix to be easily found & removed again in the future. Currently I use this: ``` <?php /*********************************************** * Fix for ace editor: * map .md extension to markdown mode * needed because currently (2025/04/09) ace editor doesn't recognize 'md') ***********************************************/ if ($ext === 'md') { $ext = 'markdown'; } ?> ```
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/tinyfilemanager#836
No description provided.