Upgrade to 3.7.1

This commit is contained in:
Bastian Allgeier
2022-07-12 13:33:21 +02:00
parent 7931eb5e47
commit 1ad1eaf387
377 changed files with 63981 additions and 63824 deletions

View File

@@ -18,112 +18,112 @@ use Michelf\SmartyPantsTypographer;
*/
class SmartyPants
{
/**
* Array with all configured options
* for the parser
*
* @var array
*/
protected $options = [];
/**
* Array with all configured options
* for the parser
*
* @var array
*/
protected $options = [];
/**
* Michelf's parser object
*
* @var SmartyPantsTypographer
*/
protected $parser;
/**
* Michelf's parser object
*
* @var SmartyPantsTypographer
*/
protected $parser;
/**
* Returns default values for all
* available parser options
*
* @return array
*/
public function defaults(): array
{
return [
'attr' => 1,
'doublequote.open' => '“',
'doublequote.close' => '”',
'doublequote.low' => '„',
'singlequote.open' => '‘',
'singlequote.close' => '’',
'backtick.doublequote.open' => '“',
'backtick.doublequote.close' => '”',
'backtick.singlequote.open' => '‘',
'backtick.singlequote.close' => '’',
'emdash' => '—',
'endash' => '–',
'ellipsis' => '…',
'space' => '(?: | | |&#0*160;|&#x0*[aA]0;)',
'space.emdash' => ' ',
'space.endash' => ' ',
'space.colon' => ' ',
'space.semicolon' => ' ',
'space.marks' => ' ',
'space.frenchquote' => ' ',
'space.thousand' => ' ',
'space.unit' => ' ',
'guillemet.leftpointing' => '«',
'guillemet.rightpointing' => '»',
'geresh' => '׳',
'gershayim' => '״',
'skip' => 'pre|code|kbd|script|style|math',
];
}
/**
* Returns default values for all
* available parser options
*
* @return array
*/
public function defaults(): array
{
return [
'attr' => 1,
'doublequote.open' => '“',
'doublequote.close' => '”',
'doublequote.low' => '„',
'singlequote.open' => '‘',
'singlequote.close' => '’',
'backtick.doublequote.open' => '“',
'backtick.doublequote.close' => '”',
'backtick.singlequote.open' => '‘',
'backtick.singlequote.close' => '’',
'emdash' => '—',
'endash' => '–',
'ellipsis' => '…',
'space' => '(?: | | |&#0*160;|&#x0*[aA]0;)',
'space.emdash' => ' ',
'space.endash' => ' ',
'space.colon' => ' ',
'space.semicolon' => ' ',
'space.marks' => ' ',
'space.frenchquote' => ' ',
'space.thousand' => ' ',
'space.unit' => ' ',
'guillemet.leftpointing' => '«',
'guillemet.rightpointing' => '»',
'geresh' => '׳',
'gershayim' => '״',
'skip' => 'pre|code|kbd|script|style|math',
];
}
/**
* Creates a new SmartyPants parser
* with the given options
*
* @param array $options
*/
public function __construct(array $options = [])
{
$this->options = array_merge($this->defaults(), $options);
$this->parser = new SmartyPantsTypographer($this->options['attr']);
/**
* Creates a new SmartyPants parser
* with the given options
*
* @param array $options
*/
public function __construct(array $options = [])
{
$this->options = array_merge($this->defaults(), $options);
$this->parser = new SmartyPantsTypographer($this->options['attr']);
// configuration
$this->parser->smart_doublequote_open = $this->options['doublequote.open'];
$this->parser->smart_doublequote_close = $this->options['doublequote.close'];
$this->parser->smart_singlequote_open = $this->options['singlequote.open'];
$this->parser->smart_singlequote_close = $this->options['singlequote.close'];
$this->parser->backtick_doublequote_open = $this->options['backtick.doublequote.open'];
$this->parser->backtick_doublequote_close = $this->options['backtick.doublequote.close'];
$this->parser->backtick_singlequote_open = $this->options['backtick.singlequote.open'];
$this->parser->backtick_singlequote_close = $this->options['backtick.singlequote.close'];
$this->parser->em_dash = $this->options['emdash'];
$this->parser->en_dash = $this->options['endash'];
$this->parser->ellipsis = $this->options['ellipsis'];
$this->parser->tags_to_skip = $this->options['skip'];
$this->parser->space_emdash = $this->options['space.emdash'];
$this->parser->space_endash = $this->options['space.endash'];
$this->parser->space_colon = $this->options['space.colon'];
$this->parser->space_semicolon = $this->options['space.semicolon'];
$this->parser->space_marks = $this->options['space.marks'];
$this->parser->space_frenchquote = $this->options['space.frenchquote'];
$this->parser->space_thousand = $this->options['space.thousand'];
$this->parser->space_unit = $this->options['space.unit'];
$this->parser->doublequote_low = $this->options['doublequote.low'];
$this->parser->guillemet_leftpointing = $this->options['guillemet.leftpointing'];
$this->parser->guillemet_rightpointing = $this->options['guillemet.rightpointing'];
$this->parser->geresh = $this->options['geresh'];
$this->parser->gershayim = $this->options['gershayim'];
$this->parser->space = $this->options['space'];
}
// configuration
$this->parser->smart_doublequote_open = $this->options['doublequote.open'];
$this->parser->smart_doublequote_close = $this->options['doublequote.close'];
$this->parser->smart_singlequote_open = $this->options['singlequote.open'];
$this->parser->smart_singlequote_close = $this->options['singlequote.close'];
$this->parser->backtick_doublequote_open = $this->options['backtick.doublequote.open'];
$this->parser->backtick_doublequote_close = $this->options['backtick.doublequote.close'];
$this->parser->backtick_singlequote_open = $this->options['backtick.singlequote.open'];
$this->parser->backtick_singlequote_close = $this->options['backtick.singlequote.close'];
$this->parser->em_dash = $this->options['emdash'];
$this->parser->en_dash = $this->options['endash'];
$this->parser->ellipsis = $this->options['ellipsis'];
$this->parser->tags_to_skip = $this->options['skip'];
$this->parser->space_emdash = $this->options['space.emdash'];
$this->parser->space_endash = $this->options['space.endash'];
$this->parser->space_colon = $this->options['space.colon'];
$this->parser->space_semicolon = $this->options['space.semicolon'];
$this->parser->space_marks = $this->options['space.marks'];
$this->parser->space_frenchquote = $this->options['space.frenchquote'];
$this->parser->space_thousand = $this->options['space.thousand'];
$this->parser->space_unit = $this->options['space.unit'];
$this->parser->doublequote_low = $this->options['doublequote.low'];
$this->parser->guillemet_leftpointing = $this->options['guillemet.leftpointing'];
$this->parser->guillemet_rightpointing = $this->options['guillemet.rightpointing'];
$this->parser->geresh = $this->options['geresh'];
$this->parser->gershayim = $this->options['gershayim'];
$this->parser->space = $this->options['space'];
}
/**
* Parses the given text
*
* @param string|null $text
* @return string
*/
public function parse(string $text = null): string
{
// prepare the text
$text = str_replace('"', '"', $text ?? '');
/**
* Parses the given text
*
* @param string|null $text
* @return string
*/
public function parse(string $text = null): string
{
// prepare the text
$text = str_replace('"', '"', $text ?? '');
// parse the text
return $this->parser->transform($text);
}
// parse the text
return $this->parser->transform($text);
}
}