From c98cea47705b7fc79513b4e5414709ff6fa3397b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 14 Jan 2026 19:29:06 +0100 Subject: [PATCH] #7894 --- .docker/images/php/Dockerfile | 2 +- app/Fluidbook/Compiler/Links.php | 16 ++++ app/Models/FluidbookPublication.php | 33 ++------ composer.lock | 124 ++++++++++++++-------------- 4 files changed, 87 insertions(+), 88 deletions(-) diff --git a/.docker/images/php/Dockerfile b/.docker/images/php/Dockerfile index 75ea53333..f18e6ff19 100644 --- a/.docker/images/php/Dockerfile +++ b/.docker/images/php/Dockerfile @@ -89,7 +89,7 @@ RUN apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true RUN npm install --unsafe-perm --global uglify-js less sass puppeteer favicons crx3 oslllo-svg-fixer terser npm-check-updates nw-builder@^4 ttf2woff2 -RUN pip3 install font-line lxml six docling accelerate --break-system-packages +RUN pip3 install font-line lxml six docling accelerate easyocr --break-system-packages RUN groupadd sudo;useradd -d /application -g 33 -G sudo -s /bin/bash -u 1001 toolbox diff --git a/app/Fluidbook/Compiler/Links.php b/app/Fluidbook/Compiler/Links.php index 5a86589dc..6b676b9df 100644 --- a/app/Fluidbook/Compiler/Links.php +++ b/app/Fluidbook/Compiler/Links.php @@ -5,8 +5,10 @@ namespace App\Fluidbook\Compiler; use App\Fluidbook\Link\Link; use App\Fluidbook\Link\LinksData; use App\SubForms\Link\Base; +use Cubist\Util\CommandLine\Docling; use Cubist\Util\Graphics\Color; use Cubist\Util\Text; +use Cubist\Util\Url; use Fluidbook\Tools\Links\AnchorLink; use Fluidbook\Tools\Links\ContentLink; use Fluidbook\Tools\Links\NormalLink; @@ -530,4 +532,18 @@ trait Links $this->config->push('triggersLinks', ['page' => $page, 'link' => $link, 'delay' => $delay]); } + public function getLinkAlternativeText($link) + { + if (Url::isDistant($link->to)) { + return ''; + } + $file = $this->wdir . '/' . $link->to; + + if (!file_exists($file)) { + return ''; + } + $res = Docling::OCR($file, $this->getFluidbook()->locale); + return $res; + } + } diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index c3401c9dc..a5e380eb8 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -67,6 +67,7 @@ use Cubist\Util\Files\Files; use Cubist\Util\Graphics\Image; use Cubist\Util\Gzip; use Cubist\Util\Json; +use Cubist\Util\Markdown; use Cubist\Util\Str; use Datetime; use Illuminate\Support\Facades\DB; @@ -521,32 +522,9 @@ class FluidbookPublication extends ToolboxStatusModel if (!isset($json)) { $json = json_decode(gzdecode(file_get_contents($file)), true); } - $config = [ - 'table' => [ - 'wrap' => [ - 'enabled' => false, - 'tag' => 'div', - 'attributes' => [], - ], - 'alignment_attributes' => [ - 'left' => ['align' => 'left'], - 'center' => ['align' => 'center'], - 'right' => ['align' => 'right'], - ], - ], - ]; - - $environment = new Environment($config); - $environment->addExtension(new CommonMarkCoreExtension()); - $environment->addExtension(new TableExtension()); - $environment->addExtension(new AutolinkExtension()); - - $converter = new MarkdownConverter($environment); + foreach ($json['pages'] as $page => $markdown) { - $h = $converter->convert($markdown)->getContent(); - $h = preg_replace('/

