Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.47.1716843512.2909.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.47.1716843512.2909.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: dn <PythonList@DancesWithMice.info>
Newsgroups: comp.lang.python
Subject: Re: Weird Stuff (Markdown, syntax highlighting and Python)
Date: Tue, 28 May 2024 08:58:17 +1200
Organization: DWM
Lines: 122
Message-ID: <mailman.47.1716843512.2909.python-list@python.org>
References: <DEA4O.100038$m2s1.57313@fx04.ams4>
 <12dcdc9e-095b-4e8e-ae03-ed45ed64856d@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de FgqKSySVWaM6iuv5fRBT6g7Wx7EMTJ398JjqHKfJqhHw==
Cancel-Lock: sha1:Ppq7eEe9Neq4EPQYPfH4JCrM2zc= sha256:7h0TM4uxHXURqsdv+XKVeOE+UAijcIKwC3pwmMP2qnE=
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
 reason="2048-bit key; unprotected key"
 header.d=danceswithmice.info header.i=@danceswithmice.info
 header.b=GIoHZCM+; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.032
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; '(which': 0.04; '3.6':
 0.05; 'pypi': 0.05; '=dn': 0.09; 'from:addr:danceswithmice.info':
 0.09; 'from:addr:pythonlist': 0.09; 'pages,': 0.09; 'python)':
 0.09; 'received:192.168.1.64': 0.09; 'url-ip:151.101.0.223/32':
 0.09; 'url-ip:151.101.128.223/32': 0.09; 'url-
 ip:151.101.192.223/32': 0.09; 'url-ip:151.101.64.223/32': 0.09;
 'url:search': 0.09; 'subject:Python': 0.12; 'url:github': 0.14;
 'import': 0.15; 'problem.': 0.15; 'syntax': 0.15; '"standard':
 0.16; 'css': 0.16; 'default.': 0.16; 'heavily': 0.16; 'markdown.':
 0.16; 'message-id:@DancesWithMice.info': 0.16; 'objective': 0.16;
 'question,': 0.16; 'received:cloud': 0.16; 'received:rangi.cloud':
 0.16; 'subject:syntax': 0.16; 'topic:': 0.16; 'unclear,': 0.16;
 'url:project': 0.16; 'url:pypi': 0.16; 'variant': 0.16; 'wrote:':
 0.16; 'problem': 0.16; 'python': 0.16; 'instead': 0.17;
 'probably': 0.17; 'to:addr:python-list': 0.20; 'language': 0.21;
 "i've": 0.22; 'code': 0.23; 'url:wiki': 0.23; "i'd": 0.24; 'idea':
 0.24; 'fellow': 0.25; 'tried': 0.26; 'again,': 0.26; "isn't":
 0.27; 'example,': 0.28; 'header:User-Agent:1': 0.30; 'code,':
 0.31; 'header:Organization:1': 0.31; 'think': 0.32; 'anybody':
 0.32; 'here,': 0.32; 'python-list': 0.32; 'received:192.168.1':
 0.32; 'but': 0.32; "i'm": 0.33; 'there': 0.33; 'particular': 0.33;
 'same': 0.34; 'package': 0.34; 'work.': 0.34; 'header:In-Reply-
 To:1': 0.34; 'trying': 0.35; 'work,': 0.36; 'people': 0.36;
 'source': 0.36; 'necessarily': 0.37; "skip:' 10": 0.37;
 'currently': 0.37; 'using': 0.37; "it's": 0.37; 'others': 0.37;
 'received:192.168': 0.37; 'file': 0.38; 'read': 0.38; 'least':
 0.39; 'single': 0.39; 'otherwise': 0.39; 'use': 0.39; 'block':
 0.39; 'finding': 0.39; 'neither': 0.39; 'table': 0.39; 'appears':
 0.40; 'case.': 0.40; 'serious': 0.40; 'learn': 0.40; 'should':
 0.40; 'reference': 0.60; 'likely': 0.61; 'ten': 0.61; 'skip:h 10':
 0.61; 'seen': 0.62; 'today,': 0.62; 'url-ip:151.101.0/24': 0.62;
 'url-ip:151.101.128/24': 0.62; 'url-ip:151.101.192/24': 0.62;
 'url-ip:151.101.64/24': 0.62; 'hours': 0.63; 'great': 0.63;
 'updates': 0.64; 'claims': 0.64; 'speaking': 0.64; 'spend': 0.64;
 'your': 0.64; 'upon': 0.64; 'came': 0.65; 'documents': 0.65;
 'tool': 0.65; 'years': 0.65; 'day': 0.66; 'numbers': 0.67;
 'url:q': 0.67; 'worked': 0.67; 'accept': 0.67; 'further': 0.69;
 'it:': 0.69; 'latter': 0.69; 'processing,': 0.69; 'within': 0.69;
 'experience.': 0.70; 'url-ip:208.80.154/24': 0.70; 'url-
 ip:208.80/16': 0.70; 'url:wikipedia': 0.70; 'url-ip:208/8': 0.71;
 'offer': 0.71; 'combination': 0.76; 'reply': 0.77; 'html': 0.80;
 'led': 0.81; 'coin': 0.84; 'extracted': 0.84; 'line-up': 0.84;
 'markdown': 0.84; 'minor': 0.84; 'realise': 0.84; 'subject:Weird':
 0.84; 'dependent': 0.93
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 9F904738
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
 s=staff; t=1716843504;
 bh=rwXUkoJhQqr2ZEdRBJMC/QlP+WlHwFQarcOT4jy2YNM=;
 h=Date:From:Subject:To:References:In-Reply-To:From;
 b=GIoHZCM++wgRGmV+QWf05vfjyFQrF4vAl7aKCA8JVwnbUIWHnwR82WcYuLE7ayPNN
 17YIYKhus9wNNaAZlVvnAXKwTlH5MRSUL6rGFsz6aELCpgsuPJRe0gkl2xSKGl46vA
 eJSYNXYjreDLY0bjENkGoR+C8K36/uEPGslvojaXkN5MY2d1oUC2VSu11lfY34LBQl
 KRP+6QB+e8toQPDkgrJlG2jkp0VWq132DllIC9o+/xqEwEeXdjodfzoI1t5i4uOJVC
 Im/OLfZYSHdpzJ/u9ttpqGWjkzo7nBc+aiLAKzrD5ZSw0NgFWGoJvDzSHBMC2OyBe+
 DC8KdbGnsRxyg==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <DEA4O.100038$m2s1.57313@fx04.ams4>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
 <python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
 <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <12dcdc9e-095b-4e8e-ae03-ed45ed64856d@DancesWithMice.info>
