Skip to content

Commit a34c2fe

Browse files
Restore source emojis and strip them only for LaTeX output
1 parent 6b2b2b0 commit a34c2fe

7 files changed

Lines changed: 29 additions & 10 deletions

File tree

‎pug_sphinx_extensions/__init__.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import os
22
import pathlib
3+
import re
34
import urllib
45

6+
from docutils import nodes
57
import sphinx.application
68
import sphinx.util.logging
9+
from sphinx.transforms.post_transforms import SphinxPostTransform
710

811

912
DOMAIN = "packaging.python.org"
@@ -12,6 +15,20 @@
1215
logger = sphinx.util.logging.getLogger(__name__)
1316

1417

18+
_LATEX_EMOJI_RE = re.compile(r"[ \t]*[😊✨🌟🍰🚀🐍📦](?:[ \t]+[😊✨🌟🍰🚀🐍📦])*")
19+
20+
21+
class LatexEmojiTransform(SphinxPostTransform):
22+
default_priority = 500
23+
formats = ("latex",)
24+
25+
def run(self, **kwargs: object) -> None:
26+
for text_node in self.document.findall(nodes.Text):
27+
sanitized = _LATEX_EMOJI_RE.sub("", text_node.astext())
28+
if sanitized != text_node.astext():
29+
text_node.parent.replace(text_node, nodes.Text(sanitized))
30+
31+
1532
def resolve_local_html_link(app: sphinx.application.Sphinx, url_path: str) -> str:
1633
"""Takes path of a link pointing an HTML render of the current project,
1734
and returns local path of the referenced document.
@@ -79,6 +96,7 @@ def rewrite_local_uri(app: sphinx.application.Sphinx, uri: str) -> str:
7996

8097
def setup(app: sphinx.application.Sphinx) -> dict[str, bool]:
8198
app.connect("linkcheck-process-uri", rewrite_local_uri)
99+
app.add_post_transform(LatexEmojiTransform)
82100

83101
return {
84102
"parallel_read_safe": True,

‎source/guides/github-actions-ci-cd-sample/publish-to-pypi.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Publish Python distribution to PyPI and TestPyPI
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
22

33
on: push
44

55
jobs:
66
build:
7-
name: Build distribution
7+
name: Build distribution 📦
88
runs-on: ubuntu-latest
99

1010
steps:
@@ -31,7 +31,7 @@ jobs:
3131

3232
publish-to-pypi:
3333
name: >-
34-
Publish Python distribution to PyPI
34+
Publish Python 🐍 distribution 📦 to PyPI
3535
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
3636
needs:
3737
- build
@@ -48,11 +48,11 @@ jobs:
4848
with:
4949
name: python-package-distributions
5050
path: dist/
51-
- name: Publish distribution to PyPI
51+
- name: Publish distribution 📦 to PyPI
5252
uses: pypa/gh-action-pypi-publish@release/v1
5353

5454
publish-to-testpypi:
55-
name: Publish Python distribution to TestPyPI
55+
name: Publish Python 🐍 distribution 📦 to TestPyPI
5656
needs:
5757
- build
5858
runs-on: ubuntu-latest
@@ -70,7 +70,7 @@ jobs:
7070
with:
7171
name: python-package-distributions
7272
path: dist/
73-
- name: Publish distribution to TestPyPI
73+
- name: Publish distribution 📦 to TestPyPI
7474
uses: pypa/gh-action-pypi-publish@release/v1
7575
with:
7676
repository-url: https://test.pypi.org/legacy/

‎source/guides/installing-stand-alone-command-line-tools.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ For example:
5959
installed package cowsay 6.1, installed using Python 3.12.2
6060
These apps are now globally available
6161
- cowsay
62-
done!
62+
done! ✨ 🌟 ✨
6363
$ cowsay -t moo
6464
___
6565
< moo >

‎source/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pre-existing project, if you are its owner.
4848
them in your PyPI and TestPyPI account settings in case you are replacing your old setup with the new one.
4949

5050

51-
Let's begin!
51+
Let's begin! 🚀
5252

5353
1. Go to https://pypi.org/manage/account/publishing/.
5454
2. Fill in the name you wish to publish your new

‎source/index.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ references to help you distribute and install Python packages with modern
2727
tools.
2828

2929
This guide is maintained on `GitHub`_ by the :doc:`Python Packaging Authority <pypa:index>`. We
30-
happily accept :doc:`contributions and feedback <contribute>`.
30+
happily accept :doc:`contributions and feedback <contribute>`. 😊
3131

3232
.. _GitHub: https://github.com/pypa/packaging.python.org
3333

‎source/tutorials/managing-dependencies.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Next steps
140140
----------
141141

142142
Congratulations, you now know how to effectively manage dependencies and
143-
development environments on a collaborative Python project!
143+
development environments on a collaborative Python project! ✨ 🍰 ✨
144144

145145
If you're interested in creating and distributing your own Python packages, see
146146
the :ref:`tutorial on packaging and distributing packages <distributing-packages>`.

‎source/tutorials/packaging-projects.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ Next steps
484484
----------
485485

486486
**Congratulations, you've packaged and distributed a Python project!**
487+
✨ 🍰 ✨
487488

488489
Keep in mind that this tutorial showed you how to upload your package to Test
489490
PyPI, which isn't a permanent storage. The Test system occasionally deletes

0 commit comments

Comments
 (0)