Broken text in pdf with sphinx-build - macos

I use sphinx-build (Sphinx v1.6.3) on a Mac (Mojave 10.14.1) to generate a PDF in different languages.
All languages work, but polish gives me broken characters:
They original text is stored as *.rst file (in German) and then I translate them into *.po files.
One example word which does not work is:
Treść
This is the according PO-File:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) Beat Gurtner
# This file is distributed under the same license as the Dokumentation des
# Sakkadentrainers package.
# FIRST AUTHOR <EMAIL#ADDRESS>, 2019.
#
msgid ""
msgstr ""
"Project-Id-Version: Dokumentation des Sakkadentrainers\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-07-26 14:43+0200\n"
"PO-Revision-Date: 2019-12-29 17:38+0000\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"X-Poedit-SourceCharset: UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.4.0\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: pl\n"
"X-Generator: Poedit 2.2.4\n"
#: ../../index.rst:7
msgid "Willkommen zur Dokumentation des Sakkadentrainers"
msgstr "Witamy w dokumentacji Sakkadycznytrener"
#: ../../index.rst:9
msgid "`Zurück zum Training <https://www.sakkadentrainer.ch>`_"
msgstr "`Powrót do treningu <https://www.sakkadentrainer.ch>`_"
#: ../../index.rst:11
msgid "Inhalt:"
msgstr "Treść:"
The command to generate the PDF is:
sphinx-build -t pl -D language=pl -b pdf /Applications/MAMP/htdocs/sakkadentrainer/doc/ /Applications/MAMP/htdocs/sakkadentrainer_medical_doc/pdf/pl/
Any help is appreciated

This is the solutions. Put it into your conf.py file.
The problem is that you need a font that supports special characters.
pdf_stylesheets = ['sphinx','kerning','a4']

Related

Pandoc cross-ref: adding empty line after last section title

I need to write articles and switch from latex to pandoc (better: I intend to do so). My markdown file looks like this:
....
bla bla
\noindent
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
# References
Mind, References really is the last line of the file.
I compile like this:
pandoc ../../bibliography/default.yaml -f markdown-tex_math_dollars -s --bibliography ../../bibliography/bibliography.bib --csl ../../bibliography/harvard-cite-them-right.csl -F pandoc-crossref $f -o $f.pdf
My default yaml file:
---
geometry: a4paper,verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=1.5cm,rmargin=1.5cm
inputenc: latin9
indent: true
sectionsDepth: 3
link-citations: true
numberSections: true
linestretch: 1.5
header-includes:
- \renewcommand{\familydefault}{\rmdefault}
- \usepackage{lineno}
- \linenumbers
---
And what I get in PDF is this:
As you can see, there's an empty line after References.
Q:
How can I get rid of this empty line?
How can I remove the numbering from section title References only, leaving the remaining section titles numbered?
Thanks

How to send a mail with special characters as subject by using sendmail command in unix shell script

