Mix RTL and LTR

How to use both LTR and RTL languages in one content? It seems hugo doesn’t support it.

However we can fix it manually by this tag in most markdown viewers:

<div dir="rtl">
سلام
</dir>

But hugo removes it:

<!-- raw HTML omitted -->

I have not much experience in css but are there any reasons why not hugo doesn’t use auto direction?

Search this forum.

https://discourse.gohugo.io/search?q=raw%20HTML%20omitted

A quick search of over 20,000 topics will often answer your question. Please be sure to read about requesting help before asking your first question.

Ok. Then I need to write a lot of this tag and this will be difficult. But probably we don’t want to wiping out the issue. Won’t fix?

The way to set directionality is to set the “dir” attribute. No way around that.

You can do it by hardcoding the HTML as you show above. In most cases I think it would be easier to use shortcodes or markdown attributes.

This is an interesting idea. Set dir=auto in something like <main dir=auto> then use JS to cascade the value down. I guess dir=auto is not inherited by descendent elements.

https://stackoverflow.com/a/16520431

1 Like

Thank you. Markdown attributes make code much less and easy to read. Now I did it temporarily:

config.yml:

markup:
  goldmark:
    parser:
      attribute:
        block: true
        title: true

content:

سلام
{dir="rtl"}

Just to be clear… there is nothing to fix here. Hugo’s markdown renderer adheres to the CommonMark and GFM specification. You’d have to request a change to the specification, which will never happen.

Using markdown attributes makes sense to me… good thinking.

I do sites with RTL languages from time to time but have completely missed this possibility. Thanks for poining it out! I think I have a use case for it directly.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.