Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline-code in markdown tables adds an unwanted \tab #985

Closed
pat-s opened this issue Nov 21, 2019 · 3 comments
Closed

inline-code in markdown tables adds an unwanted \tab #985

pat-s opened this issue Nov 21, 2019 · 3 comments
Labels
bug markdown ⬇️ wip
Milestone

Comments

@pat-s
Copy link
Contributor

@pat-s pat-s commented Nov 21, 2019

#' @title test fun
#'
#' @description test.
#'
#' @section test:
#'
#' | **test** | **test** | **test** |
#' | -------- | -------- |  ------------   |
#' | `test` | test | `test` test 2 |
#' @name test
#' @export
NULL

results in

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/test.R
\name{test}
\alias{test}
\title{test fun}
\description{
test.
}
\section{test}{
\tabular{lll}{
   \strong{test} \tab \strong{test} \tab \strong{test} \cr
   \code{test} \tab test \tab \code{test} \tab test 2 \cr
}
}

Note the additional \tab after \code{test}. This breaks the table formatting as this line now has 4 cols instead of 3.

(I tried to come up with a full reprex but didn't manage to combine roxygen2:::roc_proc_text(roxygen2:::rd_roclet() in the right way.)

@hadley
Copy link
Member

@hadley hadley commented Nov 21, 2019

Easiest way to make a reprex here is to use internal markdown() function:

md <- "
| x     |
| ----- |
| `x` y |
"
cat(roxygen2:::markdown(md))
#> \tabular{l}{
#>    x \cr
#>    \code{x} \tab  y \cr
#> }

md <- "
| x     |
| ----- |
| x y   |
"
cat(roxygen2:::markdown(md))
#> \tabular{l}{
#>    x \cr
#>    x y \cr
#> }

Created on 2019-11-21 by the reprex package (v0.3.0)

@hadley
Copy link
Member

@hadley hadley commented Nov 21, 2019

Quick check that the problem lies in roxygen2:

md <- "
| x     |
| ----- |
| `x` y |
"
cat(commonmark::markdown_xml(md, extensions = "table"))
#> <?xml version="1.0" encoding="UTF-8"?>
#> <!DOCTYPE document SYSTEM "CommonMark.dtd">
#> <document xmlns="http://commonmark.org/xml/1.0">
#>   <table>
#>     <table_header>
#>       <table_cell>
#>         <text xml:space="preserve">x</text>
#>       </table_cell>
#>     </table_header>
#>     <table_row>
#>       <table_cell>
#>         <code xml:space="preserve">x</code>
#>         <text xml:space="preserve"> y</text>
#>       </table_cell>
#>     </table_row>
#>   </table>
#> </document>

Created on 2019-11-21 by the reprex package (v0.3.0)

@hadley hadley added bug markdown ⬇️ wip labels Nov 21, 2019
@hadley hadley added this to the v7.0.1 milestone Nov 21, 2019
@pat-s
Copy link
Contributor Author

@pat-s pat-s commented Nov 21, 2019

Thanks for the quick fix and the reprex example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug markdown ⬇️ wip
Projects
None yet
Development

No branches or pull requests

2 participants