Skip to content

Commit

Permalink
fix: add pygments
Browse files Browse the repository at this point in the history
... and extra test in fake_data
  • Loading branch information
taoky committed Oct 17, 2023
1 parent 9f2f321 commit 2babb5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions frontend/management/commands/fake_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import random
import markdown.treeprocessors

from django.core.management.base import BaseCommand
from django.db.transaction import atomic
Expand Down Expand Up @@ -82,13 +83,22 @@ def handle(self, fake_complex_challenges, fake_simple_challenges,
)

for i in range(1, fake_complex_challenges + 1):
if random.choice((False, False, True)):
choice = random.choice((1, 2, 2, 3))
if choice == 1:
detail = """<p>众所周知,对 $x$ 求导得到的结果为 1。<code>flag{FLAG_INDEX}</code></p>
<p>块状公式测试 <code>flag{FLAG_INDEX:USER_ID}</code></p>
<p>$$\\frac{1}{3} = \\frac{2}{6}$$</p>
"""
else:
elif choice == 2:
detail = '<code>flag{FLAG_INDEX}</code> 或 <code>flag{FLAG_INDEX:USER_ID}</code>'
elif choice == 3:
# test markdown code block
detail = markdown.markdown(
"""```python
def a():
pass
```""", extensions=['codehilite', 'fenced_code'],
)
Challenge.create(
Context(root),
name=f'复杂题 {i}',
Expand Down
5 changes: 2 additions & 3 deletions requirements-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ django-allauth==0.57.0
gevent==23.9.1
greenlet==3.0.0
idna==3.4
importlib-metadata==6.8.0
jmespath==0.10.0
Markdown==3.4.4
oauthlib==3.2.2
Expand All @@ -19,6 +18,7 @@ psycopg-binary==3.1.12
psycopg-pool==3.1.8
pycparser==2.21
pycryptodome==3.19.0
Pygments==2.16.1
PyJWT==2.8.0
pymemcache==4.0.0
pyOpenSSL==23.2.0
Expand All @@ -27,9 +27,8 @@ PyYAML==6.0.1
requests==2.31.0
requests-oauthlib==1.3.1
sqlparse==0.4.4
typing-extensions==4.8.0
typing_extensions==4.8.0
urllib3==2.0.6
uWSGI==2.0.22
zipp==3.17.0
zope.event==5.0
zope.interface==6.1
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ psycopg==3.1.12
psycopg-binary==3.1.12
psycopg-pool==3.1.8
pycryptodome==3.19.0
pygments==2.16.1
pymemcache==4.0.0
pyOpenSSL==23.2.0
PyYAML==6.0.1
Expand Down

0 comments on commit 2babb5c

Please sign in to comment.