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

👌 IMPROVE: Store rawtext in AST nodes (for gettext) #301

Merged
merged 6 commits into from
Feb 8, 2021
Merged

👌 IMPROVE: Store rawtext in AST nodes (for gettext) #301

merged 6 commits into from
Feb 8, 2021

Conversation

jpmckinney
Copy link
Contributor

If you have Markdown like:

* My **Awesome** markdown

Sphinx needs to be passed My **Awesome** markdown.

The code does not do that.

This is the same bug as in recommonmark: readthedocs/recommonmark#187 which had originally been fixed by a Sphinx maintainer, and which I more recently fixed (though recommonmark is very behind on merging PRs).

As you can see in the code for paragraphs, sometimes the original Markdown content is not where you expect it. So far, I've only tested a few tokens.

cc @choldgraf

@codecov
Copy link

codecov bot commented Feb 5, 2021

Codecov Report

Merging #301 (2875f5e) into master (86df2ea) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
+ Coverage   90.60%   90.65%   +0.05%     
==========================================
  Files          14       14              
  Lines        1809     1809              
==========================================
+ Hits         1639     1640       +1     
+ Misses        170      169       -1     
Flag Coverage Δ
pytests 90.65% <100.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
myst_parser/docutils_renderer.py 91.85% <100.00%> (ø)
myst_parser/html_to_nodes.py 91.66% <0.00%> (+2.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86df2ea...0112d62. Read the comment docs.

@jpmckinney
Copy link
Contributor Author

jpmckinney commented Feb 5, 2021

Actually, the problem is lower-level. I'll open an issue.

@jpmckinney
Copy link
Contributor Author

Sorry, nevermind - this branch actually does address #304 (at least for the node types I tested).

@chrisjsewell
Copy link
Member

Sorry, nevermind

lol yeh I was just going to say it does capture the "bold" syntax etc.

you can use https://markdown-it.github.io/ (and the debug tab) to see what gets stored where in the tokens

myst_parser/docutils_renderer.py Outdated Show resolved Hide resolved
@chrisjsewell
Copy link
Member

Is there any other additions you want to make before merging?

@chrisjsewell
Copy link
Member

chrisjsewell commented Feb 6, 2021

I see you removed all the changes for list items, etc. Was that intended?

@chrisjsewell chrisjsewell linked an issue Feb 6, 2021 that may be closed by this pull request
@jpmckinney
Copy link
Contributor Author

jpmckinney commented Feb 6, 2021

@chrisjsewell I added a bunch more test cases in https://github.com/jpmckinney/myst-parser-tests and they all extract correctly now with only the changes to these two lines. I can still add a table test case, and maybe some other block-level elements I missed. I don't really know how to test this without looking in Sphinx's code to see what it does when the gettext builder is run.

@jpmckinney
Copy link
Contributor Author

I've now added a table test case, and it extracts incorrectly, so I'll add another commit.

@jpmckinney
Copy link
Contributor Author

The new commit fixes terms (dt) and table cells.

@chrisjsewell
Copy link
Member

I think we should add a test for this, to https://github.com/executablebooks/MyST-Parser/tree/master/tests/test_sphinx/sourcedirs:

@chrisjsewell
Copy link
Member

thats great thanks

@chrisjsewell chrisjsewell changed the title Sphinx performs translation at block-level, not inline-level 👌 IMPROVE: Store rawtext in AST nodes (for gettext) Feb 8, 2021
@chrisjsewell chrisjsewell merged commit c868b3a into executablebooks:master Feb 8, 2021
@jpmckinney jpmckinney deleted the i18n branch February 8, 2021 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sphinx extracts Markdown without inline markup
2 participants