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

math should escape and ignore any other formatting #53

Closed
1 task done
TheWiseMan opened this issue Feb 15, 2024 · 4 comments · Fixed by #60
Closed
1 task done

math should escape and ignore any other formatting #53

TheWiseMan opened this issue Feb 15, 2024 · 4 comments · Fixed by #60
Assignees
Labels
Bug Something isn't working

Comments

@TheWiseMan
Copy link

TheWiseMan commented Feb 15, 2024

Describe the bug

When using inline formatting caracters (*,_,^) in math, the text is put formatted, thus breaking the math formula

Expected Behavior

The math should be left untouched just like a code block

Relevant log output

No response

Environment

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TheWiseMan TheWiseMan added the Bug Something isn't working label Feb 15, 2024
@TheWiseMan TheWiseMan changed the title Superscript seems to precede math escaping math should escape and ignore any other formatting Feb 15, 2024
@BenjaminHoegh
Copy link
Owner

BenjaminHoegh commented Feb 15, 2024

Do you have a example I can use for testing?

Also did you remember to enable math notations using $ParsedownExtended->setSetting('math', true)

@TheWiseMan
Copy link
Author

it breaks for exemple with $sqrt(45)*x*4/3$ as inline math.

I'm enabling the math as follows :

    $Parser->setSetting('math', [
        'inline' => [
            'delimiters' => [
                //['left' => '\\(', 'right' => '\\)'],
                ['left' => '$', 'right' => '$'],
            ],
        ],
        'block' => [
            'delimiters' => [
                ['left' => '$$', 'right' => '$$'],
                ['left' => '\\begin{equation}', 'right' => '\\end{equation}'],
                ['left' => '\\begin{align}', 'right' => '\\end{align}'],
                ['left' => '\\begin{alignat}', 'right' => '\\end{alignat}'],
                ['left' => '\\begin{gather}', 'right' => '\\end{gather}'],
                ['left' => '\\begin{CD}', 'right' => '\\end{CD}'],
                ['left' => '\\[', 'right' => '\\]'],
            ],
        ],
    ]);

@BenjaminHoegh
Copy link
Owner

Seems the automatic enable dosn't work as it should, for now you can add the enabled key at the root of that array and set it to true

@BenjaminHoegh BenjaminHoegh added Investigation Issues that require further investigation Verified A issue there has been confirmed by the devs labels Feb 19, 2024
@TheWiseMan
Copy link
Author

only adding it to the root gives me Setting 'math.block' is not a boolean. , however, the following seems to work :

$Parser->setSetting('math', [
        'inline' => [
            'delimiters' => [
                //['left' => '\\(', 'right' => '\\)'],
                ['left' => '$', 'right' => '$'],
            ],
            "enabled" => true
        ],
        'block' => [
            'delimiters' => [
                ['left' => '$$', 'right' => '$$'],
                ['left' => '\\begin{equation}', 'right' => '\\end{equation}'],
                ['left' => '\\begin{align}', 'right' => '\\end{align}'],
                ['left' => '\\begin{alignat}', 'right' => '\\end{alignat}'],
                ['left' => '\\begin{gather}', 'right' => '\\end{gather}'],
                ['left' => '\\begin{CD}', 'right' => '\\end{CD}'],
                ['left' => '\\[', 'right' => '\\]'],
            ],
            "enabled" => true
        ],
        "enabled" => true
    ]);

BenjaminHoegh added a commit that referenced this issue Feb 22, 2024
BenjaminHoegh added a commit that referenced this issue Feb 22, 2024
…gnore-any-other-formatting

Fixed a issue where setSetting and isEnabled didn't handle arrays correct #53
@BenjaminHoegh BenjaminHoegh removed Investigation Issues that require further investigation Verified A issue there has been confirmed by the devs labels Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
2 participants