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

Some codes of cpp cannot be rendered #3437

Closed
Vanessa219 opened this issue Dec 29, 2021 · 2 comments · Fixed by #3438
Closed

Some codes of cpp cannot be rendered #3437

Vanessa219 opened this issue Dec 29, 2021 · 2 comments · Fixed by #3438
Labels
bug help welcome Could use help from community language

Comments

@Vanessa219
Copy link

Describe the issue
Some code of cpp can not be rendered.

Which language seems to have the issue?
cpp

Are you using highlight or highlightAuto?

highlight

...

Sample Code to Reproduce

image

#include <iostream>
#include <Eigen/Core>
int main(int argc, char** argv)
{
    //1.方阵
    Eigen::Matrix3f  A;   //本质是Eigen::Matrix<float,3,3> A;  
    A << 1,2,3,4,5,6,7,8,9;
    std::cout << "A= \n" << A << std::endl;

    //2. 转置操作
    Eigen::Matrix3f  A_T =  A.transpose();
    std::cout << "\nA的转置矩阵A_T= \n" << A_T << std::endl;

    //3. 零矩阵
    Eigen::Matrix<float,3,5> B = Eigen::Matrix<float,3,5>::Zero();
    std::cout << "\nB= \n" << B << std::endl;

    //4. 对角矩阵
    //4.1 构造对角矩阵
    Eigen::VectorXd vector(5);                //构建5维向量
    vector<<1,2,3,4,5;                        //向量赋值
    Eigen::MatrixXd  C(vector.asDiagonal());  //使用向量生成对角阵
    std::cout << "\nC= \n" << C << std::endl;

    //4.2 从普通矩阵中提取对角元素组成向量 
    std::cout << "\n从C中提取对角元素构成向量= \n" << C.diagonal() << std::endl;    //C也可以不是方阵

    //5. 单位矩阵
    //5.1 构造单位矩阵
    Eigen::Matrix3f D = Eigen::Matrix3f::Identity();                    //简写
    Eigen::Matrix<float,4,4> E = Eigen::Matrix<float,4,4>::Identity();  //完整写法
    std::cout << "\n单位矩阵D= \n" << D << std::endl;
    std::cout << "\n单位矩阵E= \n" << E << std::endl;

    //5.2 构造对角线为1的普通矩阵
    Eigen::Matrix<float,3,5> F = Eigen::Matrix<float,3,5>::Identity();
    std::cout << "\n普通对角元素为1的矩阵F= \n" << F << std::endl;

    return 0;
}

Expected behavior

image

Additional context
Code:

element.innerHTML = hljs.highlight(code, {
                language: "cpp",
                ignoreIllegals: true
            }).value;
@Vanessa219 Vanessa219 added bug help welcome Could use help from community language labels Dec 29, 2021
@joshgoebel joshgoebel mentioned this issue Dec 29, 2021
2 tasks
@joshgoebel
Copy link
Member

@Vanessa219 Could you test or review PR fix?

@Vanessa219
Copy link
Author

It works, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants