Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace YakNet\AccessibilityConsole\AutoFix;
|
||
|
|
|
||
|
|
class HtmlRepairEngine
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Instantly auto-repair common WCAG accessibility issues in raw HTML strings without network calls.
|
||
|
|
*
|
||
|
|
* @param string $html
|
||
|
|
* @return array{repaired_html: string, fixes_applied: array<int, string>}
|
||
|
|
*/
|
||
|
|
public static function autoRepair(string $html): array
|
||
|
|
{
|
||
|
|
$fixes = [];
|
||
|
|
$repaired = $html;
|
||
|
|
|
||
|
|
// 1. Ensure <html lang="..."> attribute
|
||
|
|
if (preg_match('/<html\b(?![^>]*\blang=)[^>]*>/i', $repaired)) {
|
||
|
|
$repaired = preg_replace('/<html\b([^>]*)>/i', '<html lang="tr"$1>', $repaired) ?? $repaired;
|
||
|
|
$fixes[] = 'Added missing lang="tr" attribute to <html> tag.';
|
||
|
|
}
|
||
|
|
|
||
|
|
// 2. Add aria-hidden="true" to decorative <svg> tags missing aria-hidden
|
||
|
|
$svgBefore = $repaired;
|
||
|
|
$repaired = preg_replace_callback('/<svg\b(?![^>]*\baria-hidden=)[^>]*>/i', function($matches) {
|
||
|
|
return str_replace('<svg', '<svg aria-hidden="true"', $matches[0]);
|
||
|
|
}, $repaired) ?? $repaired;
|
||
|
|
|
||
|
|
if ($repaired !== $svgBefore) {
|
||
|
|
$fixes[] = 'Added aria-hidden="true" to decorative <svg> icons.';
|
||
|
|
}
|
||
|
|
|
||
|
|
// 3. Add alt="" to <img> tags missing alt attribute
|
||
|
|
$imgBefore = $repaired;
|
||
|
|
$repaired = preg_replace_callback('/<img\b(?![^>]*\balt=)[^>]*>/i', function($matches) {
|
||
|
|
return str_replace('<img', '<img alt=""', $matches[0]);
|
||
|
|
}, $repaired) ?? $repaired;
|
||
|
|
|
||
|
|
if ($repaired !== $imgBefore) {
|
||
|
|
$fixes[] = 'Added empty alt="" attribute to decorative <img> elements.';
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
'repaired_html' => $repaired,
|
||
|
|
'fixes_applied' => $fixes,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|