3636# '
3737# ' @importFrom knitr is_latex_output
3838# ' @importFrom knitr is_html_output
39- # ' @importFrom knitr opts_knit
40- # ' @importFrom gt gt
41- # ' @importFrom gt tab_footnote
42- # ' @importFrom gt tab_options
43- # ' @importFrom gt fmt_markdown
44- # ' @importFrom gt md
45- # ' @importFrom gt as_word
46- # ' @importFrom gt opt_table_lines
39+ # ' @importFrom kableExtra kable_minimal
40+ # ' @importFrom kableExtra kbl
41+ # ' @importFrom kableExtra footnote
4742# ' @importFrom methods missingArg
4843# ' @importFrom methods hasArg
4944# ' @export
@@ -256,40 +251,35 @@ gloss_example <- function(transliteration,
256251 }
257252 }
258253
259- result | >
260- as.data.frame() | >
261- gt :: gt() | >
262- gt :: tab_options( column_labels.hidden = TRUE ,
263- table.align = " left " ) | >
264- gt :: opt_table_lines( extent = " none " ) | >
265- gt :: fmt_markdown() - >
266- result
254+ if (isTRUE( knitr :: opts_knit $ get( ' rmarkdown.pandoc.to ' ) != " docx " )) {
255+
256+ result <- kableExtra :: kbl( result , align = " l " , centering = FALSE ,
257+ escape = FALSE , vline = " " )
258+ result <- kableExtra :: kable_minimal( result ,
259+ position = " left " ,
260+ full_width = FALSE )
261+
267262
268263# add video ---------------------------------------------------------------
269264 if (! is.null(video_path ) & knitr :: is_html_output()){
270265 if (length(video_path ) > 1 ){
271266 stop(" video_path argument should be of the length 1" )
272267 }
273- result <- gt :: tab_footnote( data = result ,
274- footnote = as.character(
268+ result <- kableExtra :: footnote( kable_input = result ,
269+ general = as.character(
275270 add_video(video_path ,
276271 video_width ,
277- video_height )))
278- }
279-
280- # add free translation -----------------------------------------------------
281- if (nchar(free_translation ) > 0 ){
282- result <- gt :: tab_footnote(data = result ,
283- footnote = paste0(" '" ,
284- gt :: md(free_translation ),
285- " '" ))
272+ video_height )),
273+ general_title = " " ,
274+ escape = FALSE )
286275 }
287276
288277
289278# add comment --------------------------------------------------------------
290279 if (nchar(comment ) > 0 ){
291- result <- gt :: tab_footnote(data = result ,
292- footnote = gt :: md(comment ))
280+ result <- kableExtra :: footnote(kable_input = result ,
281+ general = comment ,
282+ general_title = " " )
293283 }
294284
295285# add audio ---------------------------------------------------------------
@@ -307,6 +297,15 @@ gloss_example <- function(transliteration,
307297 } else {
308298 add_to_translation <- " '"
309299 }
300+ # add free translation -----------------------------------------------------
301+ if (nchar(free_translation ) > 0 ){
302+ result <- kableExtra :: footnote(kable_input = result ,
303+ general = paste0(" '" ,
304+ free_translation ,
305+ add_to_translation ),
306+ general_title = " " ,
307+ escape = FALSE )
308+ }
310309
311310# remove lines from LaTeX --------------------------------------------------
312311 if (knitr :: is_latex_output()){
@@ -315,6 +314,28 @@ gloss_example <- function(transliteration,
315314 result <- gsub(" \\\\ bottomrule" , " " , result )
316315 result <- gsub(" \\\\ hline" , " " , result )
317316 }
317+
318+ } else {
319+ result | >
320+ as.data.frame() | >
321+ gt :: gt() | >
322+ gt :: tab_options(column_labels.hidden = TRUE ,
323+ table.align = " left" ) | >
324+ gt :: opt_table_lines(extent = " none" ) | >
325+ gt :: fmt_markdown() - >
326+ result
327+
328+ if (nchar(free_translation ) > 0 ){
329+ result <- gt :: tab_footnote(data = result ,
330+ footnote = paste0(" '" ,
331+ gt :: md(free_translation ),
332+ " '" ))
333+ }
334+ if (nchar(comment ) > 0 ){
335+ result <- gt :: tab_footnote(data = result ,
336+ footnote = gt :: md(comment ))
337+ }
338+ }
318339 }
319340 }
320341
@@ -328,9 +349,9 @@ gloss_example <- function(transliteration,
328349 sep = " \n " )
329350 }
330351 } else {
331- for ( i in multiline_result ) {print( i )}
352+ cat(unlist( multiline_result ))
332353 }
333- } else {
354+ } else {
334355 return (result )
335356 }
336357}
0 commit comments