<commit_before><?php
/**
 * @package    CleverStyle CMS
 * @subpackage Service scripts
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2014, <NAME>
 * @license    MIT License, see license.txt
 */
if ($argc < 3) {
	exit("Converts any CSS file into CSS that works inside Shadow DOM (native support of polyfill needed after conversion).\nUsage: php make_css_shadow_dom_ready.php source.css destination.css\n");
}
$content = file_get_contents($argv[1]);
if (preg_match('#/deep/#', $content)) {
	exit("Already ready, no actions needed!\n");
}
function process_content ($content) {
	return preg_replace_callback('/([^\{\}]+)(\{[^\}]+\})/', function ($matches) {
		$selector = explode(',', $matches[1]);
		$content  = $matches[2];
		foreach ($selector as &$s) {
			$s = trim($s);
			if ($s == 'html') {
				continue;
			}
			if (strpos($s, '@') === 0) {
				$content = process_content($content);
				continue;
			}
			if (strpos($s, 'html') === 0) {
				$s = explode(' ', $s, 2);
				$s = "$s[0] /deep/ $s[1]";
			} else {
				$s = "html /deep/ $s";
			}
		}
		$selector = implode(',', $selector);
		return "$selector$content";
	}, $content);
}

$content = process_content($content);
file_put_contents($argv[2], $content);<commit_msg>Simplified usage of `make_css_shadow_dom_ready.php` service script.<commit_after><?php
/**
 * @package    CleverStyle CMS
 * @subpackage Service scripts
 * @author     <NAME> <<EMAIL>>
 * @copyright  Copyright (c) 2014, <NAME>
 * @license    MIT License, see license.txt
 */
if ($argc < 2) {
	exit("Converts any CSS file into CSS that works inside Shadow DOM (native support of polyfill needed after conversion).\nUsage: php make_css_shadow_dom_ready.php source.css[ destination.css]\n");
}
$content = file_get_contents($argv[1]);
if (preg_match('#/deep/#', $content)) {
	exit("Already ready, no actions needed!\n");
}
function process_content ($content) {
	return preg_replace_callback('/([^\{\}]+)(\{[^\}]+\})/', function ($matches) {
		$selector = explode(',', $matches[1]);
		$content  = $matches[2];
		foreach ($selector as &$s) {
			$s = trim($s);
			if ($s == 'html') {
				continue;
			}
			if (strpos($s, '@') === 0) {
				$content = process_content($content);
				continue;
			}
			if (strpos($s, 'html') === 0) {
				$s = explode(' ', $s, 2);
				$s = "$s[0] /deep/ $s[1]";
			} else {
				$s = "html /deep/ $s";
			}
		}
		$selector = implode(',', $selector);
		return "$selector$content";
	}, $content);
}

$content = process_content($content);
file_put_contents(@$argv[2] ?: $argv[1], $content);
{'fraction_non_alphanumeric': 0.2102785406041585, 'fraction_numerical': 0.011377010592389172, 'mean_word_length': 3.8850574712643677, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3129035', 'n_tokens_mistral': 995, 'n_tokens_neox': 890, 'n_words': 225}