splitbrain / dokuwiki-plugin-dw2pdf

A fork of Luigi Micco's PDF export plugin for DokuWiki
http://www.dokuwiki.org/plugin:dw2pdf
55 stars 68 forks source link

xbr render plugin line breaks #361

Open Hativ opened 6 years ago

Hativ commented 6 years ago

Hello,

I use the xbr render plugin and the line breaks are not in the pdf export. Could support for this be integrated?

I hacked something really dirty in action.php's p_wiki_dw2pdf() function:

        // xbr
        $ret = preg_replace('/>\n+</m',"><", $ret);
        $ret = preg_replace('/\n+/m',"<br />\n", $ret);
        $ret = preg_replace('/<p><br \/>/m',"<p>", $ret);
        $ret = preg_replace('/><br \/>/m',">", $ret);
        $ret = preg_replace('/>\n<br \/>/m',">", $ret);
        $ret = preg_replace('/> <br \/>/m',">", $ret);
        $ret = preg_replace('/<br \/></m',"<", $ret);
        $ret = preg_replace('/<br \/>\n</m',"<", $ret);
        $ret = preg_replace('/<br \/> </m',"<", $ret);

Or maybe someone can tell me where I can get the page text so early like the render plugin so that str_replace("\n","<br />\n", $text) is enough, without the hack above.

Relevant code in the xbr render plugin: https://github.com/Chris--S/dokuwiki-plugin-xbr/blob/master/renderer.php

chlarsen commented 2 years ago

I second this request. Often, pdf exports serve somewhat "official" purposes, and they should look good. :-)

Klap-in commented 2 years ago

There are more issues with linebreaks.

We need to test which html (or special mpdf syntax) is working fine in mpdf. Then we can add to e.g. xbr and to the wrap plugins some dw2pdf specific code that ensure that the right line breaks are fed to mpdf. (mpdf is a bit picky and limited in the html/css it accepts)

Klap-in commented 2 years ago

Seems to work for wrap plugin. See #99 and #149