/U', '', $h); - $h = str_replace("/\n+/", "\n", $h); - $html[$page] = $h; + $html[$page] = self::mdToHTML($markdown); } file_put_contents($htmlFile, gzencode(json_encode($html))); @@ -559,6 +537,11 @@ class FluidbookPublication extends ToolboxStatusModel return json_decode(gzdecode(file_get_contents($file)), true); } + public static function mdToHTML($md) + { + return Markdown::toHTML($md, false); + } + public function getPDFSplitSource($page) { if ($page > $this->getPagesNumber()) { diff --git a/composer.lock b/composer.lock index c57262dd0..4bd8bb6a5 100644 --- a/composer.lock +++ b/composer.lock @@ -108,16 +108,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.369.8", + "version": "3.369.12", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "2fa2011e2adc8e70b15b17c50d598fc44fc3106a" + "reference": "36ee8894743a254ae2650bad4968c874b76bc7de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2fa2011e2adc8e70b15b17c50d598fc44fc3106a", - "reference": "2fa2011e2adc8e70b15b17c50d598fc44fc3106a", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/36ee8894743a254ae2650bad4968c874b76bc7de", + "reference": "36ee8894743a254ae2650bad4968c874b76bc7de", "shasum": "" }, "require": { @@ -199,9 +199,9 @@ "support": { "forum": "https://github.com/aws/aws-sdk-php/discussions", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.369.8" + "source": "https://github.com/aws/aws-sdk-php/tree/3.369.12" }, - "time": "2026-01-06T19:10:11+00:00" + "time": "2026-01-13T19:12:08+00:00" }, { "name": "backpack/backupmanager", @@ -702,12 +702,12 @@ "version": "v3.16.3", "source": { "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", + "url": "https://github.com/fruitcake/laravel-debugbar.git", "reference": "c91e57ea113edd6526f5b8cd6b1c6ee02c67b28e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/c91e57ea113edd6526f5b8cd6b1c6ee02c67b28e", + "url": "https://api.github.com/repos/fruitcake/laravel-debugbar/zipball/c91e57ea113edd6526f5b8cd6b1c6ee02c67b28e", "reference": "c91e57ea113edd6526f5b8cd6b1c6ee02c67b28e", "shasum": "" }, @@ -767,8 +767,8 @@ "webprofiler" ], "support": { - "issues": "https://github.com/barryvdh/laravel-debugbar/issues", - "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.16.3" + "issues": "https://github.com/fruitcake/laravel-debugbar/issues", + "source": "https://github.com/fruitcake/laravel-debugbar/tree/v3.16.3" }, "funding": [ { @@ -1957,13 +1957,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_cms-back.git", - "reference": "59be7a0976c996abb0b41187eaf6b6e934e51d43" + "reference": "04f1d15d514c753ae42320e8c9b6658522935566" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-23de99.tar", - "reference": "59be7a0976c996abb0b41187eaf6b6e934e51d43", - "shasum": "74b3ffe071a96317cadbe0651733c4eafdc7d14a" + "url": "https://composer.cubedesigners.com/dist/cubist/cms-back/cubist-cms-back-dev-master-9be3b4.tar", + "reference": "04f1d15d514c753ae42320e8c9b6658522935566", + "shasum": "59d17179b3c59ab51199967b2e8fc5f906512d57" }, "require": { "backpack/backupmanager": "^v3.0.9", @@ -1972,7 +1972,7 @@ "backpack/permissionmanager": "^6.0.16", "backpack/pro": "1.6.6", "backpack/revise-operation": "^1.0.12", - "barryvdh/laravel-debugbar": "^v3.15.0", + "barryvdh/laravel-debugbar": "^v3.16.0", "cache/redis-adapter": "^1.2.0", "chrisjean/php-ico": "^1.0.4", "cubist/cms-front": "dev-master", @@ -1989,9 +1989,9 @@ "graham-campbell/markdown": "^v15.3.0", "laravel-lang/lang": "12.19.4", "laravel-lang/publisher": "^v14.7.4", - "laravel/framework": "^v10.48.0", + "laravel/framework": "^v10.50.0", "lavary/laravel-menu": "^v1.8.3", - "league/commonmark": "^2.7.0", + "league/commonmark": "^2.8.0", "mews/purifier": "^3.4", "spatie/laravel-honeypot": "^4.6.0", "spatie/laravel-permission": "^4.4.3|^5.11.0", @@ -2002,7 +2002,7 @@ "require-dev": { "barryvdh/laravel-ide-helper": "^v2.15", "filp/whoops": "^2.18", - "laravel/tinker": "^v2.10" + "laravel/tinker": "^v2.11" }, "default-branch": true, "type": "library", @@ -2042,7 +2042,7 @@ } ], "description": "Cubist Backpack extension", - "time": "2026-01-07T13:58:10+00:00" + "time": "2026-01-08T15:42:20+00:00" }, { "name": "cubist/cms-front", @@ -2524,13 +2524,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_util.git", - "reference": "b5172ff53a637d01872b7d90899ee64472ee2e92" + "reference": "1c47b1f5be2cd335d034a64fe10000e59473241f" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-a547c4.tar", - "reference": "b5172ff53a637d01872b7d90899ee64472ee2e92", - "shasum": "9c37ec864a0dfcf0396cba03c82944b2f9f292bf" + "url": "https://composer.cubedesigners.com/dist/cubist/util/cubist-util-dev-master-834a22.tar", + "reference": "1c47b1f5be2cd335d034a64fe10000e59473241f", + "shasum": "6b0e2cfc57d879e4114031ea3f019c179ab87ce6" }, "require": { "cubist/net": "dev-master", @@ -2564,7 +2564,7 @@ } ], "description": "Utilities class", - "time": "2025-12-18T10:50:14+00:00" + "time": "2026-01-14T18:00:53+00:00" }, { "name": "cviebrock/eloquent-sluggable", @@ -4064,16 +4064,16 @@ }, { "name": "firebase/php-jwt", - "version": "v6.11.1", + "version": "v7.0.2", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66" + "reference": "5645b43af647b6947daac1d0f659dd1fbe8d3b65" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", - "reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66", + "url": "https://api.github.com/repos/firebase/php-jwt/zipball/5645b43af647b6947daac1d0f659dd1fbe8d3b65", + "reference": "5645b43af647b6947daac1d0f659dd1fbe8d3b65", "shasum": "" }, "require": { @@ -4121,9 +4121,9 @@ ], "support": { "issues": "https://github.com/firebase/php-jwt/issues", - "source": "https://github.com/firebase/php-jwt/tree/v6.11.1" + "source": "https://github.com/firebase/php-jwt/tree/v7.0.2" }, - "time": "2025-04-09T20:32:01+00:00" + "time": "2025-12-16T22:17:28+00:00" }, { "name": "fluidbook/tools", @@ -4131,13 +4131,13 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/fluidbook_tools.git", - "reference": "e47370d7d7da9e44de2385af1f4785d031a32aa3" + "reference": "87006bd32ce4299a18924401eaa6c4b7a6bb26fa" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-d42ec3.tar", - "reference": "e47370d7d7da9e44de2385af1f4785d031a32aa3", - "shasum": "b1190cbbdf4386478d5a47773aff7cc57cb026e6" + "url": "https://composer.cubedesigners.com/dist/fluidbook/tools/fluidbook-tools-dev-master-af8ec1.tar", + "reference": "87006bd32ce4299a18924401eaa6c4b7a6bb26fa", + "shasum": "c9e07243c7a85d9bd00b1a2ee2810c8f4984b2fb" }, "require": { "barryvdh/laravel-debugbar": "*", @@ -4173,7 +4173,7 @@ } ], "description": "Fluidbook Tools", - "time": "2026-01-07T11:49:19+00:00" + "time": "2026-01-14T16:56:21+00:00" }, { "name": "fpdf/fpdf", @@ -4301,20 +4301,20 @@ }, { "name": "google/auth", - "version": "v1.49.0", + "version": "v1.50.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-auth-library-php.git", - "reference": "68e3d88cb59a49f713e3db25d4f6bb3cc0b70764" + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/68e3d88cb59a49f713e3db25d4f6bb3cc0b70764", - "reference": "68e3d88cb59a49f713e3db25d4f6bb3cc0b70764", + "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/e1c26a718198e16d8a3c69b1cae136b73f959b0f", + "reference": "e1c26a718198e16d8a3c69b1cae136b73f959b0f", "shasum": "" }, "require": { - "firebase/php-jwt": "^6.0", + "firebase/php-jwt": "^6.0||^7.0", "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/psr7": "^2.4.5", "php": "^8.1", @@ -4324,7 +4324,7 @@ }, "require-dev": { "guzzlehttp/promises": "^2.0", - "kelvinmo/simplejwt": "0.7.1", + "kelvinmo/simplejwt": "^1.1.0", "phpseclib/phpseclib": "^3.0.35", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6", @@ -4332,7 +4332,7 @@ "squizlabs/php_codesniffer": "^4.0", "symfony/filesystem": "^6.3||^7.3", "symfony/process": "^6.0||^7.0", - "webmozart/assert": "^1.11" + "webmozart/assert": "^1.11||^2.0" }, "suggest": { "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2." @@ -4357,9 +4357,9 @@ "support": { "docs": "https://cloud.google.com/php/docs/reference/auth/latest", "issues": "https://github.com/googleapis/google-auth-library-php/issues", - "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.49.0" + "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.50.0" }, - "time": "2025-11-06T21:27:55+00:00" + "time": "2026-01-08T21:33:57+00:00" }, { "name": "google/cloud-core", @@ -4692,16 +4692,16 @@ }, { "name": "google/protobuf", - "version": "v4.33.2", + "version": "v4.33.4", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318" + "reference": "22d28025cda0d223a2e48c2e16c5284ecc9f5402" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", - "reference": "fbd96b7bf1343f4b0d8fb358526c7ba4d72f1318", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/22d28025cda0d223a2e48c2e16c5284ecc9f5402", + "reference": "22d28025cda0d223a2e48c2e16c5284ecc9f5402", "shasum": "" }, "require": { @@ -4730,9 +4730,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.2" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.4" }, - "time": "2025-12-05T22:12:22+00:00" + "time": "2026-01-12T17:58:43+00:00" }, { "name": "graham-campbell/markdown", @@ -11517,16 +11517,16 @@ }, { "name": "spatie/temporary-directory", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/spatie/temporary-directory.git", - "reference": "580eddfe9a0a41a902cac6eeb8f066b42e65a32b" + "reference": "662e481d6ec07ef29fd05010433428851a42cd07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/580eddfe9a0a41a902cac6eeb8f066b42e65a32b", - "reference": "580eddfe9a0a41a902cac6eeb8f066b42e65a32b", + "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/662e481d6ec07ef29fd05010433428851a42cd07", + "reference": "662e481d6ec07ef29fd05010433428851a42cd07", "shasum": "" }, "require": { @@ -11562,7 +11562,7 @@ ], "support": { "issues": "https://github.com/spatie/temporary-directory/issues", - "source": "https://github.com/spatie/temporary-directory/tree/2.3.0" + "source": "https://github.com/spatie/temporary-directory/tree/2.3.1" }, "funding": [ { @@ -11574,7 +11574,7 @@ "type": "github" } ], - "time": "2025-01-13T13:04:43+00:00" + "time": "2026-01-12T07:42:22+00:00" }, { "name": "spomky-labs/base64url", @@ -17772,16 +17772,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495" + "reference": "16dbf9937da8d4528ceb2145c9c7c0bd29e26374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/1e0cd5370df5dd2e556a36b9c62f62e555870495", - "reference": "1e0cd5370df5dd2e556a36b9c62f62e555870495", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/16dbf9937da8d4528ceb2145c9c7c0bd29e26374", + "reference": "16dbf9937da8d4528ceb2145c9c7c0bd29e26374", "shasum": "" }, "require": { @@ -17813,9 +17813,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.1" }, - "time": "2025-08-30T15:50:23+00:00" + "time": "2026-01-12T11:33:04+00:00" }, { "name": "phpunit/php-code-coverage", -- 2.39.5