Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight code blocks in components docs #561

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

xxdavid
Copy link
Contributor

@xxdavid xxdavid commented Jan 17, 2025

Hi @cblavier!

Finally I got some time work on Phoenix Storybook. 🙁 With this PR, I am building on your great work in #525 and fixing the only leftover from #514 – syntax highlighting for code blocks in the docs.

The code for highlighting was heavily inspired by
https://github.com/dashbitco/nimble_publisher/blob/140066e4c7b39f2c93bae662d3606fca1c1dce4d/lib/nimble_publisher/highlighter.ex

It works for both HEEx and Elixir code. When the language is not explicitly mentioned, HEEx is assumed if the code block starts with < (for an HTML tag), otherwise Elixir is used.

Screenshot 2025-01-17 at 11 20 43

@cblavier
Copy link
Contributor

Thank you, David!

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.48%. Comparing base (0b549e5) to head (6545620).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #561      +/-   ##
==========================================
+ Coverage   96.45%   96.48%   +0.03%     
==========================================
  Files          40       40              
  Lines        2201     2222      +21     
==========================================
+ Hits         2123     2144      +21     
  Misses         78       78              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cblavier
Copy link
Contributor

The code looks good to me! 👍
can you please add some tests? (see #561 (comment))
you can run mix coverage locally

@xxdavid
Copy link
Contributor Author

xxdavid commented Jan 17, 2025

Of course, I forget to write some. I'll do it now and force push with an amended commit.

@xxdavid xxdavid force-pushed the highlight_code_in_docs branch from 9ef8572 to 6545620 Compare January 17, 2025 11:56
@xxdavid
Copy link
Contributor Author

xxdavid commented Jan 17, 2025

Now it should be better. 🙂

@cblavier
Copy link
Contributor

perfect, thanks! 🚀

@cblavier cblavier merged commit 9813d0d into phenixdigital:main Jan 17, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants