加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 将markdown斜体和粗体转换为乳胶

发布时间:2020-12-14 03:58:57 所属栏目:Windows 来源:网络整理
导读:我希望能够将markdown斜体和粗体转换为乳胶版本(即,给文本字符串返回文本字符串).我觉得很容易.错误! (它仍然可能是).看到我在底部试过的窗台商务和错误. 我有什么(注意在降价时已经转义的起始星号): x - "*note: I *like* chocolate **milk** too ***mu
我希望能够将markdown斜体和粗体转换为乳胶版本(即,给文本字符串返回文本字符串).我觉得很容易.错误! (它仍然可能是).看到我在底部试过的窗台商务和错误.

我有什么(注意在降价时已经转义的起始星号):

x <- "*note: I *like* chocolate **milk** too ***much***!"

我想要的是什么:

"*note: I emph{like} chocolate textbf{milk} too textbf{emph{much}}!"

我不喜欢正则表达式,但更喜欢基础解决方案(虽然不是必需的).

愚蠢的业务:

helper <- function(ins,outs,x) {
    gsub(paste0(ins[1],".+?",ins[2]),paste0(outs[1],outs[2]),x)
}

helper(rep("***",2),c("textbf{emph{","}}"),x)

Error in gsub(paste0(ins[1],: 
  invalid regular expression '***.+?***',reason 'Invalid use of repetition operators'

如果有帮助的话,我有7000 Ananda Mahto帮我做的.您可以通过wheresPandoc< - reports ::: wheresPandoc从报告中访问它 编辑Per Ben的评论我试过:

action <- paste0(" echo ",x," | ",wheresPandoc()," -t latex ") 
system(action)

*note: I *like* chocolate **milk** too ***much***! | C:PROGRA~2Pandocbinpandoc.exe -t latex

EDIT2 Per Dason的评论我尝试过:

out <- paste("echo",shQuote(x),"|"," -t latex"); system(out)
system(out,intern = T)

> system(out,intern = T)
*note: I *like* chocolate **milk** too ***much***! | C:PROGRA~2Pandocbinpandoc.exe -t latex

解决方法

注意到我正在使用Windows和系统

This means that redirection,pipes,DOS internal commands,… cannot be used

以及来自?system2的说明

Note

system2 is a more portable and flexible interface than system,
introduced in R 2.12.0. It allows redirection of output without
needing to invoke a shell on Windows,a portable way to set
environment variables for the execution of command,and finer control
over the redirection of stdout and stderr. Conversely,system (and
shell on Windows) allows the invocation of arbitrary command lines.
Using system2

system2('pandoc','-t latex',input = '**em**',stdout = TRUE)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读