Evaluate Markdown Code Block in Python, Append Result as Comment
I am new to Editorial and pretty new to Python, too. I am trying to find out whether I can use Editorial to take notes while learning Python, similar to IPython Notebooks (I know about the Computable app but want to try another approach).
What I want to archive is:
- Send the markdown code block where the cursor is currently in to Python (I use fenced code blocks)
- Evaluate the code
- Append the results as comments at the end of the same markdown code block
```python 1 + 1 10 % 3 ```
```python 1 + 1 10 % 3 # 2 # 1 ```
Do you have any pointers how to best tackle this problem?
So you want to evaluate code that is inside of the fenced code blocks of your markdown file using the python interpreter, and then return the results back to your markdown document?
This is possible. I believe you could use regular expressions, and there is a workflow for processing python. I will see if I can find it. If not, I could attempt this.
I also have workflows for people just beginning Editorial/Python if you would like links.
This workflow should do it for you with not much effort to tweak it. Inside of the "Execute Python Expression" box, put a "current selection" variable.
If you need any help. Let me know