In my script i want to send a mail with some subject, some text as body along with csv file as attachement
My problem is subject has special characters in portuguese language
like this
Subject: Relatório de utilização do QRCODE
i am using sendmail command to send mail because i need to change sender name(not email id)
I tried this :
Subject=Relatório de utilização do QRCODE
mnth=$(date '+%m/%Y' --date="1 month ago")
echo 'mês:'$mnth>>mailBody.html
echo 'contagem de registros:'11090>>mailBody.html
cat mailBody.html>out.mail
echo "$mnth"
uuencode QR_Log.csv QR_Report_$fname.csv >> out.mail
sendmail -F "xyzname" "$subject" -f "receiver#abc.com" <out.mail
echo "mail sent"
when i run the above script i am getting message like this :
Syntax error in mailbox address "Relat??rio.de.utiliza????o.do.QRCODE"
(non-printable character)
mail sent
How can i achieve this please Help me...
Help is very much appreciated. I'll just wait
Thanks in advance
I wrote a shell script like this and I got a valid title. Try to rewrite the code for sending mail like MIME:
#!/bin/bash
echo 'To: you#domain.net'>>test.html
echo 'From: Some User <user#domain.net>'>>test.html
echo 'Subject: Relatório de utilização do QRCODE'>>test.html
echo 'MIME-Version: 1.0'>>test.html
echo 'Content-Type: text/html; charset="utf-8"'>>test.html
echo 'Content-Disposition: inline'>>test.html
echo ''>>test.html
echo '<span style="color:red;">Your message goes here</span>'>>test.html
sendmail -i -t < test.html
rm test.html
Let me know if this helped :)
Below is my old answer...
Not a linux guy but this may help you. First you must encode the subject to base64. For example:
echo 'your subject' | openssl base64
Let's say you've put the encoded string into $subject variable. Next you set the subject like this when sending email:
"=?UTF-8?B?$subject?="
Basically try to put =?UTF-8?B? before the base64-encoded subject and ?= after it without spaces.
As I said I'm not too much of a linux guy but you'll manage :)
Let me know if it helped.
rfc2045 - (5) (Soft Line Breaks) The Quoted-Printable encoding REQUIRES that encoded lines be no more than 76 characters long.
For bash shell script code:
#!/bin/bash
subject_encoder(){
echo -n "$1" | xxd -ps -c3 |awk -Wposix 'BEGIN{
BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
printf " =?UTF-8?B?"; bli=8
}
function encodeblock (strin){
b1=sprintf("%d","0x" substr(strin,1,2))
b2=sprintf("%d","0x" substr(strin,3,2))
b3=sprintf("%d","0x" substr(strin,5,2))
o=substr(BASE64,b1/4 + 1,1) substr(BASE64,(b1%4)*16 + b2/16 + 1,1)
len=length(strin)
if(len>1) o=o substr(BASE64,(b2%16)*4 + b3/64 + 1,1); else o=o"="
if(len>2) o=o substr(BASE64,b3%64 +1 ,1); else o=o"="
return o
}{
bs=encodeblock($0)
bl=length(bs)
if((bl+bli)>64){
printf "?=\n =?UTF-8?B?"
bli=bl
}
printf bs
bli+=bl
}END{
printf "?=\n"
}'
}
SUBJECT="Relatório de utilização"
SUBJECT=`subject_encoder "${SUBJECT}"`
echo '<html>test</html>'| mail -a "Subject:${SUBJECT}" -a "MIME-Version: 1.0" -a "Content-Type: text/html; charset=UTF-8" you#domain.net

How to format text file as it can be seen in man pages (justifying text, nothing more) using bash

What I would like to do is the following.
Text file content :
This is a simple text file
containing lines of text
with different width
but I would like to justify
them. Any idea ?
Expected result :
This is a simple text file containing
lines of text with different width
but I would like to justify them.
Any Idea ?
I already can split my files at the required width using :
cat textfile|fmt -s -w 37
But in that case, there is no justification...
EDIT : Using par as suggested, I found a problem with accented chars.
This is what gives par 37j1 for me :
This is à simplé text file
containing lines of tèxt with
different wïdth but I woùld like to
justîfy them. Any idéà ?
Not justified anymore... But spaces are altered anyway...
Thanks for your help,
Slander
You can employ nroff as using it man.
(echo '.ll 37'
echo '.pl 0'
cat orig.txt) | nroff
from your input produces:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?
The above WORKS ONLY WITH ASCII.
EDIT
If you want handle utf8 text with a nroff, you can try the next:
cat orig.txt | ( #yes, i know - UUOC
echo '.ll 37' #line length
echo '.pl 0' #page length (0-disables empty lines)
echo '.nh' #no hypenation
preconv -e utf8 -
) | groff -Tutf8
From this utf8 encoded input:
Voix ambiguë d'un cœur qui au zéphyr préfère les jattes de kiwi.
Voyez le brick géant que j'examine près du wharf.
Monsieur Jack, vous dactylographiez bien mieux que votre ami Wolf.
Eble ĉiu kvazaŭ-deca fuŝĥoraĵo ĝojigos homtipon..
Laŭ Ludoviko Zamenhof bongustas freŝa ĉeĥa manĝaĵo kun spicoj.
Nechť již hříšné saxofony ďáblů rozezvučí síň úděsnými tóny waltzu, tanga a
quickstepu.
produces:
Voix ambiguë d’un cœur qui au zéphyr
préfère les jattes de kiwi. Voyez le
brick géant que j’examine près du
wharf. Monsieur Jack, vous
dactylographiez bien mieux que votre
ami Wolf. Eble ĉiu kvazaŭ‐deca
fuŝĥoraĵo ĝojigos homtipon.. Laŭ
Ludoviko Zamenhof bongustas freŝa
ĉeĥa manĝaĵo kun spicoj. Nechť již
hříšné saxofony ďáblů rozezvučí síň
úděsnými tóny waltzu, tanga a
quickstepu.
If you delete the line
echo '.nh' #no hypenation
you will get hypenated text
Voix ambiguë d’un cœur qui au zéphyr
préfère les jattes de kiwi. Voyez le
brick géant que j’examine près du
wharf. Monsieur Jack, vous dactylo‐
graphiez bien mieux que votre ami
Wolf. Eble ĉiu kvazaŭ‐deca fuŝĥoraĵo
ĝojigos homtipon.. Laŭ Ludoviko Za‐
menhof bongustas freŝa ĉeĥa manĝaĵo
kun spicoj. Nechť již hříšné saxo‐
fony ďáblů rozezvučí síň úděsnými
tóny waltzu, tanga a quickstepu.
You could use par:
par -j -w37 < inputfile
The -j option would justify paragraphs.
-w denotes max output line length.
For your input, it'd produce:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?
An alternative would be to use emacs:
emacs -batch inputfile --eval '(set-fill-column 37)' --eval '(fill-region (point-min) (point-max))' -f save-buffer
This would also produce:
This is a simple text file containing
lines of text with different width
but I would like to justify them. Any
idea ?

