Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在markdown中插入数学公式 #16

Open
zhouhaibing089 opened this issue Nov 1, 2016 · 2 comments
Open

在markdown中插入数学公式 #16

zhouhaibing089 opened this issue Nov 1, 2016 · 2 comments
Labels

Comments

@zhouhaibing089
Copy link
Owner

zhouhaibing089 commented Nov 1, 2016

目的

有些时候我们想在自己的文章中插入一些数学公式, 比如

f(x)=x^2

前提

我们唯一需要知道的就是怎么用TeX语法来写数学公式.

操作

准备你要写的数学公式

f(x)=x^2

获取resource location

$ curl -X POST \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --header 'Accept: application/json' \
    --data-urlencode 'q=f(x)=x^2' \
    -i -s https://wikimedia.org/api/rest_v1/media/math/check/tex \
    | grep x-resource-location | awk '{print $2}'
611e35cb6f8d4fd5ce4b43c16363a9f5b7e65464

获取link

![f(x)=x^2](https://wikimedia.org/api/rest_v1/media/math/render/svg/611e35cb6f8d4fd5ce4b43c16363a9f5b7e65464)

f(x)=x^2

总结

我们可以写下面这个脚本来一步实现.

#! /bin/bash

res=$(curl -X POST \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --header 'Accept: application/json' \
  --data-urlencode "q=$1" \
  -i -s \
  https://wikimedia.org/api/rest_v1/media/math/check/tex | grep x-resource-location | awk '{print $2}')
echo "https://wikimedia.org/api/rest_v1/media/math/render/svg/${res}"

参考

@jizusun
Copy link

jizusun commented Nov 6, 2016

真6!然而放在wikipedia不会被删吧?

@zhouhaibing089
Copy link
Owner Author

@SmilingSun 应该不会的, 毕竟wikipedia也是这么用的..

@zhouhaibing089 zhouhaibing089 added blog and removed blog labels Dec 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants