Skip to content

Conversation

@hukkin
Copy link
Contributor

@hukkin hukkin commented Dec 19, 2020

No description provided.

@codecov
Copy link

codecov bot commented Dec 19, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.50%. Comparing base (00a28a6) to head (1c27822).
Report is 120 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@ ## master #102 +/- ## ========================================== + Coverage 96.38% 96.50% +0.12%  ========================================== Files 72 72 Lines 3205 3202 -3 ========================================== + Hits 3089 3090 +1  + Misses 116 112 -4 
Flag Coverage Δ
pytests 96.50% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hukkin
Copy link
Contributor Author

hukkin commented Dec 19, 2020

These changes do not break compatibility with mdit-py-plugins, but tests will need to be updated there.

@hukkin
Copy link
Contributor Author

hukkin commented Dec 19, 2020

executablebooks/mdit-py-plugins#6 will fix mdit-py-plugins tests if this is merged.

if i < 0:
tmpAttrs.append(["class", options.langPrefix + langName])
else:
tmpAttrs[i][1] += " " + options.langPrefix + langName
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line actually seems to have a bug that we're fixing by using the immutable tuple 😄 Mutating tmpAttrs[i] here will also mutate token.attrs[i] because tmpAttrs is a copy, not a deep copy, of token.attrs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the fix in JS markdown-it markdown-it/markdown-it@c9949dd

If we don't end up merging this PR, we should do the same change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is now in merged in master of markdown-it-py btw

@hukkin
Copy link
Contributor Author

hukkin commented Jan 13, 2021

In fact, if we want to make Token.attrs even better, we could use a Dict[str, Any] as the underlying structure. Why markdown-it doesn't use an object is exlained here markdown-it/markdown-it#142 (comment) :

Because ordering makes sence for testing, and no needs to care about hacks like "proto" name and so on.

A Python 3.6 OrderedDict or Python 3.7+ dict doesn't suffer from any of the issues why the custom list structure was used for a mapping. Using a dict would likely result in a small performance increase.

@chrisjsewell
Copy link
Member

Superseded by #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants