通过travis向下构建中的图像路径
我使用通过travis向下构建中的图像路径,r,r-markdown,travis-ci,bookdown,R,R Markdown,Travis Ci,Bookdown,我使用Bookdown构建了一系列Rmd文件。在这些Rmd文件中,有一个对位于(也在存储库中)的图像的调用。如果我从主分支打开每个Rmd文件,图像将正确渲染。但是,我尝试使用Travis构建书籍,并使用Github页面将构建的书籍推送到gh pages分支(其中也包含图像文件夹),但图像没有呈现。这本书是我的 要调用Rmd文件中的图像,我使用如下行: ![**Fig. 0** Terminal en RStudio](./docs/non-plain/img/rstudio_terminal.p
Bookdown
构建了一系列Rmd文件。在这些Rmd文件中,有一个对位于(也在存储库中)的图像的调用。如果我从主分支打开每个Rmd文件,图像将正确渲染。但是,我尝试使用Travis
构建书籍,并使用Github页面将构建的书籍推送到gh pages
分支(其中也包含图像文件夹),但图像没有呈现。这本书是我的
要调用Rmd文件中的图像,我使用如下行:
![**Fig. 0** Terminal en RStudio](./docs/non-plain/img/rstudio_terminal.png)
如果我检查内置书中的损坏图像,路径包含我的计算机的本地文件夹,考虑到Rmd文件中的所有路径都是相对的,我并不真正理解。我还尝试使用此方法(在R代码块中)调用图像,但也不起作用:
knitr::include_graphics(“/docs/non-plain/img/config_git.png”)
我正在使用一个取自Bookdown手册的.travis.yml
,它调用\u build.sh
和\u deploy.sh
脚本
.travis.yml
language: r
cache: packages
pandoc_version: 1.19.2.1
before_script:
- chmod +x ./_build.sh
- chmod +x ./_deploy.sh
script:
- ./_build.sh
- ./_deploy.sh
\u build.sh
#!/bin/sh
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
#!/bin/sh
set -e
[ -z "${GITHUB_PAT}" ] && exit 0
[ "${TRAVIS_BRANCH}" != "master" ] && exit 0
git config --global user.email "email.com"
git config --global user.name "username"
git clone -b gh-pages https://${GITHUB_PAT}@github.com/${TRAVIS_REPO_SLUG}.git book-output
cd book-output
cp -r ../_book/* ./
git add --all *
git commit -m"Update the book" || true
git push -q origin gh-pages
\u deploy.sh
#!/bin/sh
Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::gitbook')"
#!/bin/sh
set -e
[ -z "${GITHUB_PAT}" ] && exit 0
[ "${TRAVIS_BRANCH}" != "master" ] && exit 0
git config --global user.email "email.com"
git config --global user.name "username"
git clone -b gh-pages https://${GITHUB_PAT}@github.com/${TRAVIS_REPO_SLUG}.git book-output
cd book-output
cp -r ../_book/* ./
git add --all *
git commit -m"Update the book" || true
git push -q origin gh-pages
我无法理解我做错了什么,以及为什么图像不能正确渲染。非常感谢您的帮助。一个解决方法是使用github上图像的url作为路径
我在使用
bookdown::render_book()
时遇到了类似的问题,我认为这是因为图像路径与chapter.Rmd文件相对,后者位于与index.Rmd不同的文件夹中。在本例中:https://raw.githubusercontent.com/nik0lai/learn2git/master/docs/non-plain/img/rstudio_terminal.png