Skip to content

Commit 0d7be84

Browse files
committed
Revert change to line wrapping
Instead of forcing line wrapping, which may surprise some, even if benign, just use `line_spans` in our own docs.
1 parent 6f9cb09 commit 0d7be84

File tree

9 files changed

+27
-57
lines changed

9 files changed

+27
-57
lines changed

docs/src/markdown/about/changelog.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ icon: lucide/scroll-text
1111

1212
In addition, Quotes also provides an optional feature to enable specifying callouts/alerts in the style used by
1313
GitHub and Obsidian.
14-
- **NEW**: Highlight: When using Pygments lines are now wrapped in `<span>` tags. This allows for easier and better
15-
styling of line highlights. Using `line_spans` will additionally add IDs as they always did.
1614

1715
## 10.19.1
1816

docs/src/markdown/extensions/superfences.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ extensions:
468468
extension_configs:
469469
pymdownx.highlight:
470470
auto_title: true
471+
line_spans: __codeline_a
472+
line_anchors: __codelineno_a
473+
anchor_linenums: True
471474
---
472475
```python
473476
import foo.bar
@@ -497,6 +500,9 @@ extensions:
497500
extension_configs:
498501
pymdownx.highlight:
499502
auto_title: true
503+
line_spans: __codeline_b
504+
line_anchors: __codelineno_b
505+
anchor_linenums: True
500506
---
501507
```pycon
502508
>>> 3 + 3
@@ -532,6 +538,9 @@ extension_configs:
532538
pymdownx.highlight:
533539
auto_title: true
534540
auto_title_map: {"Python Console Session": "Python"}
541+
line_spans: __codeline_c
542+
line_anchors: __codelineno_c
543+
anchor_linenums: True
535544
---
536545
```pycon
537546
>>> 3 + 3
@@ -663,6 +672,10 @@ extensions:
663672
extension_configs:
664673
pymdownx.superfences:
665674
relaxed_headers: true
675+
pymdownx.highlight:
676+
line_spans: __codeline_d
677+
line_anchors: __codelineno_d
678+
anchor_linenums: True
666679
---
667680
```python [3]
668681
import code

docs/src/scss/extensions/_highlight.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
/* `pymdownx-inline` mode */
7676
[data-linenos] {
7777

78+
&:hover::before {
79+
color: var(--md-accent-fg-color);
80+
}
81+
7882
/* Special line mode coloring */
7983
&.special::before {
8084
background-color: var(--md-code-special-bg-color);

docs/src/zensical.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ markdown_extensions:
143143
class: md-render
144144
format: !!python/name:tools.pymdownx_md_render.md_sub_render
145145
- pymdownx.highlight:
146+
line_spans: __codeline
147+
line_anchors: __codelineno
148+
anchor_linenums: True
146149
extend_pygments_lang:
147150
- name: php-inline
148151
lang: php

docs/theme/assets/pymdownx-extras/extra-340de9f8e9.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/theme/assets/pymdownx-extras/extra-340de9f8e9.css renamed to docs/theme/assets/pymdownx-extras/extra-8ade818a2f.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/theme/assets/pymdownx-extras/extra-8ade818a2f.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pymdownx/highlight.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -229,57 +229,6 @@ def _wrap_tablelinenos(self, inner):
229229
for t, line in HtmlFormatter._wrap_tablelinenos(self, inner):
230230
yield t, self.RE_TABLE_NUMS.sub(r'\1<span></span>', line)
231231

232-
def _wrap_lines(self, inner):
233-
"""Wrap lines."""
234-
235-
for t, line in inner:
236-
if t:
237-
yield 1, f'<span>{line}</span>'
238-
else:
239-
yield 0, line
240-
241-
def format_unencoded(self, tokensource, outfile):
242-
"""
243-
The formatting process uses several nested generators; which of
244-
them are used is determined by the user's options.
245-
246-
Each generator should take at least one argument, ``inner``,
247-
and wrap the pieces of text generated by this.
248-
249-
Always yield 2-tuples: (code, text). If "code" is 1, the text
250-
is part of the original tokensource being highlighted, if it's
251-
0, the text is some piece of wrapping. This makes it possible to
252-
use several different wrappers that process the original source
253-
linewise, e.g. line number generators.
254-
"""
255-
256-
source = self._format_lines(tokensource)
257-
258-
# As a special case, we wrap line numbers before line highlighting
259-
# so the line numbers get wrapped in the highlighting tag.
260-
if not self.nowrap and self.linenos == 2:
261-
source = self._wrap_inlinelinenos(source)
262-
263-
if self.hl_lines:
264-
source = self._highlight_lines(source)
265-
266-
if not self.nowrap:
267-
if self.lineanchors:
268-
source = self._wrap_lineanchors(source)
269-
if self.linespans:
270-
source = self._wrap_linespans(source)
271-
else:
272-
source = self._wrap_lines(source)
273-
source = self.wrap(source)
274-
if self.linenos == 1:
275-
source = self._wrap_tablelinenos(source)
276-
source = self._wrap_div(source)
277-
if self.full:
278-
source = self._wrap_full(source, outfile)
279-
280-
for _, piece in source:
281-
outfile.write(piece)
282-
283232

284233
class Highlight:
285234
"""Highlight class."""

zensical.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ markdown_extensions:
143143
class: md-render
144144
format: !!python/name:tools.pymdownx_md_render.md_sub_render
145145
- pymdownx.highlight:
146+
line_spans: __codeline
147+
line_anchors: __codelineno
148+
anchor_linenums: True
146149
extend_pygments_lang:
147150
- name: php-inline
148151
lang: php
@@ -268,7 +271,7 @@ extra:
268271

269272
extra_css:
270273
# - https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css
271-
- assets/pymdownx-extras/extra-340de9f8e9.css
274+
- assets/pymdownx-extras/extra-8ade818a2f.css
272275
extra_javascript:
273276
- assets/pymdownx-extras/extra-loader-Ccztcqfq.js
274277
- https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js

0 commit comments

Comments
 (0)