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

Arithmatex hang/slow render #888

Closed
heartbleeded opened this issue Apr 11, 2020 · 2 comments · Fixed by #889
Closed

Arithmatex hang/slow render #888

heartbleeded opened this issue Apr 11, 2020 · 2 comments · Fixed by #889
Labels
S: confirmed Confirmed bug report or approved feature request. T: bug Bug.

Comments

@heartbleeded
Copy link

Hi,

I'm facing one Latex block which is slowly render by Arithmatex. It takes ~ 10 minutes to render.

Latex block:

text='''
$z^{[1]} = \begin{bmatrix}w^{[1]T}_1 \\ w^{[1]T}_2 \\ w^{[1]T}_3 \\ w^{[1]T}_4 \end{bmatrix} \begin{bmatrix}x_1 \\ x_2 \\ x_3 \end{bmatrix} + \begin{bmatrix}b^{[1]}_1 \\ b^{[1]}_2 \\ b^{[1]}_3 \\ b^{[1]}_4 \end{bmatrix}= \begin{bmatrix}w^{[1]T}_1 x + b^{[1]}_1 \\ w^{[1]T}_2 x + b^{[1]}_2\\ w^{[1]T}_3 x + b^{[1]}_3 \\ w^{[1]T}_4 x + b^{[1]}_4 \end{bmatrix} $
'''
html = markdown.markdown(text, extensions=['pymdownx.arithmatex'])

When Break pressed, it throws this backtrace:

 File "./markdown/core.py", line 388, in markdown
    return md.convert(text)
  File "./markdown/core.py", line 269, in convert
    newRoot = treeprocessor.run(root)
  File "./markdown/treeprocessors.py", line 370, in run
    self.__handleInline(text), child
  File "./markdown/treeprocessors.py", line 131, in __handleInline
    self.inlinePatterns[patternIndex], data, patternIndex, startIndex
  File "./markdown/treeprocessors.py", line 270, in __applyPattern
    for match in pattern.getCompiledRegExp().finditer(data, startIndex):
@gir-bot gir-bot added the S: triage Issue needs triage. label Apr 11, 2020
@facelessuser
Copy link
Owner

The example given will not match proper (this is a note outside of the reported slowness):

  1. In your example, you should probably be using a raw string test=r'''.
  2. Also, Arithmatex also, when run in the default configuration you are using, should have the closing $ with no spaces before it. This is the "smart" configuration that aims to avoid $ when not using in a LaTeX manner.

Changing those two things fixes the hang.


As for the slowness, this appears to be the case when the pattern does not match, and I'm not yet sure why. I believe can do things in a much more efficient way, so I'll look into this.

@gir-bot remove S: triage
@gir-bot add T: bug, S: confirmed

@gir-bot gir-bot added S: confirmed Confirmed bug report or approved feature request. T: bug Bug. and removed S: triage Issue needs triage. labels Apr 11, 2020
@facelessuser
Copy link
Owner

Looks like our issue is due to a regular expression typo: [^\$] should have been [^\\$].

facelessuser added a commit that referenced this issue Apr 11, 2020
facelessuser added a commit that referenced this issue Apr 11, 2020
* Improve arithmatex patterns

Fixes #888

* Fix spelling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: confirmed Confirmed bug report or approved feature request. T: bug Bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants