From 6afc2ef3cb03b9bf720a5eb8d98c0248b00a7a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olaf=20Schmidt-Wischh=C3=B6fer?= Date: Wed, 9 Jul 2025 10:11:24 +0200 Subject: [PATCH] Add configuration option for uppercase conversion --- src/Html2Text.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Html2Text.php b/src/Html2Text.php index 6e0f9e5..35032df 100644 --- a/src/Html2Text.php +++ b/src/Html2Text.php @@ -222,6 +222,10 @@ class Html2Text 'width' => 70, // Maximum width of the formatted text, in columns. // Set this value to 0 (or less) to ignore word wrapping // and not constrain text to a fixed-width column. + + 'convert_case' => true, // Convert headlines, table headers, and to uppercase + // Set this to false for languages with capitalization rules that + // are different from those used by mb_strtoupper (e.g. Turkish). ); private function legacyConstruct($html = '', $fromFile = false, array $options = array()) @@ -621,6 +625,10 @@ protected function pregPreCallback(/** @noinspection PhpUnusedParameterInspectio */ protected function toupper($str) { + if (!$this->options['convert_case']) { + return $str; + } + // string can contain HTML tags $chunks = preg_split('/(<[^>]*>)/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);