-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add RTL support for markdown files #1713
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
Conversation
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
emako
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check
| @@ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need to create this file.
Just use the code like:
// Check current UI culture and IsSupportRTL translation setting
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
{
string isSupportRTL = TranslationHelper.Get("IsSupportRTL",
failsafe: bool.TrueString,
domain: Assembly.GetExecutingAssembly().GetName().Name);
if (bool.TrueString.Equals(isSupportRTL, StringComparison.OrdinalIgnoreCase))
isRtl = true;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the unnecessary Translations.config file and simplified the RTL detection to use TranslationHelper.Get() with failsafe value directly, matching the TextViewer pattern exactly. Fixed in c5f6000.
| ".mdc", ".qmd", ".rmd", ".rmarkdown", ".apib", ".mdtxt", ".mdtext" | ||
| }; | ||
|
|
||
| if (supportedExtensions.Any(ext => extension.Equals(ext, StringComparison.OrdinalIgnoreCase))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need to check the extension again in protected string GenerateMarkdownHtml(string path) method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant extension check in GenerateMarkdownHtml method since it only processes markdown files. Simplified the RTL detection logic. Fixed in c5f6000.
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compile error, lost the using System.Linq; here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the missing using System.Linq; statement to fix the compile error. Fixed in 7485b8c.
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
| } | ||
|
|
||
| var html = template.Replace("{{content}}", content) | ||
| .Replace("{{rtl}}", isRtl ? "rtl" : "ltr"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a sapce to align the previous line of .Replace code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the alignment by adding a space to properly align the .Replace method calls. The code now has consistent indentation. Fixed in f2c8273.
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This PR adds comprehensive Right-to-Left (RTL) alignment support for markdown files in QuickLook, following the same pattern used in the TextViewer plugin for *.txt files.
Features Added
IsSupportRTLsettingCtrl+RightShiftfor RTL,Ctrl+LeftShiftfor LTR)Technical Implementation
Files Modified:
Translations.config(NEW) - Added RTL configuration for Arabic and Hebrew localesMarkdownPanel.cs- Added RTL detection logic similar to TextViewermd2html.html- Updated HTML template with RTL support and CSSQuickLook.Plugin.MarkdownViewer.csproj- Include translations as embedded resourceKey Changes:
The implementation follows the existing pattern from TextViewer:
The HTML template now includes:
dir="{{rtl}}"attribute on the<html>elementVisual Demo
The screenshots demonstrate:
Behavior
Automatic RTL Activation:
ar, Hebrewhe)IsSupportRTL=Truetranslation settingManual Control:
Ctrl + Right ShiftCtrl + Left ShiftThis implementation provides seamless RTL support for markdown files, automatically adapting to user's language preferences while maintaining full manual control options, consistent with the existing TextViewer RTL functionality.
Fixes #1705.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.