emphatic icon indicating copy to clipboard operation
emphatic copied to clipboard

General fixes

Open coolbutuseless opened this issue 2 years ago • 1 comments

  • [x] populate HL_* options from the users environment at startup.
  • [x] Unmodifed strings in hl_diff should not be coloured at all and work in both light and dark modes.
  • [x] PIck good contrasting colours for hl_diff and hl_grep
  • [x] Revisit knitr output and extend adapt for quarto output
  • [x] Unify grep highlighting into single function
  • [x] honour 'dark mode' setting in all default colouring
  • [x] Revisit how options are set, read and adjusted. Global settings vs per object settings
  • [x] bugfix hl_diff for longer outputs e.g. hl_str_diff(head(mtcars), head(mtcars, 7))
  • [x] Decide on what to support for release: Currently have
    • [x] data.frames
    • [x] ~~matrices~~
    • [x] differences
    • [x] regular expressions
  • [x] Sanity check arguments to hl_opts()
  • [x] Consider swapping arguments from (data, colour, selection) to (data, selection, colour)
  • [x] Rendering SVG for a vignette for CRAN? Is it possible?
  • [x] Replace all magrittr pipe with base R pipe
  • [x] Unify terminology: bg/fg vs fill/text I think I prefer fill/text
  • [x] hl_diff and hl_grep should auto-generate a contrasting colour if only 'fill' is given.
  • [x] Consider changing "colour" argument to "palette". This avoids name confusions with 'col' and 'dest_cols' argument. And also this variable should capture single colours as well colour scale objects.
  • [x] Rename cols and dest_cols to clarify their purposes/differences.
  • [x] Is dark mode now obsolete? Yes
  • [x] Add option to as_html() to include full DOCTYPE and html tags so it could be saved as a valid/complete html file.
  • [x] When rendering to github marked - coloured text is html wrapped in an SVG. But the HTML still needs to be escaped.
    • [x] Need to htmlescape when using as_html()
    • [x] Clone functionality of htmltools::htmlescape. Pretty sure this is just a regex
    • [x] Will also need to escape rownames and column names. this will be rarer, but still possible.
  • [x] Default colours for hl_grep() and hl_diff() should come from options/environment.
  • [x] When using a scale object as the palette. I think we can do away with the 'scale_mode' argument. If multiple columns are specified, then the scale is trained globally on all data. The scale_mode = 'first' setting should probably be expanded such that the user does multiple hl() commands. Then use scale_apply() if you want the same colouring shown across multiple columns.
  • [x] ~~Expose ANSI colouring viewing and conversion functions? No~~
  • [x] Remove 'underline_header' as an option
  • [x] Refactor/Unify code for the backends. Move all the escape_*() functions to their respective core-*.R files. Maybe unify into a named list of functions and options so that I can remove some messy if/then logic in hl_inner() and hl_loc()
  • [x] Rethink default colours for hl_diff() - should be less severe? and hl_grep() should be yellow?
  • [x] PDF/latex table rendering ist still a little askew. Difference between leading space and \ space definition?
  • [x] Add font size option to html, svg and latex output
  • [x] ~~Can i roughly calculated SVG height?~~ No.
  • [x] collapser for html should just be <br/>. Because we're rendering in <pre> mode, any \n will actually put spaces between the lines

Rendering backends

  • [x] Full HTML document - with DOCTYPE and html tags
  • [x] Full SVG document
  • [x] Latex support so that rendering to PDF works.
  • [x] typst rendering
    • [x] What's the best standard monospace font. font set to Courier New. Can be changed in call to as_typst()
    • [x] Hook up rendering with knitr/quarto by checking pandoc_to or similar and calling as_typst(). done.
    • [x] Unpack the guts of knitr::raw_block() to be part of as_typst() to get output to render
    • [x] Using the raw block support. No need to escape anything but the backtick.
  • [x] animated SVG

Before release

  • [ ] Regenerate pkgdown site
  • [ ] Do a pass over function docs
  • [ ] Do a pass over function internal commenting
  • [ ] Focus README on what's important
  • [ ] Extend vignettes to cover new features e.g. hl_diff() works on any object.

Cran stuff

  • [ ] Rhub tests
  • [ ] All functions must have an example
  • [ ] All functions must have a return value
  • [ ] Check on win-builder
  • [ ] Check on mac-builder
  • [ ] Update authors and copyright

Future?

  • Word & Excel rendering
  • HTML hover text

coolbutuseless avatar Apr 26 '24 23:04 coolbutuseless

This should probably work for escaping HTML

html_replacement <- c(
  `&` = "&amp;",
  `<` = "&lt;",
  `>` = "&gt;",
  `"` = "&quot;",
  `'` = "&#39;"
)


escape_html <- function(x) {
  x <- enc2utf8(x)
  for (orig in names(html_replacement)) {
    x <- gsub(orig, html_replacement[[orig]], x, fixed = TRUE, useBytes = TRUE)
  }
  Encoding(x) <- 'UTF-8'
  x
}

coolbutuseless avatar Apr 29 '24 00:04 coolbutuseless