X-Mailman-Original-References: <DEA4O.100038$m2s1.57313@fx04.ams4>
Bytes: 9834

With reference to another reply here, the "Weird stuff" came from 
reading the question, finding it unclear, and only later realising that 
whereas most people write Markdown-formatted documents for later 
processing, or perhaps docstrings in Markdown-format for collection by 
documentation systems; here, the objective appears to be using Python to 
generate Markdown.

How much have you used Markdown to any serious degree, before attempting 
this feat?


On 26/05/24 18:28, 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:

There are so many "variants", the problem is not "minor"!

Markdown users learn to use their tool (again, see @Grant's question) 
and work within the implementation of that "variant".

Like any other non-standardised tool, the users of some particular 
'version' often fail to realise that others using different versions may 
not enjoy the same experience. Plus-one for standardisation!


At the end of the message, the web.refs reveal use of a package which is 
based upon a variant of Markdown that is 20-years old(!), albeit with 
some updates to suit yet another variant. Neither variant-author famous 
for collaboration. The phrase YMMV springs to mind...


Some ten years ago, an effort was made to standardise Markup, and it 
ended-up being called CommonMark. Why is it not called "Standard 
Markdown" one might ask? Because the fellow who 'invented' Markdown 
objected. This very objection has likely led directly to your 
confusions, because the particular PyPi package is based upon that 
original definition...

Whereas, Markdown 3.6 is the most-recently updated Markdown search-hit 
on PyPi today, have you tried any of the others (which, ironically, may 
offer more recent and/or more standardised coverage)?


This has worked in all of the Markdown processors I have used or tried-out:

The (?reasonable) 'common-core', offers single back-ticks for code, 
triple back-ticks for a code-block, and the latter with or without a 
language specification which *usually* kicks-in syntax highlighting.


> ```python
> 
> import os
> 
> with open(os.path.join('/home/user/apath', 'somefile')) as f:
>      print(f.read())
> ```
> 
> However, that is not the case. At least not for me (using Python 3.12.3).

It's not Python 3 that is the problem. It is the "Markdown 3.6" package!


> If instead I type it:


I've not seen the hash-bang combination in-the-wild (but YMMV!)

>      #!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.

An indented-block is NOT necessarily the same as a code-block - just as 
"code" is not necessarily "Python".

Line numbers are great - although if a code snippet is extracted from 
the middle of some example code-file, the original line-numbers won't 
line-up with Markdown's...


> N.b. if you don't know, you also need to generate a css file using
> pygments to make this work.

That's not what the package's docs suggest: 
https://python-markdown.github.io/extensions/fenced_code_blocks/


> 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
========== REMAINDER OF ARTICLE TRUNCATED ==========