Skip to content

Support factors in fmt_markdown() with HTML output#1883

Merged
rich-iannone merged 1 commit intorstudio:masterfrom
rossellhayes:fix/md-as-character
Sep 18, 2024
Merged

Support factors in fmt_markdown() with HTML output#1883
rich-iannone merged 1 commit intorstudio:masterfrom
rossellhayes:fix/md-as-character

Conversation

@rossellhayes
Copy link
Contributor

Summary

This PR closes #1882 by ensuring factors are converted to text before converting to markdown when fmt_markdown() is used with HTML output. It achieves this by adding text <- as.character(text) as the first step in the md() function. It also adds a test of rendering a factor column with markdown formatting and updates the NEWS file.

gt(data.frame(x = factor("TEST"))) |> 
  fmt_markdown()
x
TEST

Created on 2024-09-17 with reprex v2.1.0

Related GitHub Issues and PRs

Checklist

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

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

This is great, thanks!

@rich-iannone rich-iannone merged commit b4fa1b3 into rstudio:master Sep 18, 2024
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.

Using fmt_markdown() on a factor prints the numeric factor level when the output format is HTML

2 participants