Skip to content

fix: add filename label support for <code> blocks#178

Merged
CodexRaunak merged 1 commit intolayer5io:masterfrom
NathanaelFetue:fix/code-filename-labels
Apr 8, 2026
Merged

fix: add filename label support for <code> blocks#178
CodexRaunak merged 1 commit intolayer5io:masterfrom
NathanaelFetue:fix/code-filename-labels

Conversation

@NathanaelFetue
Copy link
Copy Markdown
Contributor

This PR follows up on #173 by extending the filename attribute support to plain <code> blocks, ensuring UI consistency across all code display methods on the Academy platform.

Changes

  • Added CSS rules for code[filename] selector
  • Maintains same styling as existing .highlight[filename] blocks
  • Backward compatible - no breaking changes

Implementation

code[filename] {
  display: block;
  margin-top: 2rem;
}

code[filename]::before {
  content: attr(filename);
  // ... same styling as .highlight[filename]::before
}

Fixes #177

cc @CodexRaunak

- Extended filename label support beyond .highlight[filename]
- Now works with plain <code filename='...'> blocks
- Maintains consistent styling between both implementations
- Fixes layer5io#177

Signed-off-by: Nathanael-FETUE <114958970+NathanaelFetue@users.noreply.github.com>
@NathanaelFetue NathanaelFetue force-pushed the fix/code-filename-labels branch from e6e9cf8 to 853d587 Compare April 8, 2026 16:50
@CodexRaunak
Copy link
Copy Markdown
Contributor

CodexRaunak commented Apr 8, 2026

@NathanaelFetue can you also provide a screenshot

@NathanaelFetue
Copy link
Copy Markdown
Contributor Author

NathanaelFetue commented Apr 8, 2026

@CodexRaunak Here's a screenshot demonstrating both implementations:

Test 1 - Existing .highlight[filename] behavior from #173:

  • HTML: <div class="highlight" filename="config.yaml"><pre><code>...</code></pre></div>
  • Result: ✅ Label displays (existing feature)

Test 2 - NEW code[filename] support (this PR):

  • HTML: <code filename="example.js">console.log("...");</code>
  • Result: ✅ Label displays (new feature - previously didn't work!)

The CSS I added applies the same styling to code[filename] as the existing .highlight[filename], maintaining UI consistency across all code display methods:

code[filename]::before {
  content: attr(filename);
  // ... same styling properties
}

2

@CodexRaunak CodexRaunak merged commit 495fdd9 into layer5io:master Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for code for filename labels

2 participants