content转成latex update
This commit is contained in:
@@ -2041,17 +2041,14 @@ class Production extends Base
|
|||||||
//生成tex文件
|
//生成tex文件
|
||||||
$article_main_list = $this->article_main_obj->where("article_id",$data['article_id'])->where("state",0)->order("sort asc")->select();
|
$article_main_list = $this->article_main_obj->where("article_id",$data['article_id'])->where("state",0)->order("sort asc")->select();
|
||||||
$fragContentList = [];
|
$fragContentList = [];
|
||||||
$refArray = [];
|
|
||||||
foreach ($references as $ref) {
|
|
||||||
$refArray[$ref['index'] + 1] = $ref;
|
|
||||||
}
|
|
||||||
foreach ($article_main_list as $article_main_info){
|
foreach ($article_main_list as $article_main_info){
|
||||||
if($article_main_info['type']!=0){
|
if($article_main_info['type']!=0){
|
||||||
$fragContentList[] = $article_main_info;
|
$fragContentList[] = $article_main_info;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//替换其他标签
|
//替换其他标签
|
||||||
$updatedContent = $this->convertToLatex($article_main_info['content'],$refArray);
|
$updatedContent = $this->convertToLatex($article_main_info['content'],$references);
|
||||||
//做内容替换
|
//做内容替换
|
||||||
$article_main_info['content'] = $updatedContent;
|
$article_main_info['content'] = $updatedContent;
|
||||||
$fragContentList[] = $article_main_info;
|
$fragContentList[] = $article_main_info;
|
||||||
@@ -2078,40 +2075,17 @@ class Production extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function mytestconvertToLatex(){
|
|
||||||
$data = $this->request->post();
|
|
||||||
$rule = new Validate([
|
|
||||||
"article_id"=>"require",
|
|
||||||
"content"=>"require"
|
|
||||||
]);
|
|
||||||
if(!$rule->check($data)){
|
|
||||||
return jsonError($rule->getError());
|
|
||||||
}
|
|
||||||
$article_production_info = $this->production_article_obj->where("article_id",$data['article_id'])->find();
|
|
||||||
$references = $this->production_article_refer_obj
|
|
||||||
->where('p_article_id', $article_production_info['p_article_id'])
|
|
||||||
->where('state', 0)
|
|
||||||
->order('index ASC')
|
|
||||||
->select();
|
|
||||||
|
|
||||||
|
public function convertToLatex($content,$references) {
|
||||||
$refArray = [];
|
|
||||||
foreach ($references as $ref) {
|
|
||||||
$refArray[$ref['index'] + 1] = $ref;
|
|
||||||
}
|
|
||||||
$res = $this->convertToLatex($data['content'],$refArray);
|
|
||||||
echo $res;
|
|
||||||
// return jsonSuccess(["content"=>$res]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function convertToLatex($content,$refArray) {
|
|
||||||
// 空内容直接返回
|
// 空内容直接返回
|
||||||
if (empty(trim($content))) {
|
if (empty(trim($content))) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
$refArray = [];
|
||||||
|
foreach ($references as $ref) {
|
||||||
|
$refArray[$ref['index'] + 1] = $ref;
|
||||||
|
}
|
||||||
|
|
||||||
$content = str_replace("–","-",$content);
|
$content = str_replace("–","-",$content);
|
||||||
|
|
||||||
$content = $this->convertReferencesToLatex($content, $refArray);
|
$content = $this->convertReferencesToLatex($content, $refArray);
|
||||||
|
|||||||
Reference in New Issue
Block a user