Forgot password?
 Create new account
Author: abababa

tikzjax 能脱离服务器用吗?

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-10-2 19:10:40
回复 26# abababa

将最后那个 plot 后面改成 (\x,{(\x)^2/2/0.5}) 即可。(当然这是 tikz 逗……

GGbra 的导出也不咋嘀,像 rotate around={0:(0,0)},xshift=0cm,yshift=0cm 这些明显多余,而应该加的 smooth 却不加。

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-10-2 19:16:30
回复 21# hbghlyj
比如这样
  1. jQuery(document).ready(function(){for(let i=0;i<jQuery("script[type='text/tikz']").length;i++){jQuery("script[type='text/tikz']")[i].innerHTML=jQuery("script[type='text/tikz']")[i].innerHTML.replaceAll("&gt;",">").replaceAll("&lt;","<")}});
Copy the Code

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-10-3 09:36:48
回复 27# kuing

果然如此,那还是不用其它软件导出,直接写tikz代码方便。要是这个能用tkz-euclide就更好了,画平面几何图简单,好像也能自定义命令吧,像那个网页版的katex一样,自定义出那些命令就应该都能用了。

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-10-4 17:21:08
这个如果把
  1. var scripts = document.getElementsByTagName('script');
  2.   var tikzScripts = Array.prototype.slice.call(scripts).filter(e => e.getAttribute('type') === 'text/tikz');
Copy the Code
这两行的第一行,改成
  1. var scripts = document.getElementsByTagName('tikz');
Copy the Code
然后在index.html页面里,就不用写<script>这样的脚本了,而是写
  1. <tikz type="text/tikz">
  2.   \begin{tikzpicture}
  3.     \draw (0,0) circle (1in);
  4.   \end{tikzpicture}
  5. </tikz>
Copy the Code
标签变成tikz了,这样就属于安全的了吧,因为听说script可能不安全。
$type tikzjax1.js (953.26 KB, Downloads: 233) $type index.html (707 Bytes, Downloads: 170)

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-11-15 05:28:43
<script src="//i.upmath.me/latex.js"></script>
i.upmath.me/g/

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-15 14:26:40
回复 32# hbghlyj

怎么玩?直接粘贴链接吗?

  1. [img]//i.upmath.me/svg/%5Cbegin%7Btikzpicture%7D%5Bdomain%3D0%3A2%5D%0A%5Cdraw%5Bvery%20thin%5D%20(-0.1%2C-0.1)%20grid%20(2.1%2C2.1)%3B%0A%5Cdraw%5B-%3E%5D%20(-0.2%2C0)--(2.2%2C0)%20node%5Bright%5D%20%7B%24x%24%7D%3B%0A%5Cdraw%5B-%3E%5D%20(0%2C-0.2)--(0%2C2.2)%20node%5Babove%5D%20%7B%24y%24%7D%3B%0A%5Cdraw%20plot%20(%5Cx%2C%7Bsin(%5Cx%20r)%7D)%20node%5Bright%5D%20%7B%24y%3D%5Csin%20x%24%7D%3B%0A%5Cdraw%5Bcolor%3Dblue%5D%20plot%20(%5Cx%2C%5Cx)%20node%5Bright%5D%20%7B%24y%3Dx%24%7D%3B%0A%5Cend%7Btikzpicture%7D[/img]
Copy the Code
好像真的可以

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-15 14:30:28
回复 33# kuing

那是不是可以直接用
  1. [img]//i.upmath.me/svg/代码[/img]
Copy the Code
的形式来插图了?比如
  1. [img]//i.upmath.me/svg/\begin{tikzpicture}\draw(0,0)circle(1);\end{tikzpicture}[/img]
Copy the Code

不行,还是得改一下,\ 要改为 %5C
  1. [img]//i.upmath.me/svg/%5Cbegin{tikzpicture}%5Cdraw(0,0)circle(1);%5Cend{tikzpicture}[/img]
Copy the Code

代码可否换行?
[img]//i.upmath.me/svg/%5Cbegin{tikzpicture}
%5Cdraw(0,0)circle(1);
%5Cend{tikzpicture}[/img]
不行……

不过,万一哪天这个 i.upmath.me 挂了,这些图也全挂,非长久之计……

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-11-15 15:31:22
回复 34# kuing

那这样的话,是不是能新建一个标签,比如叫[tikzimg] [/tikzimg],然后就像草稿本那样,运行一个javascript脚本,把这个标签里的反斜线跟换行符都替换了,这样不就能正确显示了。如果那个网站坏了,那只要把这个替换的脚本删除,不做替换,就恢复成原来的tikz代码了,复制一下就能在自己电脑上直接编译了。

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-15 18:01:39
[img]//i.upmath.me/svg/%5Cbegin{tikzpicture}%5Cdraw[red](0,0)circle(1);%5Cend{tikzpicture}[/img]
中括号影响 BBcode 的识别,这是个大问题……

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-11-15 19:01:13
Last edited by abababa at 2021-11-15 19:07:00回复 36# hbghlyj
哦,原来有这样一个函数可用,谢谢。

回复 37# kuing
那能不能换成标签那种呢?就是尖括号的那种。我做了一个html文档,画的就是之前画的两个图,是用javascript替换的。

$type index2.html (1018 Bytes, Downloads: 149)

或者单独新建一个BBCode标签,比如叫[tikzimg],然后是在帖子里,那么帖子内容应该也有一个html的标签,然后就还是用document.getElementsBy...这样的函数取得帖子的标签,然后再把帖子里的文本做一下替换,就替换[tikzimg]里面那些,不过那个after的函数我就不知道怎么用了,好像只能是对尖括号的标签这样的东西用。

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-11-15 20:09:29
将discuz的BBcode正则表达式
  1. \[b\]([^\[]*)\[\/b\]
Copy the Code
改为
  1. \[b\](.*?)\[\/b\]
Copy the Code
即可在BBcode中使用中括号.

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-11-15 20:11:03
例如
  1. [b]字[字[/b]
Copy the Code
对于第一个无法match
而对于第二个可以match

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-11-15 20:22:30
Last edited by hbghlyj at 2021-12-20 14:49:00这种.*?叫做lazy quantifier或者non-greedy quantifier
developer.mozilla.org/en-US/docs/Web/JavaScri … ressions/Quantifiers
it will stop as soon as it finds a match

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-11-15 20:30:37
回复 41# hbghlyj

这样改了之后,BBCode还能嵌套吗?比如加粗的斜体这种。

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-15 22:05:45
回复 39# hbghlyj

在哪里改?

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-16 00:39:27
回复 45# hbghlyj

你上Q
Q说

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2021-11-16 02:45:00
  1. document.body.innerHTML=document.body.innerHTML.replaceAll('[tikz]','<tikz>').replaceAll('[/tikz]','</tikz>');document.querySelectorAll('tikz').forEach(function(elem){elem.innerHTML='<img src="https://i.upmath.me/svg/'+encodeURI(elem.innerHTML.replaceAll('&gt;','>').replaceAll('&lt;','<'))+'">'})
Copy the Code

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-16 14:27:41
  1. [tikz]\begin{tikzpicture}[line width=2pt]
  2. \draw[red] (0,0) circle (3 and 1);
  3. \node at (0,0) {$a<p>a</p>a$};
  4. \end{tikzpicture}[/tikz]
Copy the Code

对了,这个不能用 \tikz{...},必须用 tikzpicture 环境[小纠结]。
环境前后换行
  1. [tikz]
  2. \begin{tikzpicture}
  3. \draw sin(1,1)cos(2,0)sin(3,-1)cos(4,0);
  4. \end{tikzpicture}
  5. [/tikz]
Copy the Code

\xymatrix 也可以用
  1. [tikz]
  2. \xymatrix{A \ar[r]^f \ar[d]_g & B \ar[d]^{g'} \\
  3. D \ar[r]_{f'} & C}
  4. [/tikz]
Copy the Code

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2021-11-16 16:45:49
回复 49# kuing

整个替换会不会太慢,而且会不会在有些地方有问题?我觉得可以只替换帖子内容部分,就是div class="postmessage"的那个,这个是不是也能做?

701

Threads

110K

Posts

910K

Credits

Credits
94177
QQ

Show all posts

kuing Posted at 2021-11-16 17:00:01
回复 50# abababa

你应该是问 hbghlyj,我不清楚,暂时好像没什么问题

手机版Mobile version|Leisure Math Forum

2025-4-20 22:26 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list