Sujet : Re: Weird Stuff (Markdown, syntax highlighting and Python)
De : list1 (at) *nospam* tompassin.net (Thomas Passin)
Groupes : comp.lang.pythonDate : 27. May 2024, 19:08:55
Autres entêtes
Message-ID : <mailman.49.1716851939.2909.python-list@python.org>
References : 1 2
User-Agent : Mozilla Thunderbird
On 5/26/2024 2:28 AM, Gilmeh Serda via Python-list wrote:
The web claims (I think on all pages I've read about Markdown and Python)
that this code should work, with some very minor variants on the topic:
```python
import os
with open(os.path.join('/home/user/apath', 'somefile')) as f:
print(f.read())
```
There are different flavors of Markdown, so that might be a factor so far as details of the block are concerned.
What do you mean by it not "working"? What do you see and what did you expect to see? What did you see different when you used the next example?
How did you generate the output HTML file?
However, that is not the case. At least not for me (using Python 3.12.3).
If instead I type it:
#!python
import os
with open(os.path.join('/home/user/apath', 'somefile')) as f:
print(f.read())
As an indented block (four spaces) and a shebang, THEN it works. You even
get line numbers by default.
N.b. if you don't know, you also need to generate a css file using
pygments to make this work.
Not until I started to read the markdown source code and its docs pages,
the coin dropped.
I'm posting this for other Markdown newbies that otherwise probably would
spend hours trying to make it work.
Speaking of Markdown. Does anybody out there have any idea how to turn on
table borders, adjust them (color/width/etc.) and such things? Currently I
have to add HTML to do so, which works, but isn't very nice. I'd hate to
spend an additional day or two, hunting for this info.
References:
https://pypi.org/project/Markdown/
https://python-markdown.github.io/