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

mark oddly interprets input as file where documentation suggests otherwise? #100

Closed
LukasWallrich opened this issue Apr 28, 2023 · 3 comments

Comments

@LukasWallrich
Copy link

I frequently use markdown::mark(), yet now ran into an issue where "*F*(5, 7165) = 358.25, *p* < .001" was interpreted as a filename. Having never looked at the documentation before, it took me a while to figure out where that error came from.

According to the docs a single character string input will be treated as a file only when the file exists or it has a file extension - neither seems to be the case here?

markdown::mark("*F*(5, 7165) = 358.25, *p* < .001")
#> Warning in file(con, "r"): cannot open file '*F*(5, 7165) = 358.25, *p* <
#> .001': No such file or directory
#> Error in file(con, "r"): cannot open the connection

Created on 2023-04-28 with reprex v2.0.2

@yihui
Copy link
Member

yihui commented Apr 28, 2023

In this case, .001 was treated as a "file extension":

markdown/man/mark.Rd

Lines 24 to 30 in 0f64983

\item{file}{Path to an input file. If not provided, it is presumed that the
\code{text} argument will be used instead. This argument can also take a
character vector of Markdown text directly. To avoid ambiguity in the
latter case, a single character string input will be treated as a file only
when the file exists or it has a file extension. If a string happens to
have a \dQuote{file extension} and should be treated as Markdown text
instead, wrap it in \code{I()}.}

To ensure the input is text, use either I() or the text argument:

markdown::mark(I("*F*(5, 7165) = 358.25, *p* < .001"))
markdown::mark(text = "*F*(5, 7165) = 358.25, *p* < .001")

I think the file extension heuristics in mark() should be improved and I'll see what I can do. Thanks for the report!

@yihui yihui closed this as completed in 534d3be Apr 28, 2023
@yihui
Copy link
Member

yihui commented Apr 28, 2023

Should be fixed now. Thanks again!

@LukasWallrich
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants