-
Notifications
You must be signed in to change notification settings - Fork 20
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
Develop Lua filters for common LaTeX macros not handled by pandoc directly #35
Comments
Thank you again. This is exactly where we wanted to go! I think this would be an interesting task for our future Outreachy fellow. |
Thanks Martin, @mtmorgan Here is a working filter that I was able to come up with. The language is a bit unwieldy and I'm a novice :) function RawInline (raw)
local formula = raw.text:match '\\Rpackage{(.*)}'
if raw.format == 'latex' and formula then
return pandoc.RawInline('markdown', '`r Biocpkg(' .. formula .. ')`')
end
local formula = raw.text:match '\\Robject{(.*)}'
if raw.format == 'latex' and formula then
return pandoc.RawInline('markdown', '`' .. formula .. '`')
end
local formula = raw.text:match '\\Rfunction{(.*)}'
if raw.format == 'latex' and formula then
return pandoc.RawInline('markdown', '`' .. formula .. '`')
end
end |
It would probably be helpful to come up with a test Rnw document and corresponding expected Rmd document, with one line per LaTeX 'test' --> corresponding Rmd. I tweaked your code & my code a bit
to translate
to get something that is mostly correct(?)
As you note, probably there are much better ways of implementing the Lua code, which is highly repetitive now! Also, maybe we could start a Lua repository that might start to follow better practices (than an issue thread!) for Lua development... |
@mcarlsn @villafup @BerylKanali It might be that you've noticed things that we repeatedly have to manually edit to get it in the right format. It might good to start documenting that here, so that we can make sure those cases are included. I agree with @mtmorgan that it would be nice to come up with a test .Rnw. Maybe @BerylKanali can help with this given some guidance? |
@jwokaty perhaps it makes sense to create a |
Following on #34, This StackOverflow post shows how to write a Lua filter; a set of these might be developed for the BiocStyle macros as a kind of 'meta' resource for this project.
This
would replace the Rnw macro
\R{}
with the markdown_R_
and if in a fileBiocStyle-Rnw-to-Rmd.lua
would be used asThe next macros to tackle are likely
\CRANpkg{<package name>}
and\Biocpkg{<package name>}
which translate to markdown links[<package name>](https://cran.r-project.org/package=<package name>)
and[<package name>](https://bioconductor.org/packages/<package name>
followed by\Rcode{<inline code>}
translated to`<inline code>`
. I think Sweave code chunks<<...>>= ... @
could also be translated automaticallyThe text was updated successfully, but these errors were encountered: