Sublime Forum

Is it possible to upgrade the markdown library available to ST packages?

#1

Hi all.

I’ve written a ST package to (amongst other things) convert MD to HTML and then perform a series of manipulations against the resulting HTML.

Recently, the MD to HTML component has been generating unexpected and malformed output. When I invoke print(markdown.__version__) from within the package, it shows an 4 y/o version of the Markdown library.

It reports 3.2.2 (May 2020), whereas the most recent version is 3.7 (Nov 2024). Is there any way to upgrade this?

The plugin is configured for Python 3.8 and has the following dependencies.json:

{ "*": { "*": [ "bs4","soupsieve","Markdown","pymdownx"] } }
1 Like

#2

No that’s not possible as more recent versions are not compatible with embedded python 3.8.

It fails due to stdlib being provided by ST in zipped form.

That’s a python 3.8 bug, which has been fixed in 3.10.

0 Likes

#3

Hi deathaxe. Bugger, that’s a shame. Thanks for the confirmation though. I will have to look for workarounds.

The problem I am having is an odd one, and has only started occurring recently. I am not sure what has triggered it.

If I have a simple markdown file with at least two paragraphs, the resulting HTML is well formed, ie:

This is my first para.

This is my second para.

* bullet points
* more bullet points.

results in:

<p>This is my first para.</p>
<p>This is my second para.</p>
<ul>
    <li>bullet points</li>
    <li>more bullet points.</li>
</ul>

If I only have one para, the output is malformed and the HTML corrupted, ie:

This is a single para.

* bullet points
* more bullet points.

results in:

This is a single para. < ul > <li>bullet points</li> < li > more bullet points. < /li></ul >

Wierd, huh?

0 Likes

#4

As markdown hasn’t meen updated for ages there must be other reasons.

Mdpopups, which uses markdown to convert md to html creates perfectly fine output for your example.

>>> mdpopups.md2html(view, """This is my first para.

* bullet points
* more bullet points.""")
'<p>This is my first para.</p>\n<ul>\n<li>bullet points</li>\n<li>more bullet points.</li>\n</ul>'
0 Likes

#5

Hi deathaxe. Thanks for following up. I tend to agree - after tracking this back, I am no longer convinced that the markdown library is the root cause. I also use BS4 to prettyprint the HTML output - it may be the cause. I will keep investigating.

Thanks for all your time on this.

1 Like