diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 00000000..8da0349d --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2024-05-15 - Enhancing Generated File Tree HTML +**Learning:** Raw directory listings generated into HTML often lack critical accessibility meta tags (like `lang="en"`, `viewport` for responsive scaling) and aria-labels for directory/file links (which are otherwise non-descriptive for screen readers like just `📁 folderName`). +**Action:** Always include base semantic structures (`
`, ``, responsive meta tags) and `aria-label`s specifying the entity type (e.g., `folderName directory`) when generating raw navigation trees to ensure keyboard and screen-reader usability. Add `:focus` styles mimicking `:hover` for keyboard users. diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index 50b2680d..5dca48bb 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -99,6 +99,7 @@ fun process_dir(curr_dir: File){ padding: 0.5rem; text-decoration: none; color: #0366d6; + border-radius: 4px; } a:hover, a:focus-visible { background-color: #f6f8fa; @@ -118,9 +119,10 @@ fun process_dir(curr_dir: File){ ${css} -

${curr_dir.getName().escapeHtml()}

- +
""" diff --git a/src/main/kotlin/html4tree/util.kt b/src/main/kotlin/html4tree/util.kt index 9a882d74..c8979c31 100644 --- a/src/main/kotlin/html4tree/util.kt +++ b/src/main/kotlin/html4tree/util.kt @@ -39,7 +39,7 @@ class LinkedList { if(l == null){ return null } else { - l.next = null + l.next = null return LinkedListEntry(l.data, l.level) } } diff --git a/src/test/kotlin/html4tree/MainTest.kt b/src/test/kotlin/html4tree/MainTest.kt index 31c193a2..1cd3188a 100644 --- a/src/test/kotlin/html4tree/MainTest.kt +++ b/src/test/kotlin/html4tree/MainTest.kt @@ -110,7 +110,11 @@ class MainTest { assertTrue(indexFile.exists()) val htmlContent = indexFile.readText() assertTrue(htmlContent.contains("")) + assertTrue(htmlContent.contains("
")) + assertTrue(htmlContent.contains("
")) assertTrue(htmlContent.contains("aria-label=\"상위 디렉토리로 이동\"")) + assertTrue(htmlContent.contains("aria-label=\"file1.txt 파일\"")) + assertTrue(htmlContent.contains("aria-label=\"subdir 디렉토리\"")) assertTrue(htmlContent.contains("file1.txt")) assertTrue(htmlContent.contains("subdir/")) assertTrue(htmlContent.contains("📁"))