Skip to content

Line-by-line conversion to HTML #59

@krlmlr

Description

@krlmlr

In the tibble 2.0.1 blog post, converting each line of output separately helped work around how the blackfriday markdown -> HTML converter treats newlines embedded in HTML: tidyverse/tidyverse.org@32d6829. Perhaps conversion to HTML should treat newlines separately? I'm not sure if and where this change should happen, though.

In the reprex below, applying strsplit() just seems to work even if the newline is inside a block. I don't understand why.

options(crayon.enabled = TRUE)
text <- crayon::blue("a\nb")
fansi::sgr_to_html(text)
#> [1] "<span style='color: #0000BB;'>a\nb</span>"

text_split <- unlist(strsplit(text, "\n", fixed = TRUE))
fansi::sgr_to_html(text_split)
#> [1] "<span style='color: #0000BB;'>a</span>"
#> [2] "<span style='color: #0000BB;'>b</span>"

Created on 2019-01-13 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions