Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is there a way to customise the knitr::kable() output for Jira style tables? Edited

Azhar Ali I'm New Here Jul 12, 2021

I am trying to create a table output formatting that matches the style of Jira tables. Jira uses pipes like in the knitr::kable(format = "pipe") output but differs with regards to the column headers. Here is an example of my current table format using the knitr package:

data("BOD")
BOD %>% tibble::tibble() %>% 
  head(n = 10) %>% 
  knitr::kable(format = "pipe")

> | Time| demand|
  |----:|------:|
  |    1|    8.3|
  |    2|   10.3|
  |    3|   19.0|
  |    4|   16.0|
  |    5|   15.6|
  |    7|   19.8|

Instead of using a line to separate the headers from the column content, Jira has a slightly different switch syntax:

|| Time|| demand||
|     1|     8.3|
|     2|    10.3|
|     3|    19.0|
|     4|    16.0|
|     5|    15.6|
|     7|    19.8|

Currently, I am removing the ›separation row‹ and modifying the first row:

BOD %>% tibble::tibble() %>% 
  head(n = 10) %>% 
  knitr::kable(format = "pipe") -> tmp
tmp <- tmp[-2] 
tmp[1] <- stringr::str_replace_all(tmp[1], pattern = "\\|", replacement = "||")
tmp %>% writeClipboard() # Paste into Jira
# Output:
|| Time|| demand||
|    1|    8.3|
|    2|   10.3|
|    3|   19.0|
|    4|   16.0|
|    5|   15.6|
|    7|   19.8|

Is there a way to customise the kable() output in order to achieve Jira compatibility?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you