如果 URL 包含特殊字符,则 Bookdown 文本引用不起作用 [英] Bookdown text references not working if URL contains special characters

查看:48
本文介绍了如果 URL 包含特殊字符,则 Bookdown 文本引用不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

bookdown 中的文本引用存在一些不一致的行为,其中 URL 包含特殊字符,例如 :_.以下是一些演示:

There is some inconsistent behaviour of text references in bookdown with URLs containing special characters such as : or _. Here are some demonstrations:

---
output: bookdown::pdf_book
---

(ref:good) [This Works](https://commons.wikimedia.org/wiki)

(ref:good)


(ref:bad) [This Does Not](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg)

(ref:bad)


The link will work normally [like here](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg)

如果文本引用包含特殊字符,有没有办法让它们起作用?

Is there a way to get text references to work if they contain special characters?

此问题在此处,但这些符号并未直接确定为问题中的关键问题.在将其作为潜在问题在 GitHub 上提出之前,我想在 SO 上创建一个重点线程.

This behaviour was flagged in this question here, but the symbols were not directly identified as the key issues within the question. I wanted to make a focussed thread on SO before raising it as a potential issue on GitHub.

推荐答案

问题不是特殊字符引起的,而是链接太长,所以 LaTeX 中的行默认被 Pandoc 换行:

The problem was not caused by special characters but the fact that the link was too long, so the line in LaTeX was wrapped by Pandoc by default:

(ref:bad)
\href{https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg}{This Does Not}

应该被认为是bookdown的一个bug,但是有一个解决方法:

It should be considered as a bug of bookdown, but there is a workaround:

output:
  bookdown::pdf_book:
    pandoc_args: [--wrap=none]

这篇关于如果 URL 包含特殊字符,则 Bookdown 文本引用不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