weblib MDL-22664 html_to_text should not strip images, it should replace them by their alt text.
Also, an new optional argument to html_to_text to control word-wrapping.
This commit is contained in:
+4
-1
@@ -219,7 +219,7 @@ class html2text
|
||||
'-',
|
||||
'*',
|
||||
'£',
|
||||
'EUR', // Euro sign. € ?
|
||||
'EUR', // Euro sign. € ?
|
||||
' ' // Runs of spaces, post-handling
|
||||
);
|
||||
|
||||
@@ -237,6 +237,7 @@ class html2text
|
||||
'/<(a) [^>]*href=("|\')([^"\']+)\2[^>]*>(.*?)<\/a>/i',
|
||||
// <a href="">
|
||||
'/<(th)[^>]*>(.*?)<\/th>/i', // <th> and </th>
|
||||
'/<(img)[^>]*alt=\"([^>"]+)\"[^>]*>/i', // <img> with alt
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -574,6 +575,8 @@ class html2text
|
||||
return $this->_strtoupper("\n\n". $matches[2] ."\n\n");
|
||||
case 'a':
|
||||
return $this->_build_link_list($matches[3], $matches[4]);
|
||||
case 'img':
|
||||
return '[' . $matches[2] . ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user