Skip to content

Commit 831f157

Browse files
committed
Fix minified code integration with competitive-verifier
- Use default document_body.html template (just includes dependencies and code) - Inject minified code into embedded array instead of separate fields - This integrates properly with code.html which expects embedded array format - Minified versions now appear as tabs alongside Default and Bundled
1 parent b45bb1b commit 831f157

File tree

3 files changed

+405
-64
lines changed

3 files changed

+405
-64
lines changed
Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,2 @@
1-
{% if page.data.dependsOn.size != 0 %}
2-
<h2>Depends on</h2>
3-
<ul>
4-
{% for item in page.data._extendedDependsOn %}
5-
<li><a href="{{ item.path | absolute_url }}">{{ item.icon }} {{ item.title }}
6-
{% if item.title != item.path %}<small>({{ item.path }})</small>{% endif %}
7-
</a></li>
8-
{% endfor %}
9-
</ul>
10-
{% endif %}
11-
12-
13-
{% if page.data.requiredBy.size != 0 %}
14-
<h2>Required by</h2>
15-
<ul>
16-
{% for item in page.data._extendedRequiredBy %}
17-
<li><a href="{{ item.path | absolute_url }}">{{ item.icon }} {{ item.title }}
18-
{% if item.title != item.path %}<small>({{ item.path }})</small>{% endif %}
19-
</a></li>
20-
{% endfor %}
21-
</ul>
22-
{% endif %}
23-
24-
25-
{% if page.data.verifiedWith.size != 0 %}
26-
<h2>Verified with</h2>
27-
<ul>
28-
{% for item in page.data._extendedVerifiedWith %}
29-
<li><a href="{{ item.path | absolute_url }}">{{ item.icon }} {{ item.title }}
30-
{% if item.title != item.path %}<small>({{ item.path }})</small>{% endif %}
31-
</a></li>
32-
{% endfor %}
33-
</ul>
34-
{% endif %}
35-
36-
37-
<h2>Code</h2>
38-
39-
<script defer type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
40-
<script defer src="https://cdn.jsdelivr.net/npm/jquery-balloon-js@1.1.2/jquery.balloon.min.js" integrity="sha256-ZEYs9VrgAeNuPvs15E39OsyOJaIkXEEt10fzxJ20+2I=" crossorigin="anonymous"></script>
41-
<script defer type="text/javascript" src="{{ "/assets/js/copy-button.js" | absolute_url }}"></script>
42-
<link rel="stylesheet" href="{{ "/assets/css/copy-button.css" | absolute_url }}">
43-
44-
<span><a id="unbundled"></a></span>
45-
{% include highlight.html extension=page.data._pathExtension content=page.data.code %}
46-
47-
{% if page.data.bundledCode %}
48-
<span><a id="bundled"></a></span>
49-
{% include highlight.html extension=page.data._pathExtension content=page.data.bundledCode %}
50-
{% endif %}
51-
52-
{% if page.data.minifiedCode %}
53-
<span><a id="minified"></a>Minified (Source)</span>
54-
{% include highlight.html extension=page.data._pathExtension content=page.data.minifiedCode %}
55-
{% endif %}
56-
57-
{% if page.data.minifiedBundledCode %}
58-
<span><a id="minified-bundled"></a>Minified (Bundled)</span>
59-
{% include highlight.html extension=page.data._pathExtension content=page.data.minifiedBundledCode %}
60-
{% endif %}
1+
{%- include dependencies.html data=include.data -%}
2+
{%- include code_and_testcases.html data=include.data -%}

.verify-helper/scripts/inject_minified_docs.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,26 @@ def inject_minified_to_markdown(markdown_file, minified_code=None, minified_bund
4747
if 'data' not in front_matter or not isinstance(front_matter['data'], dict):
4848
return False
4949

50-
# Add or update minifiedCode in the nested data object
50+
# Ensure embedded array exists
51+
if 'embedded' not in front_matter['data']:
52+
return False
53+
54+
if not isinstance(front_matter['data']['embedded'], list):
55+
return False
56+
57+
# Add minified versions to the embedded array
5158
if minified_code:
52-
front_matter['data']['minifiedCode'] = minified_code
59+
front_matter['data']['embedded'].append({
60+
'name': 'minified',
61+
'code': minified_code
62+
})
5363
updated = True
5464

55-
# Add or update minifiedBundledCode in the nested data object
5665
if minified_bundled_code:
57-
front_matter['data']['minifiedBundledCode'] = minified_bundled_code
66+
front_matter['data']['embedded'].append({
67+
'name': 'minified + bundled',
68+
'code': minified_bundled_code
69+
})
5870
updated = True
5971

6072
if not updated:

0 commit comments

Comments
 (0)