Skip to content

Advanced Editor: .md files not detected as Markdown – requires manual mapping #1309

@elektrischerwalfisch

Description

@elektrischerwalfisch

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. 😊

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions