代码之家  ›  专栏  ›  技术社区  ›  landau

在多行文本上打印单个可隐藏行

  •  0
  • landau  · 技术社区  · 7 年前

    有时需要在 tibble 在多行上。例子: https://github.com/ropensci/drake/issues/489 . drake plans 长命令很难读取。

    library(drake)
    pkgconfig::set_config("drake::strings_in_dots" = "literals")
    drake_plan(
      u_auckland = make_place(
        Name = "University of Auckland",
        Latitude = -36.8521369,
        Longitude = 174.7688785
      ),
      shapefile = {
        file_out("u-auckland.prj", "u-auckland.shx", "u-auckland.dbf")
        st_write(
          obj = u_auckland,
          dsn = file_out("u-auckland.shp"),
          driver = "ESRI Shapefile",
          delete_dsn = TRUE
        )
      }
    )
    #> # A tibble: 2 x 2
    #>   target     command                                                      
    #> * <chr>      <chr>                                                        
    #> 1 u_auckland "make_place(Name = \"University of Auckland\", Latitude = -3…
    #> 2 shapefile  "{\n    file_out(\"u-auckland.prj\", \"u-auckland.shx\", \"u…
    

    罐头 pillar::pillar_shaft() 或者类似的工具来达到更好的效果?我主要关注换行和缩进(可能与 styler )但我也对语法突出显示感兴趣,可能是 hightlight crayon .

    # A tibble: 2 x 2
      target     command                                             
    * <chr>      <drake_cmd>
    1 u_auckland make_place(
                   Name = "University of Auckland",
                   Latitude = -36.8521369,
                   Longitude = 174.7688785
                 )
    2 shapefile  {
                   file_out(
                     "u-auckland.prj",
                     "u-auckland.shx",
                     "u-auckland.dbf"
                   )
                   st_write(
                     obj = u_auckland,
                     dsn = file_out("u-auckland.shp"),
                     driver = "ESRI Shapefile",
                     delete_dsn = TRUE
                   )
                 }
    
    1 回复  |  直到 7 年前