Hmm, I’ve tried this :

 

```markdown

---

mainfont: Linux Libertine O

lang: en

---

 

The Markdown for the span is: This is Hebrew text [בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃]{dir=rtl}.

 

The Markdown for the div is:

 

::: {dir=rtl}

בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃

:::

```

 

But I’m getting the same error. Looking at the template it seems that there are some definitions to make \RL work with pdftex, but not with lualatex or xelatex.

 

I can however use this :

 

```markdown

---

mainfont: Linux Libertine O

lang: en

---

 

The Markdown for the span is: This is Hebrew text בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃.

 

The Markdown for the div is:

 

בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃

```

 

i.e., no spans or divs at all !

 

This gives okish results with

pandoc input.md -o output.pdf --pdf-engine=lualatex

(Apart from the missing characters, probably cantilation marks. A font with better hebrew support might give better results.)

This works with lualatex because babel’s built-in bidi algorithm is activated in that case. It won’t work with xelatex, though.

 

If you add the language variables for these pieces you will also be able to change the fonts for these pieces.

 

```markdown

---

mainfont: Linux Libertine O

lang: en

header-includes: \babelfont[hebrew]{rm}{SBL Hebrew}

---

 

The Markdown for the span is: This is Hebrew text בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃.

 

The Markdown for the div is:

 

בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃

 

[בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃]{lang=he}

```

 

pandoc input.md -o output.pdf --pdf-engine=lualatex

 

Denis

 

 

 

 

Von: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> Im Auftrag von BPJ
Gesendet: Montag, 7.
März 2022 21:38
An: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Betreff: Re: Bidirectional Markdown documents to PDF

 

Sorry for late reply. Busy day!

 

From a quick glance at Pandoc's default LaTeX template it seems like activation of bidi support requires you to set the `lang` variable (usually in a Pandoc defaults file or the document metadata) for the main language of the document (I would guess in your case to it-IT, it-CH, en-GB or en-US) because only then is the babel package, and with it bidi support. I hope this helps.

 

You should probably also set the `lang=he` variable on the spans and divs containing the Hebrew text. (Strictly speaking the language code for Ancient Hebrew is hbo, but it seems Pandoc doesn't support it. You might want to open an issue for that.)

 

Here is a lua filter which will save you some typing and make upgrading easier if and when Pandoc supports the hbo tag.

 

``````lua

-- he-lang.lua

-- Pandoc filter which sets the proper dir and lang tags for Hebrew on spans and divs with a class `.he`:

-- 

--     [Hebrew text]{.he}

--   

--     :::he

--     Hebrew paragraph.

--     :::

--

-- If and when Pandoc supports the hbo language tag for Ancient Hebrew

-- you may want to change `elem.attributes.lang = 'he'` into

-- `elem.attributes.lang = 'hbo'`.

 

 

local function handler (elem)

  if elem.classes:includes('he') then

    elem.attributes.dir = 'rtl'

    elem.attributes.lang = 'he'

    return elem

  end

  return nil

end

 

return {

  { Span = handler, Div = handler }

}

``````

 

Den mån 7 mars 2022 11:31Emiliano <gattulli.emiliano-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

I realized that I sent my previous response in a private message!

 

When I try the span, Pandoc generates this error:

 

Error producing PDF.
! Undefined control sequence.
l.66 This is Hebrew text \RL

 

When I try the div, Pandoc generates this error:

 

Error producing PDF.
! LaTeX Error: Environment RTL undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                 
l.66 \begin{RTL}

 

The Markdown for the span is: This is Hebrew text [בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃]{dir=rtl}.

 

The Markdown for the div is:

 

::: {dir=rtl}
בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃
:::

 

The command for Pandoc in the terminal is: pandoc --pdf-engine=xelatex test.md -o test.pdf

 

I am currently running Pandoc v. 2.17.1.1 on a macOS Monterey. Hope this helps!

 

Il giorno domenica 6 marzo 2022 alle 17:53:34 UTC+1 BPJ ha scritto:

Wrap the rtl bits in spans and divs with the variable `dir=rtl`:

 

``````markdown

[rtl text]{dir=rtl}

 

::: {dir=rtl}

RTL paragraph.

:::

``````

 

If the main language is RTL you can use `dir=ltr` for LTR bits instead.

 

See

 

 

 

Den sön 6 mars 2022 16:04Emiliano <gattulli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

Hi everyone! I love Markdown and Pandoc, they are an incredible couple! For my studies, I need to write bidirectional documents prevalently using English/Italian with ancient Hebrew. I have no issue whatsoever when I work with Markdown files. However, when I convert the Markdown document to PDF through Pandoc (using XeLaTex as PDF engine), the Hebrew words are inverted due to the left-to-right default setting. My question is: How can I tell Pandoc to treat specific sentences or words as right-to-left and then go back to the default left-to-right? It is obvious to me that this work should be done in the Markdown document, but I just don't know how! Thanks in advance for your help!

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pandoc-discuss/dbe5712e-c50d-43e9-8046-48d16f5ee1b8n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pandoc-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pandoc-discuss/aed50487-27b8-4ff0-83a6-3bd4bd68b59dn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAo7%2BfR77OO-kxnG98PD6j%2BAbtb3xyHLx9tr_HJJXXXwQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/f169e0fcedb04d2d8bb9d6b0c8ee4219%40unibe.ch.