gpt4 book ai didi

javascript - CK编辑器4,谷歌翻译也翻译我的MATHJAX公式,即使没有翻译

转载 作者:行者123 更新时间:2023-12-02 02:45:44 24 4
gpt4 key购买 nike

大家好,我这里有一个大问题,很长时间没有得到解决。

我正在使用 ck 编辑器和 Mathjax 插件来添加数学公式,如下所示

<script src="https://cdn.ckeditor.com/4.13.1/standard-all/ckeditor.js"></script>

<textarea name="desc" class="form-control" id="richtext" placeholder="About this category."></textarea>

<script>

var richtext = document.getElementById('richtext');
CKEDITOR.replace('richtext', {
on : {
change: function ( evt ) {
$(richtext).html(evt.editor.getData().replace(/(\r\n|\n|\r)/gm,"") ) ;
}
},
extraPlugins: 'mathjax,colorbutton,font,justify,print,tableresize,uploadimage,uploadfile,pastefromword,liststyle,pagebreak',
mathJaxLib: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-AMS_HTML',
height: 320
});

if (CKEDITOR.env.ie && CKEDITOR.env.version == 8) {
document.getElementById('ie8-warning').className = 'tip alert';
}
</script>

到这里为止一切都很顺利。

现在,当我发布数据并使用谷歌翻译将数据从英语翻译成印地语时,如下所示

require_once ('assets/vendor/autoload.php');
use \Statickidz\GoogleTranslate;
$source = 'en';
$target = 'hi';
$text = "<p>This is a test question. please do not translate this <span class="math-tex">\(x = {-b \pm \sqrt{b^2-4ac} \over 2a}\)</span>equation.</p>";
// i know there is an issue of double quotes in the class math-tex, but this is what i get from ckeditor. even if i replace the double quotes with single it does not does the job.

$tex4444t=str_replace(array("\r\n", "\r", "\n"), " ", $text);
$trans232 = new GoogleTranslate();
$results3 = $trans232->translate($source, $target, $tex4444t);

i know there is an issue of double quotes in the class math-tex, but this is what i get from ckeditor. even if i replace the double quotes with single it does not does the job. i have also tried using notranslate class with math-tex it still does not work.

我尝试了很多其他替代方案,但没有一个有效,请帮我解决这个问题。

最佳答案

这已出现在 MathJax issue tracker 中。看来php google translate似乎无法处理 notranslate 类。您可以向他们提交错误。

与此同时,数学“翻译”后的主要问题是反斜杠后面有多余的空格。因此,也许只需进行正则表达式替换,将反斜杠后跟空格转换为反斜杠即可?

还有another option MathJax 问题跟踪器中建议的方法更复杂,但可能是最安全的方法。

关于javascript - CK编辑器4,谷歌翻译也翻译我的MATHJAX公式,即使没有翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60221267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com