Skip to content
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

Right to left writting is now possible #946

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ discord_id: # your discord id (18-digit unique numerical identifier)
contact_note: >
You can even add a little note about which of these is the best way to reach you.


# -----------------------------------------------------------------------------
# Right-to-left scripts
# -----------------------------------------------------------------------------
rtl_langs: ["ar","arc","az","dv","he","ku","fa","ur"]

# -----------------------------------------------------------------------------
# Analytics and search engine verification
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -261,7 +267,7 @@ jekyll-archives:
tag: '/blog/tag/:name/'
category: '/blog/category/:name/'

display_tags: ['formatting', 'images', 'links', 'math', 'code'] # this tags will be dispalyed on the front page of your blog
display_tags: ['formatting', 'images', 'links', 'math', 'code', 'internationalization'] # this tags will be dispalyed on the front page of your blog

# -----------------------------------------------------------------------------
# Jekyll Scholar
Expand Down
3 changes: 2 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@{{ site.fontawesome.version }}/css/all.min.css" integrity="{{ site.fontawesome.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/academicons@{{ site.academicons.version }}/css/academicons.min.css" integrity="{{ site.academicons.integrity }}" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">

<!-- Code Syntax Highlighting -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jwarby/jekyll-pygments-themes@master/{{ site.highlight_theme_light | append: '.css' }}" media="" id="highlight_theme_light" />

Expand Down
63 changes: 38 additions & 25 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,46 @@

<!-- Content -->
<div class="container mt-5">
{% if page.toc and page.toc.sidebar %}
{% if page.toc.sidebar == "right" %}
<div class="row">
<!-- main content area -->
<div class="col-sm-9">
{{ content }}
</div>
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
</div>
<div {% if site.rtl_langs contains page.lang %}dir="rtl" align="right"{% endif %}>
{% if page.toc and page.toc.sidebar %}

<!-- revert the side bar for rtl -->
{% assign placement = page.toc.sidebar %}
{% if site.rtl_langs contains page.lang %}
{% if page.toc.sidebar == "right" %}
{% assign placement = "left" %}
{% else %}
{% assign placement = "right" %}
{% endif %}
{% endif %}

{% if placement == "right" %}
<div class="row">
<!-- main content area -->
<div class="col-sm-9">
{{ content }}
</div>
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
</div>
{% else %}
<div class="row">
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
<!-- main content area -->
<div class="col-sm-9">
{{ content }}
</div>
</div>
{% endif %}
{% else %}
<div class="row">
<!-- sidebar, which will move to the top on a small screen -->
<div class="col-sm-3">
<nav id="toc-sidebar" class="sticky-top"></nav>
</div>
<!-- main content area -->
<div class="col-sm-9">
{{ content }}
</div>
</div>
{{ content }}
{% endif %}
{% else %}
{{ content }}
{% endif %}
</div>
</div>

<!-- Footer -->
Expand Down
2 changes: 1 addition & 1 deletion _layouts/distill.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{%- include header.html %}

<!-- Content -->
<div class="post distill">
<div class="post distill" {% if site.rtl_langs contains page.lang %}dir="rtl" align="right"{% endif %}>

<d-title>
<h1>{{ page.title }}</h1>
Expand Down
74 changes: 74 additions & 0 deletions _posts/2022-10-15-rtl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
layout: post
title: Right to left scripting
date: 2022-10-15
description: you can also write from right to left
lang: fa
tags: internationalization formatting math code
category: internationalization
---

# عنوان
این یک پست نمونه برای سنجش نوشتارهای راست‌به‌چپ است.


## فرمول‌نویسی
فرمول‌ها هم مانند کد به درستی به نمایش در‌خواهند آمد:


$$
\sum_{k=1}^\infty |\langle x, e_k \rangle|^2 \leq \|x\|^2
$$

## کد
کدها هم‌چنان مانند قبل از چپ‌به‌راست خواهند بود.

```python
if lang=="rtl"
print("I am a right-to-left script!")
```
arashgmn marked this conversation as resolved.
Show resolved Hide resolved

## بلاک
بلاک‌ها همواره چپ‌چین خواهند ماند:

---
layout: page
title: project
description: a project with a background image
img: /assets/img/12.jpg
---
arashgmn marked this conversation as resolved.
Show resolved Hide resolved

حتی اگر به زبان‌های راست‌به‌چپ نوشته شوند:

---
صفحه‌بندی: صفحه
عنوان: پروژه
توضیحات: یک پروژه با تصویر زمینه
---

## نقل‌قول
> نقل‌قول‌ها به این شکل به نمایش درخواهند آمد.
arashgmn marked this conversation as resolved.
Show resolved Hide resolved

زیباتر خواهد بود اگر خط عمودی به راست انتقال داده شود. این کار با ویرایش _base.scss امکان‌پذیر است:

```scss
blockquote {
background: var(--global-bg-color);
border-left: 2px solid var(--global-theme-color); // change to border-right:
margin: 1.5em 10px;
padding: 0.5em 10px;
font-size: 1.2rem;
}

...


.post-content{
blockquote {
border-left: 5px solid var(--global-theme-color); // change to border-right: ...
padding: 8px;
}
}
```
Comment on lines +54 to +72
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of providing a suggestion on how to update CSS here, it's better the add rtl-conditional style overrides directly to _scss/_base.scss, like this (I haven't tested the code below, so please adjust as necessary):

rtl blockquote {
    border-left: none;
    border-right: 2px solid var(--global-theme-color);
}
.post-content {
    rtl blockquote {
        border-left: none;
        border-right: 2px solid var(--global-theme-color);
    }
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check this locally, and push a new commit if it worked on my side.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review my new commit (lines 71-74 and 971-977).


منطقا باید بتوان با توجه به جهت‌گیری متن (rtl یا ltr) صفت مناسب را تعریف کرد. اما من چندان به sass مسلط نیستم. امیدوارم فرد مسلط‌تری این مشکل کوچک را رفع کند.
Loading