Hi Francisco,

Here is a BBEdit Text Filter in PHP that capitalizes the text of hyperlinks.
Save it as "~/Library/Application Support/BBEdit/Text 
Filters/capitalize_links_php.php"
and you can call it from the "Text"  > "Apply Text Filter" > 
"capitalize_links_php" menu item.

```PHP
    #!/usr/bin/env php
    <?php
    //---
    function capitalize_skipping_inner_tags($string) {
        $array = preg_split('/(<[^>]+?>)/iusx', $string, -1, 
PREG_SPLIT_DELIM_CAPTURE);
        $m = count($array);
        $i = 0;
        while($i < $m) {
            if (strpos($array[$i], '<') === 0) {
                $i++;
            } else {
                $array[$i] = ucwords(strtolower($array[$i]));
            }
            $i++;
        }
        return implode($array);
    }
    //---
    $input_script = file_get_contents('php://stdin');
    $split_pattern = '/(<a[^>]+?>|<\/a>)/iusx';
    $array = preg_split($split_pattern, $input_script, -1, 
PREG_SPLIT_DELIM_CAPTURE);
    $m = count($array) - 1 ;
    $i = 0;
    while($i < $m) {
        if (stripos($array[$i], '<a') === 0) {
            $i++;
            $array[$i] = capitalize_skipping_inner_tags($array[$i]);
        }
        $i++;
    }
    $output_script = implode($array);
    file_put_contents('php://stdout', $output_script);
    exit(0);
    //---
```
HTH

Jean Jourdain

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/addd2855-88c5-4ec1-829a-9816320421c7n%40googlegroups.com.

Reply via email to