使用Rails资产管道加载Katex字体 [英] Getting Katex fonts to load with Rails Asset Pipeline

查看:345
本文介绍了使用Rails资产管道加载Katex字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将 Katex 数学公式渲染库集成到Rails 3.2应用程序,但字体资产不断返回404错误消息:
$ b

服务资产/fonts/KaTeX_Math-Italic.woff - 404未找到(3ms)

ActionController :: RoutingError(没有路由匹配[GET] /assets/fonts/KaTeX_Math-Italic.woff):

我将所有的字体放入 vendor / assets / fonts 目录。

如果不操作第三方的JS或CSS文件,我该怎么去关于解决这个问题?

解决方案

事实证明,所有的资产都被编译到 public / assets 目录而不是像 public / assets / fonts 那样分开,这就是Katex期待的。



然而,subdirect这些main目录的目录被保留,所以我把Katex字体移动到了下面的目录中:

  vendor / assets / fonts / fonts / 

现在 public / assets 目录包含字体目录和路径 /assets/fonts/KaTeX_Math-Italic.woff 获得服务就好了。

我不喜欢有一个字体/字体目录,所以让我知道如果有一个更优雅的方式来解决这个问题,不涉及操纵第三方JS或CSS资产。


I'm integrating the Katex math formula rendering library into a Rails 3.2 app but the font assets keep returning a 404 error message:

Started GET "/assets/fonts/KaTeX_Math-Italic.woff"
Served asset /fonts/KaTeX_Math-Italic.woff - 404 Not Found (3ms)

ActionController::RoutingError (No route matches [GET] "/assets/fonts/KaTeX_Math-Italic.woff"):

I placed all of the fonts in the vendor/assets/fonts directory.

Without manipulating the third party JS or CSS files, how do I go about solving this?

解决方案

It turns out that all of the assets are compiled into the public/assets directory instead of being separated like public/assets/fonts, which is what Katex is expecting.

However, subdirectories of these "main" directories are retained so I moved the Katex fonts to the following directory instead:

vendor/assets/fonts/fonts/

Now the public/assets directory contains a fonts directory and the path /assets/fonts/KaTeX_Math-Italic.woff gets served just fine.

I don't like having a fonts/fonts directory so let me know if there's a more elegant way to solve this that doesn't involve manipulating the third party JS or CSS assets.

这篇关于使用Rails资产管道加载Katex字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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