importpython-markdown 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,8 +14,11 @@ time in the element's own vocabulary, so an authoring mistake is
14
14
  a loud build failure rather than a silent page.
15
15
 
16
16
  The emitted markup follows the element's contract exactly: each
17
- part is a bare ``<pre>``, a direct child of the element, in the
18
- order the author wrote it.
17
+ part is a ``<pre>`` holding one ``<code>``, the pre a direct
18
+ child of the element, in the order the author wrote it. The
19
+ element reads a ``<pre><code>`` pair and a bare ``<pre>``
20
+ identically; the inner ``<code>`` is for the surrounding theme,
21
+ whose block styling and copy button expect it.
19
22
  """
20
23
 
21
24
  import html
@@ -374,22 +377,29 @@ class ImportPythonPreprocessor(Preprocessor):
374
377
  )
375
378
  return inner.convert("\n".join(piece["text"])) + "\n"
376
379
  text, lit = self.paint("\n".join(piece["text"]), piece)
380
+ # One code element inside every pre, highlighted or not:
381
+ # MkDocs-family themes hang block styling and the copy
382
+ # button on pre > code, and the element reads both shapes
383
+ # identically. No newline before the text - a pre swallows
384
+ # one after its own tag, a code does not - so textContent
385
+ # stays byte-identical to the bare-pre form.
386
+ text = f"<code>{text}\n</code>"
377
387
  if piece["part"] == "file":
378
388
  title = html.escape(piece["title"])
379
- return f'<pre{lit} title="{title}">\n{text}\n</pre>\n'
389
+ return f'<pre{lit} title="{title}">{text}</pre>\n'
380
390
  if piece["part"] in ("config", "body"):
381
391
  role = piece["part"]
382
- return f'<pre{lit} data-role="{role}">\n{text}\n</pre>\n'
383
- return f"<pre{lit}>\n{text}\n</pre>\n"
392
+ return f'<pre{lit} data-role="{role}">{text}</pre>\n'
393
+ return f"<pre{lit}>{text}</pre>\n"
384
394
 
385
395
  def paint(self, code, piece):
386
396
  """
387
397
  Highlight a part's code as Pygments spans with no wrapper
388
- of any kind, so the pre stays a bare direct child and its
389
- textContent stays exactly the code. The class="highlight"
390
- the coloured path adds is what lets a Material or
391
- Zensical site's existing Pygments stylesheet colour these
392
- blocks, palettes and all, with no CSS of ours.
398
+ of any kind - render_piece adds the one code element both
399
+ paths share, and the pre stays the direct child. The
400
+ class="highlight" the coloured path adds is what lets a
401
+ Material or Zensical site's existing Pygments stylesheet
402
+ colour these blocks, palettes and all, with no CSS of ours.
393
403
 
394
404
  The language comes from the fence, or a file's name, with
395
405
  json and html assumed for config and body; an unknown or
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: importpython-markdown
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Runnable Python examples in Markdown, via importpython.org.
5
5
  Author-email: "Nicholas H.Tollervey" <ntoll@ntoll.org>
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ importpython_markdown/__init__.py,sha256=C9tEDiPB7CCeW76X0D-X2Rv3lCnPcwYDhH9fVNUnKjI,18453
2
+ importpython_markdown-0.1.2.dist-info/licenses/LICENSE,sha256=ksfiPPZ3bBB4_KgmDo6-NLda44B_-onAZ3JLVxYSIVg,1077
3
+ importpython_markdown-0.1.2.dist-info/METADATA,sha256=Pp5BqSH9hVCCrlFih5572ePkMcQedzY7q6JrJ61rH_s,2335
4
+ importpython_markdown-0.1.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ importpython_markdown-0.1.2.dist-info/entry_points.txt,sha256=0Fo68SFJa3rmdmuysJyRTCu35rve3xGdegmhOutPs18,81
6
+ importpython_markdown-0.1.2.dist-info/top_level.txt,sha256=gZT7U42MZK8PK1UxWpt0IGHGv8ynHvdYlxn-OjZRQ-0,22
7
+ importpython_markdown-0.1.2.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- importpython_markdown/__init__.py,sha256=Un8CqZvwxhC8YT21jS2LxZM4_qOaVtczn0wM_kSqfUE,17832
2
- importpython_markdown-0.1.1.dist-info/licenses/LICENSE,sha256=ksfiPPZ3bBB4_KgmDo6-NLda44B_-onAZ3JLVxYSIVg,1077
3
- importpython_markdown-0.1.1.dist-info/METADATA,sha256=1S3ya5P9DRheIA2oMrBS3JXZYWCFws7WbHr8T1vXQCE,2335
4
- importpython_markdown-0.1.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
- importpython_markdown-0.1.1.dist-info/entry_points.txt,sha256=0Fo68SFJa3rmdmuysJyRTCu35rve3xGdegmhOutPs18,81
6
- importpython_markdown-0.1.1.dist-info/top_level.txt,sha256=gZT7U42MZK8PK1UxWpt0IGHGv8ynHvdYlxn-OjZRQ-0,22
7
- importpython_markdown-0.1.1.dist-info/RECORD,,