2

Six years ago somebody asked this question but got no answer and his question was closed. Now I have the same question to ask:

I have prepared BIB data (in biblatex format) for the papers of the volume I'm publishing and would like to put the bibliographical reference lists on the Web site of the publisher.

So I simply need the same output (italics, bold, text in Latin, Greek, Cyrillic, Arabic, Japanese, Chinese and Malayalam script) in HTML format, using the same biblatex style as in the PDF (authoryear-icomp), for example this entry:

@BOOK{bib243,
   AUTHOR = {{al-Qalqašandī, Abū l-ʿAbbās ʾAḥmad ibn ʿAlī}},
   AUTHOR_ORIGINAL = {{القلقشندي أبو العبّاس أحمد بن علي بن أحمد}},
   AUTHOR+AN = {1=ar-Arab},
   TITLE = {{{\amirismall\beginR صبح الأعشى في صناعة الإنشاء\endR} [The Morning of the Dim-Sighted [Treatise] on the Art of Composition]}},
   PUBLISHER = {{\amirismall\beginR الهية العامة للكتاب\endR} [al-Hayʾa l-ʿāmma li-l-Kitāb]},
   ADDRESS = {Cairo},
   YEAR = {1985},
}

should become, according to authoryear-icomp:

<li>al-Qalqašandī, Abū l-ʿAbbās ʾAḥmad ibn ʿAlī [القلقشندي أبو العبّاس أحمد بن علي بن أحمد] (1985).
صبح الأعشى في صناعة الإنشاء <i>[The Morning of the Dim-Sighted [Treatise] on the Art of Composition]</i>.
Cairo: الهية العامة للكتاب [al-Hayʾa l-ʿāmma li-l-Kitāb].</li>

in order to look like this:

  • al-Qalqašandī, Abū l-ʿAbbās ʾAḥmad ibn ʿAlī [القلقشندي أبو العبّاس أحمد بن علي بن أحمد] (1985). صبح الأعشى في صناعة الإنشاء [The Morning of the Dim-Sighted [Treatise] on the Art of Composition]. Cairo: الهية العامة للكتاب [al-Hayʾa l-ʿāmma li-l-Kitāb].

The program will have to read the appropriate field commands in the BBL file, and apply their definitions in the authoryear-icomp file in order to obtain the appropriate HTML output.

Is there any tool doing that?

(I tried htxelatex by taking the precaution of removing the TeX file contents and leaving only a \nocite{*} command, and it produced an XDV file with 31,669 (!!!) pages before running out of memory...)

4
  • 1
    what does make4ht -l do? It uses LuaTeX instead of XeTeX. I think it will need some redefinitions for stuff like \beginR and \endR, but it should handle all Unicode values. But it is hard to say how much work will be needed without a MWE.
    – michal.h21
    Nov 21, 2019 at 22:43
  • I removed whatever was connected to xelatex and ran it with make4ht. It ended with the error message --- error --- Can't find/open file [lmroman10-regular]:+tlig;.tfm' Make4ht: Fatal error. Command tex4ht returned exit code 256
    – yannis
    Nov 21, 2019 at 23:00
  • I found a clue in another stackexchange page and added \usepackage[utf8]{inputenc}\usepackage[T1]{fontenc} now the bibliography comes out OK but all Unicode characters other than T1 disappear, in a way similar to what would happen in PDF when asking for Unicode characters outside the T1 range. Is there some way to make make4ht Unicode compliant?
    – yannis
    Nov 21, 2019 at 23:08
  • I've posted an answer that works on recent TL.
    – michal.h21
    Nov 21, 2019 at 23:10

1 Answer 1

3

I can convert your sample file using make4ht. TeX MWE:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguages{arabic}
\newfontfamily\amirismall{Amiri}[Language=Arabic]

\usepackage[style=authoryear-icomp]{biblatex}
\addbibresource{hello.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

Because you want to use lot of different Unicode characters, it is better to use LuaTeX than XeTeX with tex4ht. The reason is that it needs to make every supported character active with XeTeX and it can lead to some issues. It is then necessary to provide definitions for \beginR and \endR commands, which aren't supported by LuaTeX. Try the following configuration file, config.cfg:

\Preamble{xhtml}
\def\beginR{\HCode{<span dir="rtl">}\NoFonts}
\def\endR{\EndNoFonts\HCode{</span>}}
\begin{document}
\EndPreamble

It will insert a <span> element with correct direction info to the HTML file. The \NoFonts command disables creation of lot of unnecessary elements that are created by default.

Compile the file using

make4ht -ul -c config.cfg filename.tex

This is the result:

enter image description here

And the HTML code:

<h3 class="sectionHead"><a 
 id="x1-1000"></a>References</h3>
<!--l. 9--><p class="noindent" >   
</p>
<dl class="thebibliography"><dt id="X0-bib243" class="thebibliography">
</dt><dd 
id="bib-1" class="thebibliography">   
<!--l. 9--><p class="noindent" ><a id="page.1"></a><a 
href="biblatexsample.html" id="X0-" ></a>al-Qalqašandī,  Abū  l-ʿAbbās  ʾAḥmad  ibn  ʿAlī  (1985).  <span dir="rtl">صبح  الأعشى  في
صناعة الإنشاء</span> <span 
class="rm-lmri-10">[The Morning of the Dim-Sighted [Treatise] on the Art of</span>
<span 
class="rm-lmri-10">Composition]</span>. Cairo: <span dir="rtl">الهية العامة للكتاب</span> [al-Hayʾa l-ʿāmma li-l-Kitāb].</p></dd></dl>
3
  • Thanks, that's good news. I tried the method to a different file containing Japanese and the Japanese characters simply disappeared. It seems that there is no Japanese support for polyglossia. With xelatex I was using xeCJK but what should I do for luatex, using your method?
    – yannis
    Nov 21, 2019 at 23:15
  • In fact I just need to convert all UTF-8 characters in the BIB file into ^^^^abcd, and then this into ***abcd***, and once the HTML file is produced, I convert ***abcd*** into &#xabcd; and everything works out fine. Thanks!
    – yannis
    Nov 21, 2019 at 23:36
  • @yannis do you use any special macros for the Japanese text? Or packages? It is possible that they interfere with TeX4ht.
    – michal.h21
    Nov 21, 2019 at 23:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .