-
Notifications
You must be signed in to change notification settings - Fork 432
Closed
Milestone
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug. Not a question or feature request.
- The topic is not already reported at Issues. (I've searched it).
- Markor is up to date. See Releases for the latest version. Updates are available from F-Droid and GitHub.
- The bug is still present in the latest development version (git master). (Please download and try the test version of Markor, named Marder. Don't worry; Markor and Marder appear as completely separate applications. You can install both side-by-side, and Markor settings are not touched. In case the issue is resolved there, you don't need to create a bug report. The change will be part of the next Markor update.)
Description
VBA code is not being syntax-highlighted properly
Steps to reproduce
- Copy the VBA script into an MD (Markdown) file
- Switch to Reading View (or Preview mode)
- The VBA code appears only in black text — variables and keywords are not colored (no syntax highlighting)
Information
Android version: 11
Device: vivo Y76s
App Version: 2.15.2
Source
GitHub Releases
Format / File type
Markdown
Additional info / Log
Subject: Feature Request: Add Syntax Highlighting Support for VBA Code Blocks in Markdown Preview
Dear gsantner (or Markor development team),
I hope this message finds you well. First off, thank you for creating and maintaining Markor—it's an incredibly lightweight and versatile Markdown editor for Android, and I've been using it daily for note-taking and code snippets. The offline capabilities and clean interface are standout features.
I'm writing to report a small but noticeable limitation in the Markdown preview mode (Reading View) and suggest a practical solution. When embedding VBA (Visual Basic for Applications) scripts in fenced code blocks within an .md file—like this:
Sub Example()
Dim ws As Worksheet
Set ws = ActiveSheet
MsgBox "Hello, World!"
End Sub
—the code renders as plain black text without any syntax highlighting for keywords (e.g., "Sub", "Dim", "Set") or variables. This makes it harder to read and review VBA macros quickly, especially since Markor already excels at highlighting common languages like JSON, YAML, and even CSV.
From what I can gather, Markor uses a custom syntax highlighting implementation for its supported formats, which is efficient but doesn't yet cover VBA. While VBA isn't a super common Markdown-embedded language, it's essential for Excel automation users (like myself), and adding it would make Markor even more appealing to that niche.
### Practical Suggestion for Implementation
A straightforward, low-effort way to address this could be integrating a lightweight VBA grammar from an open-source library like **Highlight.js** (which Markor might already draw from or could easily incorporate). Here's a step-by-step outline to make it feasible:
1. **Source the Grammar**: Highlight.js has a community-contributed VBA highlighter (available in their core library or as an extension). You can grab the grammar file from their GitHub repo: https://github.com/highlightjs/highlight.js/tree/main/src/languages/vba.js. It's just a simple JavaScript object defining keywords, operators, and patterns—under 200 lines.
2. **Integration Steps**:
- Add the VBA grammar to Markor's existing syntax highlighter bundle (likely in the `static/libs/highlight/` directory based on the repo structure).
- Register it in the highlighter initialization code (e.g., via `hljs.registerLanguage('vba', vba);` if using Highlight.js).
- In the Markdown parser/renderer, ensure fenced blocks with `vba` as the language identifier trigger this new rule. This should only affect preview mode and keep performance intact, as VBA blocks are typically short.
- Test with a sample .md file containing the block above—keywords should then appear in blue/purple (or your theme's code colors), variables in white/gray, etc.
3. **Fallback for Edge Cases**: For unrecognized languages, keep falling back to plain text (as it does now) to avoid any breakage.
This change would take minimal time (likely under an hour for someone familiar with the codebase) and could be a quick win in a future release. If you'd like, I can contribute a pull request with the integrated grammar—just let me know!
In the meantime, as a workaround for users like me, I've been switching to the editor mode for quick VBA reviews or using external tools like VS Code for syntax-colored previews before pasting into Markor. But native support here would be a game-changer.
Thanks again for your open-source work and for considering this. Keep up the great job—Markor is one of the best FOSS apps on the Play Store.
Best regards,
xingbanyelan-51
Android User & VBA EnthusiastMetadata
Metadata
Assignees
Labels
No labels


