dokuwiki-plugin-dw2pdf icon indicating copy to clipboard operation
dokuwiki-plugin-dw2pdf copied to clipboard

enable hyphenation based on wiki language

Open Juergen-aus-Zuendorf opened this issue 5 years ago • 7 comments

Hi,

it seems that the given language is not passed from HTML to the PDF output. I am trying to use automatic hyphenation using the CSS function "hyphens". But for this to work, the definition of the language attribute in the HTML code is required. When debugging with "&debughtml=text" you can see that the language is not specified.

Regards Juergen

Juergen-aus-Zuendorf avatar Oct 28 '20 10:10 Juergen-aus-Zuendorf

Could you describe how someone can reproduce your situation? I have not yet an idea what your issue is.

Klap-in avatar Oct 28 '20 10:10 Klap-in

The CSS command Hyphens: auto can be used to activate automatic hyphenation. However, the hyphenation rules are language-specific. In HTML, the language is determined by the lang attribute, and browsers hyphenate only if this attribute is present and the corresponding hyphenation dictionary is available. Interestingly, mpdf also supports this function. But without a specific, previously defined language, hyphenation looks very strange.

In my userstyle.css file I have the following sequence:

body {
	hyphens: auto;
	-moz-hyphens: auto;
	-ms-hyphens: auto;
	-o-hyphens: auto;
	-webkit-hyphens: auto;
}

... and it works perfectly for german language (Firefox).

The same syntax in the style.ini of the pdf template brings some kind of hyphenation which is totally wrong.

Juergen-aus-Zuendorf avatar Oct 28 '20 11:10 Juergen-aus-Zuendorf

And I can just export every page to see this? Please provide a small recipe for reproducing. I do not know what I should put in my wiki, which plugins/versions/settings are needed. I don't know what the current output is in your setup. I do not know what output you expect. Please realize that we do not know anything about your setup. So guide your potential helpers to quickly reproduce your situation.

Klap-in avatar Oct 28 '20 21:10 Klap-in

Here I have a small recipe as a wiki text:

====== Spielplatz ======

Die Betriebsanleitung vor Beginn aller Arbeiten sorgfältig durchlesen! Sie ist Produktbestandteil und muss in unmittelbarer Nähe der Maschine für das Personal jederzeit zugänglich aufbewahrt werden. 

And here is the result: a) Browser (Edge): Browser(Edge)

b) Output as PDF: PDF-Ausgabe

The word "jederzeit" is hyphened at a wrong position (correct should be this: je-der-zeit). And this problem runs through the whole text.

My idea why the hyphenation is in the wrong position is that the language "de" is not recognized because it is simply not known during PDF generation. As written at the beginning of this thread, when debugging with "&debughtml=text" you can see that the language is not specified.

Here is my template: schuette_ban_de_v01.zip

Juergen-aus-Zuendorf avatar Oct 30 '20 16:10 Juergen-aus-Zuendorf

I have done a little research: The language must be defined in the file "..\dw2pdf\vendor\mpdf\mpdf\src\Config\ConfigVariables.php"

Syntax for German hyphenation:
'SHYlang' => "de", // 'en','de','es','fi','fr','it','nl','pl','ru','sv'

I dont't know: Is there perhaps a possibility to influence this from a parameter passing using the DW2PDF plugin?

Juergen-aus-Zuendorf avatar Feb 12 '21 14:02 Juergen-aus-Zuendorf

The wiki has already a global language setting. (of course it get more complex to get the correct language when the translation plugin is used. https://www.dokuwiki.org/plugin:translation).

From this setting, probably for available languages in mpdf the hyphenation setting could be set. https://mpdf.github.io/what-else-can-i-do/hyphenation.html

The config settings for mpdf are handled here: https://github.com/splitbrain/dokuwiki-plugin-dw2pdf/blob/master/DokuPDF.class.php

Klap-in avatar Feb 13 '21 11:02 Klap-in

In fact, I use the translation plugin. And for this reason, unfortunately, the global definition via the wiki login language is not enough for me. Therefore, it would certainly be ideal to determine the language analogous to the translation plugin. Alternatively, it would be sufficient to have an URL parameter, e.g. "&lang=de".

Juergen-aus-Zuendorf avatar Feb 15 '21 07:02 Juergen-aus-Zuendorf

implemented in #481

splitbrain avatar May 02 '23 13:05 splitbrain