There is a lot of information about using Python code in a Markdown document. But all this is like a demonstration of Python snippets, rather than creating good documents.
Can I not combine Python and Markdown in one document, as you can with R and Markdown?
MWE:
Output some text from Python in **Markdown**:
```python
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
print(clf.predict_proba(iris.data[:1, :]))
```
Compilation: markdown_py markdown.txt
<p>Output some text from Python in <strong>Markdown</strong>:
<code>python
from sklearn.datasets import load_iris
from sklearn import tree
iris = load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris.data, iris.target)
clf.predict_proba(iris.data[:1, :])</code></p>
It displays the code (cool), but does not actually run it.
Can't you run Python code in Markdown? If not, what are the alternatives?
(Using the python-markdown package from Ubuntu.)
source
share