Skip to content

Feat/code viewer line numbers - #222

Merged
komalharshita merged 5 commits into
komalharshita:mainfrom
Pranav-IIITM:feat/code-viewer-line-numbers
May 19, 2026
Merged

Feat/code viewer line numbers#222
komalharshita merged 5 commits into
komalharshita:mainfrom
Pranav-IIITM:feat/code-viewer-line-numbers

Conversation

@Pranav-IIITM

@Pranav-IIITM Pranav-IIITM commented May 17, 2026

Copy link
Copy Markdown
Contributor

📝 Pull Request

Summary [required]

This PR enhances the inline code viewer on the project detail page by adding line numbers to the starter code panel. Previously, large starter files were rendered as plain <pre><code> blocks, making navigation difficult for contributors and learners referencing specific lines. The updated implementation improves readability and usability by rendering each line with a dedicated line number column, similar to professional code viewers like GitHub and VS Code.

Related Issue [required]

Closes #95

Type of Change [required]

  • Bug fix — resolves a broken behaviour
  • Feature — adds new functionality
  • Data — adds new projects to data/projects.json
  • Documentation — updates docs, README, or code comments only
  • Style — CSS or visual changes only, no logic change
  • Refactor — restructures code without changing behaviour
  • Test — adds or updates tests

What Was Changed [required]

File Change made
static/script.js Added logic to split starter code into individual lines and render numbered code rows dynamically
static/style.css Added styling for .line-number, .code-line, and .line-content for improved readability and alignment
templates/project.html Updated code viewer structure to support line-based rendering layout

Fixes komalharshita#95

- static/script.js: added renderCodeWithLineNumbers() to split code into
  line rows with separate number and content spans; updated fetchStarterCode()
  to render numbered lines; fixed copy button to extract only line content,
  excluding line numbers
- static/style.css: updated .code-viewer to remove white-space:pre; added
  .code-line, .line-number, and .line-content styles for layout and appearance
- templates/project.html: added display:block to <code> element so flex
  line rows render correctly
@vercel

vercel Bot commented May 17, 2026

Copy link
Copy Markdown

@Pranav-IIITM is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Pranav-IIITM

Pranav-IIITM commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @komalharshita , could you please review this PR when you have some time?

This PR adds line numbers to the inline code viewer on the project detail page to improve readability and navigation for contributors. The implementation now renders starter code line-by-line with a dedicated line number column, similar to GitHub/VS Code style viewers.

I’ve updated the JS rendering logic, added the required styling, and modified the template structure accordingly. Looking forward to your feedback. Thanks!

@komalharshita komalharshita left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enhancement overall. Adding line numbers to the code viewer meaningfully improves readability and makes code references easier for users reviewing starter templates and examples.

The feature appears well-scoped and adds practical UX value without introducing unnecessary modifications. This is especially useful in an educational/project-learning environment like DevPath.

Minor future consideration: verify responsive behavior and ensure line numbers stay properly aligned for larger or wrapped code blocks.

Approved for merge.

@komalharshita
komalharshita merged commit 1692686 into komalharshita:main May 19, 2026
7 of 8 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 line numbers to the inline code viewer panel in the project detail page

2 participants