public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Bidirectional Markdown documents to PDF
Date: Mon, 7 Mar 2022 21:37:33 +0100	[thread overview]
Message-ID: <CADAJKhAo7+fR77OO-kxnG98PD6j+Abtb3xyHLx9tr_HJJXXXwQ@mail.gmail.com> (raw)
In-Reply-To: <aed50487-27b8-4ff0-83a6-3bd4bd68b59dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 5484 bytes --]

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
>>
>> https://pandoc.org/MANUAL.html#language-variables under "dir"
>>
>>
>> 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...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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
>>> <https://groups.google.com/d/msgid/pandoc-discuss/dbe5712e-c50d-43e9-8046-48d16f5ee1b8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/aed50487-27b8-4ff0-83a6-3bd4bd68b59dn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/aed50487-27b8-4ff0-83a6-3bd4bd68b59dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

[-- Attachment #2: Type: text/html, Size: 8525 bytes --]

  parent reply	other threads:[~2022-03-07 20:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-06 15:03 Emiliano
     [not found] ` <dbe5712e-c50d-43e9-8046-48d16f5ee1b8n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-06 16:53   ` BPJ
     [not found]     ` <CADAJKhBx55tiRuvJqQGQGapLsi21PcWayCagBtj8wUb27S4sTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-03-07 10:30       ` Emiliano
     [not found]         ` <aed50487-27b8-4ff0-83a6-3bd4bd68b59dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-03-07 20:37           ` BPJ [this message]
     [not found]             ` <CADAJKhAo7+fR77OO-kxnG98PD6j+Abtb3xyHLx9tr_HJJXXXwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-03-08  9:15               ` AW: " denis.maier-NSENcxR/0n0
     [not found]                 ` <f169e0fcedb04d2d8bb9d6b0c8ee4219-NSENcxR/0n0@public.gmane.org>
2022-03-08 16:44                   ` John MacFarlane
     [not found]                     ` <m25yoov1fn.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2022-03-09 14:43                       ` Emiliano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADAJKhAo7+fR77OO-kxnG98PD6j+Abtb3xyHLx9tr_HJJXXXwQ@mail.gmail.com \
    --to=melroch-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).