Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
0495d5cd
Commit
0495d5cd
authored
11 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
html2text: Properly wrap and pad text with diacritics
parent
430459df
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/html2text.php
+12
-6
12 additions, 6 deletions
include/html2text.php
with
12 additions
and
6 deletions
include/html2text.php
+
12
−
6
View file @
0495d5cd
...
...
@@ -55,6 +55,10 @@ function convert_html_to_text($html, $width=74) {
'b'
=>
array
(
'text-transform'
=>
'uppercase'
),
'strong'
=>
array
(
'text-transform'
=>
'uppercase'
),
'h4'
=>
array
(
'text-transform'
=>
'uppercase'
),
// Crazy M$ styles
'.MsoNormal'
=>
array
(
'margin'
=>
0
,
'margin-bottom'
=>
0.0001
),
'.MsoPlainText'
=>
array
(
'margin'
=>
0
,
'margin-bottom'
=>
0.0001
),
))
);
$options
=
array
();
...
...
@@ -188,9 +192,9 @@ class HtmlInlineElement {
$this
->
ws
=
$this
->
getStyle
(
'white-space'
,
'normal'
);
// Direction
$dir
=
$this
->
node
->
getAttribute
(
'dir'
);
// Ensure we have a value, but don't a control char unless
direction
// is declared
$this
->
dir
=
$dir
?:
'l
ef
t'
;
// Ensure we have a value, but don't
emit
a control char unless
//
direction
is declared
$this
->
dir
=
$dir
?:
'lt
r
'
;
switch
(
strtolower
(
$dir
))
{
case
'ltr'
:
$output
.
=
"
\xE2\x80\x8E
"
;
# LEFT-TO-RIGHT MARK
...
...
@@ -234,7 +238,7 @@ class HtmlInlineElement {
}
switch
(
$this
->
getStyle
(
'text-decoration'
,
'none'
))
{
case
'underline'
:
//
Remove
diacritics and underline chars which do not go below
//
Split
diacritics and underline chars which do not go below
// the baseline
if
(
class_exists
(
'Normalizer'
))
$output
=
Normalizer
::
normalize
(
$output
,
Normalizer
::
FORM_D
);
...
...
@@ -903,7 +907,8 @@ function mb_wordwrap($string, $width=75, $break="\n", $cut=false) {
if
(
$cut
)
{
// Match anything 1 to $width chars long followed by whitespace or EOS,
// otherwise match anything $width chars long
$search
=
'/(.{1,'
.
$width
.
'})(?:\s|$|(\p{Ps}))|(.{'
.
$width
.
'})/uS'
;
$search
=
'/((?>[^\n\p{M}]\p{M}*){1,'
.
$width
.
'})(?:[ \n]|$|(\p{Ps}))|((?>[^\n\p{M}]\p{M}*){'
.
$width
.
'})/uS'
;
# <?php
$replace
=
'$1$3'
.
$break
.
'$2'
;
}
else
{
// Anchor the beginning of the pattern with a lookahead
...
...
@@ -917,8 +922,9 @@ function mb_wordwrap($string, $width=75, $break="\n", $cut=false) {
// Thanks http://www.php.net/manual/en/ref.mbstring.php#90611
function
mb_str_pad
(
$input
,
$pad_length
,
$pad_string
=
" "
,
$pad_style
=
STR_PAD_RIGHT
)
{
$marks
=
preg_match_all
(
'/\p{M}/u'
,
$input
,
$match
);
return
str_pad
(
$input
,
strlen
(
$input
)
-
mb_strwidth
(
$input
)
+
$pad_length
,
$pad_string
,
strlen
(
$input
)
-
mb_strwidth
(
$input
)
+
$
marks
+
$
pad_length
,
$pad_string
,
$pad_style
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment