From: Guenter M. <mi...@us...> - 2021-01-17 16:47:17
|
On 2021-01-15, Abdullah Al-hadab wrote: > Hi , > I have translated docutils to Arabic, and it is working fine, however, > I am getting the direction wrong ( text is aligned to left) > [cid:image003.jpg@01D6EB29.AA4121B0] > I saw these two scripts on Docutils FAQ (Frequently Asked Questions) > (sourceforge.io)<https://docutils.sourceforge.io/FAQ.html#can-i-produce-documents-in-right-to-left-languages> > , which should solve this issue. If it is only about alignment, maybe you just need a custom stylesheet. Maybe we can design a "rtl.css" stylesheet for use with RTL languages? (Unfortunately, I don't understand any language that uses an RTL script.) Did you set --language=arabic (or farsi, hebrew,...)? You can also set the language for individual elements with the "class" argument or "class" directive. A class value of "language-mylang" is written as `lang=mylang` in HTML. > I followed the instruction but when I run rst2html_bidi I get the > following error > AttributeError: 'Element' object has no attribute 'dir' > Exiting due to error. Use "--traceback" to diagnose. > Please report errors to <doc...@li...>. > Include "--traceback" output, Docutils version (0.17b.dev [release]), > Python version (3.7.9), your OS type & version, and the > command line used. Looking at docutils/docs/ref/doctree.html, I realize that "dir" is not standard attribute in Docutils. It seems to be an addition by the "hibidy"-enhanced custom writer. > Traceback (most recent call last): > File "./rst2html_hibidi.py", line 38, in <module> > publish_cmdline(writer=HiBiDiWriter(), description=description) > File "/home/geohadab/github/docutils/docutils/docutils/core.py", line 355, in publish_cmdline > config_section=config_section, enable_exit_status=enable_exit_status) > File "/home/geohadab/github/docutils/docutils/docutils/core.py", line 220, in publish > output = self.writer.write(self.document, self.destination) > File "/home/geohadab/github/docutils/docutils/docutils/writers/__init__.py", line 79, in write > self.translate() > File "./rst2html_hibidi.py", line 30, in translate > self.output = hibidi.hibidi_unicode(self.output, encoding=self.destination.encoding) > File "/home/geohadab/github/hibidi.py", line 34, in hibidi_unicode > return hibidi_str(u.encode(encoding), root).decode(encoding) > File "/home/geohadab/github/hibidi.py", line 39, in hibidi_str > hibidi_dom(doc, root) > File "/home/geohadab/github/hibidi.py", line 50, in hibidi_dom > assign_dirs(node) > File "/home/geohadab/github/hibidi.py", line 101, in assign_dirs > assign_dirs(child, node.dir) > File "/home/geohadab/github/hibidi.py", line 101, in assign_dirs > assign_dirs(child, node.dir) > File "/home/geohadab/github/hibidi.py", line 97, in assign_dirs > if not node.dir: > AttributeError: 'Element' object has no attribute 'dir' This shows that the problem is in the 3rt-party module "hibidy.py". Maybe making line 97 failproof changing it to something like if not getattr(node, "dir"): helps. (But I don't know which default to use and whether there are other follow-up errors.) Günter |