Open OfirSinn opened 8 months ago
Right-to-left support can be added in html by using the dir
attribute with value rtl
:
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta charset="utf-8">
...
See: https://www.w3schools.com/tags/att_global_dir.asp
One possibility is to change the direction based on the configured language.
Another option is to configured the direction in CSS:
html[lang^="he"] *,
html[lang^="fa"] *,
html[lang^="ar"] * {
direction: rtl;
}
It should be noted that changing the text direction does not necessarily play nice with absolute styling. Therefore, additional styling may be necessary to restore the expected page layout.
Generally the html version is preferred, because it still works when CSS is not available. (e.g. when using a screenreader)
I know there is a option to write the html in obisidian, is there a cleaner solution in the quartz files? in other words I'm asking where is it best to place these code snippets (both the html and the css one)?
I know there is a option to write the html in obisidian, is there a cleaner solution in the quartz files? in other words I'm asking where is it best to place these code snippets (both the html and the css one)?
If all your pages are right-to-left:
Change to
<html dir="rtl" lang={lang}>
(You might have to change here too)
For CSS:
html[lang^="he"] *,
html[lang^="fa"] *,
html[lang^="ar"] * {
direction: rtl;
}
In the custom.scss
file.
Please note that additional custom styling might be necessary due to the changed text direction potentially impacting the page layout.
If you want page-specific right-to-left support, you can add a cssclass
to the frontmatter of specific notes and use custom CSS:
In the notes:
---
title: some page with right to left text.
cssclass: rtl-class
---
In the custom.scss
file:
.rtl-class,
.rtl-class * {
direction: rtl;
}
thank you very much!
Hi, I was trying quartz out but very soon noticed the lack of RTL language support, which is makes the existense of an arabic language file in quartz/i18n/locales quite perculiar. I know this is a niche feature, but it seems have been added in 3.2v and now in the most up to date version is absent.
The issue is specific to the html, rtl support for obsidian already exists.
best possible solution would be multi language support (like that of hugo), to have both rtl and ltr in the same file (one line rtl and one line ltr).
but even a full site text direction switch would be enough to satisfy.
if you want a quick look at an RTL file (rendered in LTR) as of now in quartz: https://ofirsinn.github.io/Articles/Home/%D7%96%D7%94-%D7%94%D7%95%D7%90-%D7%A7%D7%95%D7%91%D7%A5-%D7%91%D7%A2%D7%91%D7%A8%D7%99%D7%AA
https://github.com/OfirSinn/Articles/