使用Rails资产管道加载Katex字体 [英] Getting Katex fonts to load with Rails Asset Pipeline
问题描述
我将 Katex 数学公式渲染库集成到Rails 3.2应用程序,但字体资产不断返回404错误消息:
$ b
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屋!