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

ENH: Add option to convert code to code-cell directives in md output #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mmcky
Copy link
Member

@mmcky mmcky commented Jul 2, 2021

This PR adds the option to convert code in rst to code-cell in markdown for use with jupyter-book and enables the direct conversion to executable code-cell directives that are available in myst.

This is enabled using:

--code-to-code-cell

in the cli or

code_to_code_cell: true

in the config.yaml

@welcome
Copy link

welcome bot commented Jul 2, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

@codecov
Copy link

codecov bot commented Jul 2, 2021

Codecov Report

Merging #24 (06c8a75) into main (bb74674) will decrease coverage by 0.04%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   84.33%   84.28%   -0.05%     
==========================================
  Files          10       10              
  Lines        1621     1629       +8     
==========================================
+ Hits         1367     1373       +6     
- Misses        254      256       +2     
Flag Coverage Δ
pytests 84.28% <75.00%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
rst_to_myst/mdformat_render.py 97.24% <ø> (ø)
rst_to_myst/markdownit.py 91.41% <66.66%> (-0.39%) ⬇️
rst_to_myst/cli.py 84.02% <100.00%> (+0.16%) ⬆️

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 bb74674...06c8a75. Read the comment docs.

token_type = "fence"
directive_name = "code"
if self.code_to_code_cell:
token_type = "directive"
Copy link
Member Author

Choose a reason for hiding this comment

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

@chrisjsewell I can't find the documentation on token_types -- so I don't see how to specify a myst directive when adding this token.

@@ -0,0 +1,5 @@
# head

```
Copy link
Member Author

Choose a reason for hiding this comment

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

this needs to be:

```{code-cell}
<code>
```

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.

1 participant