How to send mail with bash without attachment

I'm trying to send a mail with a subject, a unique receiver, and few lines of text in the body. Almost everything is working as expected, except the body gets attached as a file instead of being in the mail's body.
Here is my code:
destinataire="foo#mail.com"
obj="** ALERTE BACKUP sur $host pour le dump DB de $db** "
body="Erreur lors du dump de la DB $db sur l'hote $host\n"
body="$body - Code erreur: $ret\n"
body="$body - Env: $prodfolder\n"
body="$body \n\nMail envoyé a $destinataire"
echo $body | mail -s "$obj" ${destinataire}
The content of $body gets transformed into a file, and attached to the mail. I don't understand what I am doing wrong, or if there is any additional configuration to do?
Thanks to xlembouras, and this post, the problem as been solved:
Language-specific characters such as é combined with default encoding set to UTF-8 (on the system the mail is being sent from) leads the body of the message to be transferred as attachment instead of raw text.
Try this instead:
mail -s "$obj" ${destinataire} <<EOF
Erreur lors du dump de la DB $db sur l'hote $host
- Code erreur: $ret
- Env: $prodfolder
Mail envoyé a $destinataire
EOF

How to change encoding for existing file with Vim

here is a subtitle file on http://subscene.com/subtitles/crank/farsi_persian/281992. if you download it you will see some codes like:
1
00:02:05,360 --> 00:02:07,430
åßÊæÑ¡ ãÇ åäæÒ ÏÇÑíã ãí ÑÎíã¿
ÎæÈå
2
00:02:07,600 --> 00:02:10,956
áíæÓ! ãÇ ÏÇÑíã í ÇÑ ãíäíã Èå ¿
æ Ïíå åí æÞÊ ãä Ñæ ÕÏÇ äãíÒäí
the thing i expect is:
1
00:02:05,360 --> 00:02:07,430
هكتور، ما هنوز داريم مي چرخيم؟
خوبه
2
00:02:07,600 --> 00:02:10,956
چليوس! ما داريم چي کار ميکنيم بچه ؟
و ديگه هيچ وقت من رو صدا نميزني
i reached it by changing the file extension from srt to txt, opening it with chrome browser, chenging encoding to arabic windows and re save file contents by select all text.
i have no idea how to do this with vim, or shell script. i tried :write ++enc=utf-8 russian.txt or set encoding or set fileencoding, but no luck.
thanks, mona
in vim:
after loading your file, don't do any modification. then you could do:
:e ++enc=cp1256
To save in utf-8, just
:w ++enc=utf-8
or you could do it in shell:
iconv -cf WINDOWS-1256 -t utf-8 problem.srt -o correct.srt

Resources