markdown-environments 1.0.0__tar.gz

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.
Files changed (165) hide show
  1. markdown_environments-1.0.0/.github/dependabot.yml +11 -0
  2. markdown_environments-1.0.0/.github/workflows/publish.yaml +22 -0
  3. markdown_environments-1.0.0/.gitignore +18 -0
  4. markdown_environments-1.0.0/.readthedocs.yaml +15 -0
  5. markdown_environments-1.0.0/CONTRIBUTING.md +23 -0
  6. markdown_environments-1.0.0/LICENSE.md +21 -0
  7. markdown_environments-1.0.0/PKG-INFO +252 -0
  8. markdown_environments-1.0.0/README.md +227 -0
  9. markdown_environments-1.0.0/docs/Makefile +20 -0
  10. markdown_environments-1.0.0/docs/_static/css/custom.css +17 -0
  11. markdown_environments-1.0.0/docs/api.rst +38 -0
  12. markdown_environments-1.0.0/docs/conf.py +27 -0
  13. markdown_environments-1.0.0/docs/contributing.rst +2 -0
  14. markdown_environments-1.0.0/docs/example_usage.rst +3 -0
  15. markdown_environments-1.0.0/docs/index.rst +10 -0
  16. markdown_environments-1.0.0/docs/requirements.txt +33 -0
  17. markdown_environments-1.0.0/pyproject.toml +67 -0
  18. markdown_environments-1.0.0/requirements.txt +77 -0
  19. markdown_environments-1.0.0/src/markdown_environments/__init__.py +18 -0
  20. markdown_environments-1.0.0/src/markdown_environments/captioned_figure.py +165 -0
  21. markdown_environments-1.0.0/src/markdown_environments/cited_blockquote.py +162 -0
  22. markdown_environments-1.0.0/src/markdown_environments/div.py +130 -0
  23. markdown_environments-1.0.0/src/markdown_environments/dropdown.py +196 -0
  24. markdown_environments-1.0.0/src/markdown_environments/mixins.py +87 -0
  25. markdown_environments-1.0.0/src/markdown_environments/thms.py +435 -0
  26. markdown_environments-1.0.0/src/markdown_environments/util.py +5 -0
  27. markdown_environments-1.0.0/tests/__init__.py +0 -0
  28. markdown_environments-1.0.0/tests/captioned_figure/__init__.py +0 -0
  29. markdown_environments-1.0.0/tests/captioned_figure/fail_1.html +8 -0
  30. markdown_environments-1.0.0/tests/captioned_figure/fail_1.txt +12 -0
  31. markdown_environments-1.0.0/tests/captioned_figure/fail_2.html +8 -0
  32. markdown_environments-1.0.0/tests/captioned_figure/fail_2.txt +12 -0
  33. markdown_environments-1.0.0/tests/captioned_figure/fail_3.html +8 -0
  34. markdown_environments-1.0.0/tests/captioned_figure/fail_3.txt +12 -0
  35. markdown_environments-1.0.0/tests/captioned_figure/fail_4.html +8 -0
  36. markdown_environments-1.0.0/tests/captioned_figure/fail_4.txt +12 -0
  37. markdown_environments-1.0.0/tests/captioned_figure/success_1.html +11 -0
  38. markdown_environments-1.0.0/tests/captioned_figure/success_1.txt +13 -0
  39. markdown_environments-1.0.0/tests/captioned_figure/success_2.html +11 -0
  40. markdown_environments-1.0.0/tests/captioned_figure/success_2.txt +13 -0
  41. markdown_environments-1.0.0/tests/captioned_figure/test_captioned_figure.py +22 -0
  42. markdown_environments-1.0.0/tests/cited_blockquote/__init__.py +0 -0
  43. markdown_environments-1.0.0/tests/cited_blockquote/fail_1.html +8 -0
  44. markdown_environments-1.0.0/tests/cited_blockquote/fail_1.txt +11 -0
  45. markdown_environments-1.0.0/tests/cited_blockquote/fail_2.html +8 -0
  46. markdown_environments-1.0.0/tests/cited_blockquote/fail_2.txt +11 -0
  47. markdown_environments-1.0.0/tests/cited_blockquote/fail_3.html +8 -0
  48. markdown_environments-1.0.0/tests/cited_blockquote/fail_3.txt +11 -0
  49. markdown_environments-1.0.0/tests/cited_blockquote/fail_4.html +8 -0
  50. markdown_environments-1.0.0/tests/cited_blockquote/fail_4.txt +11 -0
  51. markdown_environments-1.0.0/tests/cited_blockquote/success_1.html +9 -0
  52. markdown_environments-1.0.0/tests/cited_blockquote/success_1.txt +12 -0
  53. markdown_environments-1.0.0/tests/cited_blockquote/success_2.html +9 -0
  54. markdown_environments-1.0.0/tests/cited_blockquote/success_2.txt +12 -0
  55. markdown_environments-1.0.0/tests/cited_blockquote/test_cited_blockquote.py +22 -0
  56. markdown_environments-1.0.0/tests/div/__init__.py +0 -0
  57. markdown_environments-1.0.0/tests/div/fail_1.html +5 -0
  58. markdown_environments-1.0.0/tests/div/fail_1.txt +5 -0
  59. markdown_environments-1.0.0/tests/div/fail_2.html +4 -0
  60. markdown_environments-1.0.0/tests/div/fail_2.txt +4 -0
  61. markdown_environments-1.0.0/tests/div/fail_3.html +4 -0
  62. markdown_environments-1.0.0/tests/div/fail_3.txt +4 -0
  63. markdown_environments-1.0.0/tests/div/success_1.html +12 -0
  64. markdown_environments-1.0.0/tests/div/success_1.txt +14 -0
  65. markdown_environments-1.0.0/tests/div/success_2.html +11 -0
  66. markdown_environments-1.0.0/tests/div/success_2.txt +11 -0
  67. markdown_environments-1.0.0/tests/div/test_div.py +26 -0
  68. markdown_environments-1.0.0/tests/dropdown/__init__.py +0 -0
  69. markdown_environments-1.0.0/tests/dropdown/fail_1.html +7 -0
  70. markdown_environments-1.0.0/tests/dropdown/fail_1.txt +10 -0
  71. markdown_environments-1.0.0/tests/dropdown/fail_2.html +6 -0
  72. markdown_environments-1.0.0/tests/dropdown/fail_2.txt +9 -0
  73. markdown_environments-1.0.0/tests/dropdown/fail_3.html +6 -0
  74. markdown_environments-1.0.0/tests/dropdown/fail_3.txt +9 -0
  75. markdown_environments-1.0.0/tests/dropdown/fail_4.html +6 -0
  76. markdown_environments-1.0.0/tests/dropdown/fail_4.txt +9 -0
  77. markdown_environments-1.0.0/tests/dropdown/fail_5.html +6 -0
  78. markdown_environments-1.0.0/tests/dropdown/fail_5.txt +9 -0
  79. markdown_environments-1.0.0/tests/dropdown/fail_6.html +6 -0
  80. markdown_environments-1.0.0/tests/dropdown/fail_6.txt +9 -0
  81. markdown_environments-1.0.0/tests/dropdown/success_1.html +19 -0
  82. markdown_environments-1.0.0/tests/dropdown/success_1.txt +20 -0
  83. markdown_environments-1.0.0/tests/dropdown/success_2.html +18 -0
  84. markdown_environments-1.0.0/tests/dropdown/success_2.txt +18 -0
  85. markdown_environments-1.0.0/tests/dropdown/test_dropdown.py +37 -0
  86. markdown_environments-1.0.0/tests/mixins/__init__.py +0 -0
  87. markdown_environments-1.0.0/tests/mixins/html_class_mixin/__init__.py +0 -0
  88. markdown_environments-1.0.0/tests/mixins/html_class_mixin/test_html_class_mixin.py +13 -0
  89. markdown_environments-1.0.0/tests/mixins/thm_mixin/__init__.py +0 -0
  90. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_1.txt +1 -0
  91. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_1_expected.txt +0 -0
  92. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_2.txt +1 -0
  93. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_2_expected.txt +1 -0
  94. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_3.txt +1 -0
  95. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_3_expected.txt +1 -0
  96. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_4.txt +1 -0
  97. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_4_expected.txt +1 -0
  98. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_5.txt +1 -0
  99. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_5_expected.txt +1 -0
  100. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_6.txt +1 -0
  101. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_6_expected.txt +1 -0
  102. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_7.txt +1 -0
  103. markdown_environments-1.0.0/tests/mixins/thm_mixin/gen_thm_heading_md_7_expected.txt +1 -0
  104. markdown_environments-1.0.0/tests/mixins/thm_mixin/prepend_thm_heading_md_1.txt +1 -0
  105. markdown_environments-1.0.0/tests/mixins/thm_mixin/prepend_thm_heading_md_1_expected.txt +1 -0
  106. markdown_environments-1.0.0/tests/mixins/thm_mixin/prepend_thm_heading_md_2.txt +1 -0
  107. markdown_environments-1.0.0/tests/mixins/thm_mixin/prepend_thm_heading_md_2_expected.txt +1 -0
  108. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_1.txt +1 -0
  109. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_2.txt +1 -0
  110. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_3.txt +1 -0
  111. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_4.txt +1 -0
  112. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_5.txt +1 -0
  113. markdown_environments-1.0.0/tests/mixins/thm_mixin/test_thm_mixin.py +143 -0
  114. markdown_environments-1.0.0/tests/thms/__init__.py +0 -0
  115. markdown_environments-1.0.0/tests/thms/fail_1.html +18 -0
  116. markdown_environments-1.0.0/tests/thms/fail_1.txt +24 -0
  117. markdown_environments-1.0.0/tests/thms/fail_2.html +16 -0
  118. markdown_environments-1.0.0/tests/thms/fail_2.txt +22 -0
  119. markdown_environments-1.0.0/tests/thms/fail_3.html +1 -0
  120. markdown_environments-1.0.0/tests/thms/fail_3.txt +1 -0
  121. markdown_environments-1.0.0/tests/thms/success_1.html +8 -0
  122. markdown_environments-1.0.0/tests/thms/success_1.txt +7 -0
  123. markdown_environments-1.0.0/tests/thms/success_2.html +9 -0
  124. markdown_environments-1.0.0/tests/thms/success_2.txt +9 -0
  125. markdown_environments-1.0.0/tests/thms/success_3.html +12 -0
  126. markdown_environments-1.0.0/tests/thms/success_3.txt +11 -0
  127. markdown_environments-1.0.0/tests/thms/success_4.html +35 -0
  128. markdown_environments-1.0.0/tests/thms/success_4.txt +31 -0
  129. markdown_environments-1.0.0/tests/thms/success_5.html +24 -0
  130. markdown_environments-1.0.0/tests/thms/success_5.txt +15 -0
  131. markdown_environments-1.0.0/tests/thms/success_6.html +30 -0
  132. markdown_environments-1.0.0/tests/thms/success_6.txt +24 -0
  133. markdown_environments-1.0.0/tests/thms/success_7.html +45 -0
  134. markdown_environments-1.0.0/tests/thms/success_7.txt +46 -0
  135. markdown_environments-1.0.0/tests/thms/test_thms.py +100 -0
  136. markdown_environments-1.0.0/tests/thms/thmcounter/__init__.py +0 -0
  137. markdown_environments-1.0.0/tests/thms/thmcounter/fail_1.html +1 -0
  138. markdown_environments-1.0.0/tests/thms/thmcounter/fail_1.txt +1 -0
  139. markdown_environments-1.0.0/tests/thms/thmcounter/success_1.html +6 -0
  140. markdown_environments-1.0.0/tests/thms/thmcounter/success_1.txt +11 -0
  141. markdown_environments-1.0.0/tests/thms/thmcounter/success_2.html +6 -0
  142. markdown_environments-1.0.0/tests/thms/thmcounter/success_2.txt +11 -0
  143. markdown_environments-1.0.0/tests/thms/thmcounter/success_3.html +6 -0
  144. markdown_environments-1.0.0/tests/thms/thmcounter/success_3.txt +11 -0
  145. markdown_environments-1.0.0/tests/thms/thmcounter/success_4.html +6 -0
  146. markdown_environments-1.0.0/tests/thms/thmcounter/success_4.txt +11 -0
  147. markdown_environments-1.0.0/tests/thms/thmcounter/success_5.html +6 -0
  148. markdown_environments-1.0.0/tests/thms/thmcounter/success_5.txt +11 -0
  149. markdown_environments-1.0.0/tests/thms/thmcounter/test_thmcounter.py +29 -0
  150. markdown_environments-1.0.0/tests/thms/thmheading/__init__.py +0 -0
  151. markdown_environments-1.0.0/tests/thms/thmheading/fail_1.html +1 -0
  152. markdown_environments-1.0.0/tests/thms/thmheading/fail_1.txt +1 -0
  153. markdown_environments-1.0.0/tests/thms/thmheading/success_1.html +1 -0
  154. markdown_environments-1.0.0/tests/thms/thmheading/success_1.txt +1 -0
  155. markdown_environments-1.0.0/tests/thms/thmheading/success_2.html +1 -0
  156. markdown_environments-1.0.0/tests/thms/thmheading/success_2.txt +1 -0
  157. markdown_environments-1.0.0/tests/thms/thmheading/success_3.html +1 -0
  158. markdown_environments-1.0.0/tests/thms/thmheading/success_3.txt +1 -0
  159. markdown_environments-1.0.0/tests/thms/thmheading/success_4.html +1 -0
  160. markdown_environments-1.0.0/tests/thms/thmheading/success_4.txt +1 -0
  161. markdown_environments-1.0.0/tests/thms/thmheading/success_5.html +1 -0
  162. markdown_environments-1.0.0/tests/thms/thmheading/success_5.txt +1 -0
  163. markdown_environments-1.0.0/tests/thms/thmheading/test_thmheading.py +22 -0
  164. markdown_environments-1.0.0/tests/util/test_util.py +9 -0
  165. markdown_environments-1.0.0/tests/util.py +18 -0
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "pip" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "monthly"
@@ -0,0 +1,22 @@
1
+ name: Build & Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ environment: release
11
+ permissions:
12
+ id-token: write # needed for PyPI trusted publisher
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - name: Install Hatch
16
+ run: pip install hatch
17
+ - name: Build package
18
+ run: hatch build
19
+ - name: Test package
20
+ run: hatch test
21
+ - name: Publish package to PyPI
22
+ uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
@@ -0,0 +1,18 @@
1
+ # build
2
+ dist/
3
+
4
+ # docs
5
+ docs/_build/
6
+
7
+ # package manager
8
+ venv/
9
+
10
+ # python
11
+ __pycache__/
12
+
13
+ # testing
14
+ .pytest_cache/
15
+ .coverage
16
+
17
+ # vim
18
+ *.swp
@@ -0,0 +1,15 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.10"
7
+
8
+ # requirements needed to build documentation
9
+ python:
10
+ install:
11
+ - requirements: docs/requirements.txt
12
+
13
+ sphinx:
14
+ configuration: docs/conf.py
15
+ fail_on_warning: true
@@ -0,0 +1,23 @@
1
+ # Contributing
2
+
3
+ I don't expect this project to be huge, so feel free to drop an issue or pull request on [GitHub](https://github.com/AnonymousRand/python-markdown-environments) to report bugs or suggest features. Running tests and updating documentation before submitting a pull request is appreciated ^^
4
+
5
+ ## Setting Up Development Environment
6
+
7
+ Install necessary packages in a virtual environment:
8
+ ```shell
9
+ $ mkdir venv
10
+ $ python3 -m venv venv
11
+ $ source venv/bin/activate
12
+ $ pip install -r requirements.txt
13
+ ```
14
+
15
+ ## Running Tests
16
+
17
+ Run `hatch test` in the project's root directory. Tests are located in `tests/`; carefully modify tests if adding new features.
18
+
19
+ ## Generating Documentation
20
+
21
+ Module, class, and function documentation are generated automatically from docstrings by `sphinx.ext.autodoc`. To update the documentation, simply update the docstrings and Read the Docs will automatically run Sphinx to generate the documentation when your changes are merged. Alternatively, to generate documentation manually for testing, run `make html` in the `docs/` directory and then open `docs/_build/html/index.html` in a browser.
22
+
23
+ Docstrings use Google style, although a sprinkle of reStructuredText/Sphinx is used for things like controlling syntax highlighting on code blocks.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 AnonymousRand
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: markdown-environments
3
+ Version: 1.0.0
4
+ Summary: Highly customizable extensions for Python-Markdown in the style of LaTeX environments/theorems
5
+ Project-URL: Homepage, https://github.com/AnonymousRand/python-markdown-environments
6
+ Project-URL: Documentation, https://github.com/AnonymousRand/python-markdown-environments#readme
7
+ Project-URL: Issues, https://github.com/AnonymousRand/python-markdown-environments/issues
8
+ Author: AnonymousRand
9
+ License-Expression: MIT
10
+ License-File: LICENSE.md
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Requires-Python: ~=3.10
21
+ Requires-Dist: beautifulsoup4~=4.12.3
22
+ Requires-Dist: lxml~=5.3.0
23
+ Requires-Dist: markdown~=3.7
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Markdown-Environments
27
+
28
+ Replicating amsthm features and syntax in Markdown so you can publish mathematical papers in HTML—because what mathematician *hasn't* tried to publish to the very reputable journal called *Their Janky Flask Personal Site That No One Will Ever See*?
29
+
30
+ This Python-Markdown extension uses LaTeX-like syntax
31
+ ```
32
+ \begin{...}
33
+ ...
34
+ \end{...}
35
+ ```
36
+ to create enviroments such as captioned figures, general-purpose `<div>`s, dropdowns, and user-defined LaTeX-style theorems that can be styled with attached HTML `class`es.
37
+
38
+ ## Installation
39
+
40
+ ```
41
+ pip install markdown-environments
42
+ ```
43
+
44
+ ## Available Environments
45
+
46
+ - `\begin{captioned_figure}`: figures with captions
47
+ - `\begin{cited_blockquote}`: blockquotes with quote attribution
48
+ - User-defined environments wrapped in general-purpose `<div>`s to style to your heart's content
49
+ - User-defined environments formatted as `<details>` and `<summary>` dropdowns
50
+ - User-defined LaTeX theorem environments with customizable:
51
+ - Theorem counters
52
+ - Heading punctuation
53
+ - Linkable `id`s by theorem name
54
+
55
+ ## Further Reading
56
+
57
+ Full documentation and detailed usage examples can be found [here](https://python-markdown-environments.readthedocs.io).
58
+
59
+ <!-- example usage -->
60
+
61
+ # Example Usage
62
+
63
+ ## Backend:
64
+
65
+ ```py
66
+ import markdown
67
+ from markdown_environments import ThmsExtension
68
+
69
+ input_text = ...
70
+ output_text = markdown.markdown(input_text, extensions=[
71
+ ThmsExtension(
72
+ div_config={
73
+ "types": {
74
+ "thm": {
75
+ "thm_type": "Theorem",
76
+ "html_class": "md-thm",
77
+ "thm_counter_incr": "0,0,1"
78
+ },
79
+ r"thm\\\*": {
80
+ "thm_type": "Theorem",
81
+ "html_class": "md-thm"
82
+ }
83
+ },
84
+ "html_class": "md-div"
85
+ },
86
+ dropdown_config={
87
+ "types": {
88
+ "exer": {
89
+ "thm_type": "Exercise",
90
+ "html_class": "md-exer",
91
+ "thm_counter_incr": "0,0,1",
92
+ "thm_punct": ":",
93
+ "use_punct_if_nothing_after": False
94
+ },
95
+ "pf": {
96
+ "thm_type": "Proof",
97
+ "thm_counter_incr": "0,0,0,1",
98
+ "thm_name_overrides_thm_heading": True
99
+ }
100
+ },
101
+ "html_class": "md-dropdown",
102
+ "summary_html_class": "md-dropdown__summary mb-0"
103
+ },
104
+ thm_heading_config={
105
+ "html_class": "md-thm-heading",
106
+ "emph_html_class": "md-thm-heading__emph"
107
+ }
108
+ )
109
+ ])
110
+ ```
111
+
112
+ ## Markdown input:
113
+
114
+ ```md
115
+ # Section {{1}}: this is theorem counter syntax from ThmsExtension()
116
+
117
+ ## Subsection {{0,1}}: Bees
118
+
119
+ Here we begin our study of bees.
120
+
121
+
122
+
123
+ \begin{thm}[the bee theorem]
124
+ According to all known laws of aviation, there is no way that a bee should be able to fly.
125
+ \end{thm}
126
+
127
+ \begin{pf}
128
+ Its wings are too small to get its fat little body off the ground.
129
+ \end{pf}
130
+
131
+
132
+
133
+ \begin{thm\*}{hidden thm name used as `id`; not real LaTeX syntax}
134
+ Bees, of course, fly anyways.
135
+ \end{thm\*}
136
+
137
+ \begin{pf}[Proofs are configured to have titles override the heading]{hidden names are useless when there's already a name}
138
+ Because bees don't care what humans think is impossible.
139
+ \end{pf}
140
+
141
+
142
+
143
+ \begin{exer}
144
+
145
+ \begin{summary}
146
+ Prove that this `summary` environment is common to all dropdown-based environments.
147
+ \end{summary}
148
+
149
+ Solution: by reading the documentation, of course!
150
+ \end{exer}
151
+
152
+
153
+
154
+ \begin{exer}
155
+ All dropdowns initialized in `ThmsExtension()` have a default `summary` value of `thm_type`,
156
+ so using dropdowns like `pf` and `exer` here without a `summary` block is also fine.
157
+
158
+ Also, since there's no extra summary after the theorem heading of "Exercise", there is no punctuation
159
+ (the colon; default punctuation is a period) since we set `"use_punct_if_nothing_after": False`.
160
+ \end{exer}
161
+ ```
162
+
163
+ ## HTML output (prettified):
164
+
165
+ ```html
166
+ <h1>Section 1: this is theorem counter syntax from ThmsExtension()</h1>
167
+ <h2>Subsection 1.1: Bees</h2>
168
+
169
+ <p>Here we begin our study of bees.</p>
170
+
171
+
172
+
173
+ <div class="md-div md-thm">
174
+ <p>
175
+ <span class="md-thm-heading" id="the-bee-theorem"><span class="md-thm-heading__emph">Theorem 1.1.1</span> (the bee theorem)</span>.
176
+ According to all known laws of aviation, there is no way that a bee should be able to fly.
177
+ </p>
178
+ </div>
179
+
180
+ <details class="md-dropdown">
181
+ <summary class="md-dropdown__summary mb-0">
182
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Proof 1.1.1.1</span></span>.
183
+ </summary>
184
+ <div>
185
+ <p>Its wings are too small to get its fat little body off the ground.</p>
186
+ </div>
187
+ </details>
188
+
189
+
190
+
191
+ <div class="md-div md-thm">
192
+ <p>
193
+ <span class="md-thm-heading" id="hidden-thm-name-used-as-id-not-real-latex-syntax">
194
+ <span class="md-thm-heading__emph">Theorem</span>
195
+ </span>.
196
+ Bees, of course, fly anyways.
197
+ </p>
198
+ </div>
199
+
200
+ <details class="md-dropdown">
201
+ <summary class="md-dropdown__summary mb-0">
202
+ <span class="md-thm-heading" id="proofs-are-configured-to-have-titles-override-the-heading">
203
+ <span class="md-thm-heading__emph">Proofs are configured to have titles override the heading</span>
204
+ </span>.
205
+ </summary>
206
+ <div>
207
+ <p>Because bees don't care what humans think is impossible.</p>
208
+ </div>
209
+ </details>
210
+
211
+
212
+
213
+ <details class="md-dropdown md-exer">
214
+ <summary class="md-dropdown__summary mb-0">
215
+ <p>
216
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Exercise 1.1.2</span></span>:
217
+ Prove that this <code>summary</code> environment is common to all dropdown-based environments.
218
+ </p>
219
+ </summary>
220
+ <div>
221
+ <p>Solution: by reading the documentation, of course!</p>
222
+ </div>
223
+ </details>
224
+
225
+
226
+
227
+ <details class="md-dropdown md-exer">
228
+ <summary class="md-dropdown__summary mb-0">
229
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Exercise 1.1.3</span></span>
230
+ </summary>
231
+ <div>
232
+ <p>
233
+ All dropdowns initialized in <code>ThmsExtension()</code> have a default <code>summary</code> value of <code>thm_type</code>,
234
+ so using dropdowns like <code>pf</code> and <code>exer</code> here without a <code>summary</code> block is also fine.
235
+ </p>
236
+ <p>
237
+ Also, since there's no extra summary after the theorem heading of "Exercise", there is no punctuation
238
+ (the colon; default punctuation is a period) since we set <code>"use_punct_if_nothing_after": False</code>.
239
+ </p>
240
+ </div>
241
+ </details>
242
+ ```
243
+
244
+ ## HTML example render:
245
+
246
+ ### Closed dropdowns:
247
+
248
+ ![example render (closed dropdowns)](https://github.com/user-attachments/assets/6ed34a55-ba7f-48c0-9c82-10efd7cb53d2)
249
+
250
+ ### Open dropdowns:
251
+
252
+ ![example render (open dropdowns)](https://github.com/user-attachments/assets/92410977-a048-4e4d-b425-84b550d6699b)
@@ -0,0 +1,227 @@
1
+ # Markdown-Environments
2
+
3
+ Replicating amsthm features and syntax in Markdown so you can publish mathematical papers in HTML—because what mathematician *hasn't* tried to publish to the very reputable journal called *Their Janky Flask Personal Site That No One Will Ever See*?
4
+
5
+ This Python-Markdown extension uses LaTeX-like syntax
6
+ ```
7
+ \begin{...}
8
+ ...
9
+ \end{...}
10
+ ```
11
+ to create enviroments such as captioned figures, general-purpose `<div>`s, dropdowns, and user-defined LaTeX-style theorems that can be styled with attached HTML `class`es.
12
+
13
+ ## Installation
14
+
15
+ ```
16
+ pip install markdown-environments
17
+ ```
18
+
19
+ ## Available Environments
20
+
21
+ - `\begin{captioned_figure}`: figures with captions
22
+ - `\begin{cited_blockquote}`: blockquotes with quote attribution
23
+ - User-defined environments wrapped in general-purpose `<div>`s to style to your heart's content
24
+ - User-defined environments formatted as `<details>` and `<summary>` dropdowns
25
+ - User-defined LaTeX theorem environments with customizable:
26
+ - Theorem counters
27
+ - Heading punctuation
28
+ - Linkable `id`s by theorem name
29
+
30
+ ## Further Reading
31
+
32
+ Full documentation and detailed usage examples can be found [here](https://python-markdown-environments.readthedocs.io).
33
+
34
+ <!-- example usage -->
35
+
36
+ # Example Usage
37
+
38
+ ## Backend:
39
+
40
+ ```py
41
+ import markdown
42
+ from markdown_environments import ThmsExtension
43
+
44
+ input_text = ...
45
+ output_text = markdown.markdown(input_text, extensions=[
46
+ ThmsExtension(
47
+ div_config={
48
+ "types": {
49
+ "thm": {
50
+ "thm_type": "Theorem",
51
+ "html_class": "md-thm",
52
+ "thm_counter_incr": "0,0,1"
53
+ },
54
+ r"thm\\\*": {
55
+ "thm_type": "Theorem",
56
+ "html_class": "md-thm"
57
+ }
58
+ },
59
+ "html_class": "md-div"
60
+ },
61
+ dropdown_config={
62
+ "types": {
63
+ "exer": {
64
+ "thm_type": "Exercise",
65
+ "html_class": "md-exer",
66
+ "thm_counter_incr": "0,0,1",
67
+ "thm_punct": ":",
68
+ "use_punct_if_nothing_after": False
69
+ },
70
+ "pf": {
71
+ "thm_type": "Proof",
72
+ "thm_counter_incr": "0,0,0,1",
73
+ "thm_name_overrides_thm_heading": True
74
+ }
75
+ },
76
+ "html_class": "md-dropdown",
77
+ "summary_html_class": "md-dropdown__summary mb-0"
78
+ },
79
+ thm_heading_config={
80
+ "html_class": "md-thm-heading",
81
+ "emph_html_class": "md-thm-heading__emph"
82
+ }
83
+ )
84
+ ])
85
+ ```
86
+
87
+ ## Markdown input:
88
+
89
+ ```md
90
+ # Section {{1}}: this is theorem counter syntax from ThmsExtension()
91
+
92
+ ## Subsection {{0,1}}: Bees
93
+
94
+ Here we begin our study of bees.
95
+
96
+
97
+
98
+ \begin{thm}[the bee theorem]
99
+ According to all known laws of aviation, there is no way that a bee should be able to fly.
100
+ \end{thm}
101
+
102
+ \begin{pf}
103
+ Its wings are too small to get its fat little body off the ground.
104
+ \end{pf}
105
+
106
+
107
+
108
+ \begin{thm\*}{hidden thm name used as `id`; not real LaTeX syntax}
109
+ Bees, of course, fly anyways.
110
+ \end{thm\*}
111
+
112
+ \begin{pf}[Proofs are configured to have titles override the heading]{hidden names are useless when there's already a name}
113
+ Because bees don't care what humans think is impossible.
114
+ \end{pf}
115
+
116
+
117
+
118
+ \begin{exer}
119
+
120
+ \begin{summary}
121
+ Prove that this `summary` environment is common to all dropdown-based environments.
122
+ \end{summary}
123
+
124
+ Solution: by reading the documentation, of course!
125
+ \end{exer}
126
+
127
+
128
+
129
+ \begin{exer}
130
+ All dropdowns initialized in `ThmsExtension()` have a default `summary` value of `thm_type`,
131
+ so using dropdowns like `pf` and `exer` here without a `summary` block is also fine.
132
+
133
+ Also, since there's no extra summary after the theorem heading of "Exercise", there is no punctuation
134
+ (the colon; default punctuation is a period) since we set `"use_punct_if_nothing_after": False`.
135
+ \end{exer}
136
+ ```
137
+
138
+ ## HTML output (prettified):
139
+
140
+ ```html
141
+ <h1>Section 1: this is theorem counter syntax from ThmsExtension()</h1>
142
+ <h2>Subsection 1.1: Bees</h2>
143
+
144
+ <p>Here we begin our study of bees.</p>
145
+
146
+
147
+
148
+ <div class="md-div md-thm">
149
+ <p>
150
+ <span class="md-thm-heading" id="the-bee-theorem"><span class="md-thm-heading__emph">Theorem 1.1.1</span> (the bee theorem)</span>.
151
+ According to all known laws of aviation, there is no way that a bee should be able to fly.
152
+ </p>
153
+ </div>
154
+
155
+ <details class="md-dropdown">
156
+ <summary class="md-dropdown__summary mb-0">
157
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Proof 1.1.1.1</span></span>.
158
+ </summary>
159
+ <div>
160
+ <p>Its wings are too small to get its fat little body off the ground.</p>
161
+ </div>
162
+ </details>
163
+
164
+
165
+
166
+ <div class="md-div md-thm">
167
+ <p>
168
+ <span class="md-thm-heading" id="hidden-thm-name-used-as-id-not-real-latex-syntax">
169
+ <span class="md-thm-heading__emph">Theorem</span>
170
+ </span>.
171
+ Bees, of course, fly anyways.
172
+ </p>
173
+ </div>
174
+
175
+ <details class="md-dropdown">
176
+ <summary class="md-dropdown__summary mb-0">
177
+ <span class="md-thm-heading" id="proofs-are-configured-to-have-titles-override-the-heading">
178
+ <span class="md-thm-heading__emph">Proofs are configured to have titles override the heading</span>
179
+ </span>.
180
+ </summary>
181
+ <div>
182
+ <p>Because bees don't care what humans think is impossible.</p>
183
+ </div>
184
+ </details>
185
+
186
+
187
+
188
+ <details class="md-dropdown md-exer">
189
+ <summary class="md-dropdown__summary mb-0">
190
+ <p>
191
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Exercise 1.1.2</span></span>:
192
+ Prove that this <code>summary</code> environment is common to all dropdown-based environments.
193
+ </p>
194
+ </summary>
195
+ <div>
196
+ <p>Solution: by reading the documentation, of course!</p>
197
+ </div>
198
+ </details>
199
+
200
+
201
+
202
+ <details class="md-dropdown md-exer">
203
+ <summary class="md-dropdown__summary mb-0">
204
+ <span class="md-thm-heading"><span class="md-thm-heading__emph">Exercise 1.1.3</span></span>
205
+ </summary>
206
+ <div>
207
+ <p>
208
+ All dropdowns initialized in <code>ThmsExtension()</code> have a default <code>summary</code> value of <code>thm_type</code>,
209
+ so using dropdowns like <code>pf</code> and <code>exer</code> here without a <code>summary</code> block is also fine.
210
+ </p>
211
+ <p>
212
+ Also, since there's no extra summary after the theorem heading of "Exercise", there is no punctuation
213
+ (the colon; default punctuation is a period) since we set <code>"use_punct_if_nothing_after": False</code>.
214
+ </p>
215
+ </div>
216
+ </details>
217
+ ```
218
+
219
+ ## HTML example render:
220
+
221
+ ### Closed dropdowns:
222
+
223
+ ![example render (closed dropdowns)](https://github.com/user-attachments/assets/6ed34a55-ba7f-48c0-9c82-10efd7cb53d2)
224
+
225
+ ### Open dropdowns:
226
+
227
+ ![example render (open dropdowns)](https://github.com/user-attachments/assets/92410977-a048-4e4d-b425-84b550d6699b)
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = ./
9
+ BUILDDIR = _build/
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,17 @@
1
+ h1 {
2
+ font-size: 2.25em;
3
+ }
4
+
5
+ h2 {
6
+ font-size: 1.75em;
7
+ }
8
+
9
+ .rst-content p.rubric,
10
+ .rst-content dl dt {
11
+ margin-bottom: 12px !important;
12
+ border-left: 3px solid #ccc !important;
13
+ background: #f0f0f0;
14
+ padding: 0.25em;
15
+ color: #404040 !important;
16
+ font-size: 1.15em;
17
+ }
@@ -0,0 +1,38 @@
1
+ API Reference
2
+ =============
3
+
4
+ .. automodule:: markdown_environments
5
+
6
+ ..
7
+ for making sure sphinx can find the classes
8
+ .. currentmodule:: markdown_environments
9
+
10
+ Captioned Figure
11
+ ----------------
12
+
13
+ .. autoclass:: CaptionedFigureExtension()
14
+ :members: __init__
15
+
16
+ Cited Blockquote
17
+ ----------------
18
+
19
+ .. autoclass:: CitedBlockquoteExtension()
20
+ :members: __init__
21
+
22
+ Div
23
+ ---
24
+
25
+ .. autoclass:: DivExtension()
26
+ :members: __init__
27
+
28
+ Dropdown
29
+ --------
30
+
31
+ .. autoclass:: DropdownExtension()
32
+ :members: __init__
33
+
34
+ Thms
35
+ ----
36
+
37
+ .. autoclass:: ThmsExtension()
38
+ :members: __init__