Skip to content
New issue

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

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

Already on GitHub? # to your account

CaseClauseError if component doc contains fenced code block with non elixir/heex lang #570

Closed
woylie opened this issue Jan 30, 2025 · 1 comment · Fixed by #572
Closed
Assignees
Labels
bug Something isn't working

Comments

@woylie
Copy link
Contributor

woylie commented Jan 30, 2025

If a component documentation contains a fenced code block with a language other than Elixir or HEEx, a CaseClauseError is produced and the story cannot be rendered.

@doc """
Here's some example CSS:

```css
.component {
  color: pink;
}
```-
"""

(Added a dash to trick the GH syntax highlighter.)

Stacktrace:

[error] ** (CaseClauseError) no case clause matching: "css"
    (phoenix_storybook 0.8.1) lib/phoenix_storybook/stories/doc.ex:112: PhoenixStorybook.Stories.Doc.highlight_code_block/3
    (elixir 1.18.2) lib/regex.ex:808: Regex.apply_list/5
    (elixir 1.18.2) lib/regex.ex:803: Regex.apply_list/5
    (elixir 1.18.2) lib/regex.ex:809: Regex.apply_list/5
    (elixir 1.18.2) lib/regex.ex:803: Regex.apply_list/5
    (elixir 1.18.2) lib/regex.ex:738: Regex.replace/4
    (phoenix_storybook 0.8.1) lib/phoenix_storybook/stories/doc.ex:30: PhoenixStorybook.Stories.Doc.fetch_doc_as_html/2
    (phoenix_storybook 0.8.1) lib/phoenix_storybook/live/story/component_doc.ex:35: PhoenixStorybook.Story.ComponentDoc."render_documentation (overridable 1)"/1
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/tag_engine.ex:96: Phoenix.LiveView.TagEngine.component/3
    (phoenix_storybook 0.8.1) lib/phoenix_storybook/live/story_live.ex:224: anonymous fn/2 in PhoenixStorybook.StoryLive.render/1
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/diff.ex:414: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/diff.ex:555: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
    (elixir 1.18.2) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/diff.ex:412: Phoenix.LiveView.Diff.traverse/7
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/diff.ex:136: Phoenix.LiveView.Diff.render/3
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/static.ex:288: Phoenix.LiveView.Static.to_rendered_content_tag/4
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/static.ex:171: Phoenix.LiveView.Static.do_render/4
    (phoenix_live_view 1.0.3) lib/phoenix_live_view/controller.ex:39: Phoenix.LiveView.Controller.live_render/3
    (phoenix 1.7.18) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5

Code that produces the error:

@cblavier
Copy link
Contributor

thanks, will fix ASAP

@cblavier cblavier self-assigned this Jan 30, 2025
@cblavier cblavier added the bug Something isn't working label Jan 30, 2025
@cblavier cblavier linked a pull request Jan 31, 2025 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants