timonwong / OmniMarkupPreviewer

Sublime Text 2&3 plugin to live preview markup files, supported (not limited to) markup formats are markdown, reStructuredText, WikiCreole and textile.
MIT License
502 stars 75 forks source link

No module named 'mathjax' #139

Open LuoDongK opened 4 years ago

LuoDongK commented 4 years ago

Everytime I reopen my file, there will be a '404' error when I tried to preview current markup in browser. I have to set "mathjax_enabled" to false and preview current markup in browser again. Then reset "mathjax_enabled" to true and the previewer will work properly.But no matter what, the following error will continuely come up: OmniMarkupPreviewer: [INFO] Launching web browser for http://127.0.0.1:51004/view/229 OmniMarkupPreviewer: [ERROR] Exception occured while rendering using MarkdownRenderer Traceback (most recent call last): File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/OmniMarkupPreviewer/OmniMarkupLib/RendererManager.py", line 266, in render_text rendered_text = renderer.render(text, filename=filename) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/OmniMarkupPreviewer/OmniMarkupLib/Renderers/MarkdownRenderer.py", line 48, in render extensions=self.extensions) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 390, in markdown md = Markdown(**kwargs) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 100, in init configs=kwargs.get('extension_configs', {})) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 126, in registerExtensions ext = self.build_extension(ext, configs.get(ext, {})) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 166, in build_extension module = importlib.import_module(ext_name) File "./python3.3/importlib/init.py", line 90, in import_module File "", line 1584, in _gcd_import File "", line 1565, in _find_and_load File "", line 1529, in _find_and_load_unlocked ImportError: No module named 'mathjax'

JianhuiShi commented 4 years ago

Same problem to me.

HQ-CS commented 3 years ago

Same problem

kprojiang commented 3 years ago

Same problem

Same problem to me.

Everytime I reopen my file, there will be a '404' error when I tried to preview current markup in browser. I have to set "mathjax_enabled" to false and preview current markup in browser again. Then reset "mathjax_enabled" to true and the previewer will work properly.But no matter what, the following error will continuely come up: OmniMarkupPreviewer: [INFO] Launching web browser for http://127.0.0.1:51004/view/229 OmniMarkupPreviewer: [ERROR] Exception occured while rendering using MarkdownRenderer Traceback (most recent call last): File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/OmniMarkupPreviewer/OmniMarkupLib/RendererManager.py", line 266, in render_text rendered_text = renderer.render(text, filename=filename) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/OmniMarkupPreviewer/OmniMarkupLib/Renderers/MarkdownRenderer.py", line 48, in render extensions=self.extensions) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 390, in markdown md = Markdown(kwargs) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 100, in init configs=kwargs.get('extension_configs', {})) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 126, in registerExtensions ext = self.build_extension(ext, configs.get(ext, {})) File "/Users/iloveuso/Library/Application Support/Sublime Text 3/Packages/python-markdown/st3/markdown/core.py", line 166, in build_extension module = importlib.import_module(ext_name) File "./python3.3/importlib/init**.py", line 90, in import_module File "", line 1584, in _gcd_import File "", line 1565, in _find_and_load File "", line 1529, in _find_and_load_unlocked ImportError: No module named 'mathjax'

I have just figured out how this bug happens and feel thrilled to fix it.

  1. OmniMarkupPreviewer.sublime-settings

    {
        "server_port": 51006,
        "mathjax_enabled": true,
        "renderer_options-MarkdownRenderer": {
            "extensions": ["markdown.extensions.tables",
                "markdown.extensions.attr_list",
                "markdown.extensions.codehilite",
                "markdown.extensions.fenced_code",
                "markdown.extensions.footnotes",
                "markdown.extensions.toc",
                "markdown.extensions.mdx_mathjax",
            ]
        }
    }
  2. copy mdx_mathjax.py under folder "Packages/python-markdown/st3/markdown/extensions"

  3. modify the makeExtension function in mdx_mathjax.py to be

    def makeExtension(**kwargs):
        return MathJaxExtension(**kwargs)
  4. modify the MarkdownRenderer.py under Packages/OmniMarkupPreviewer/OmniMarkupLib/Renderers to comment out

    # if global_setting.mathjax_enabled:
    #     if 'mathjax' not in extensions:
    #         extensions.add('markdown.extensions.mdx_mathjax')

    lines 20~22

kprojiang commented 3 years ago

:stuck_out_tongue: :star: :star2: :thumbsup: :ok_hand: :tada: