Skip to content

Commit afd8a65

Browse files
Parse custom mediawiki link format
1 parent 2a1b780 commit afd8a65

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

web/resources/assets/style.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ h1 {
4747
padding: 0;
4848
margin: 0;
4949
}
50-
p {
50+
li, p {
5151
line-height: 1.5em;
5252
}
5353

@@ -114,8 +114,7 @@ hr {
114114
.function-type-title {
115115
float: right;
116116
font-size: 1.8em;
117-
padding-left: 1em;
118-
padding-top: 11px;
117+
padding-top: 2px;
119118
position: relative;
120119
z-index: 1;
121120
}

web/resources/function.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<!-- Title & Description -->
22
{% if function.type_name == 'shared' %}
33
<div class="function-type-title" style="color: #7575ff;">Shared function</div>
4-
<h1 style="border-bottom: 3px solid #7575ff; margin-bottom: 0.1em;">{{ function.name }}</h1>
4+
<h1 style="border-bottom: 3px solid #7575ff; padding-bottom: 0.1em;">{{ function.name }}</h1>
55
<p style="margin-top: 1em;">{{ function['shared'].description_html }}</p>
66
{% elif function.type_name == 'client' %}
77
<div class="function-type-title" style="color: #FF0000;">Client-side function</div>
8-
<h1 style="border-bottom: 3px solid #FF0000; margin-bottom: 0.1em;">{{ function.name }}</h1>
8+
<h1 style="border-bottom: 3px solid #FF0000;">{{ function.name }}</h1>
99
<p style="margin-top: 1em;">{{ function['client'].description_html }}</p>
1010
{% elif function.type_name == 'server' %}
1111
<div class="function-type-title" style="color: #FF7F00;">Server-side function</div>
12-
<h1 style="border-bottom: 3px solid #FF7F00; margin-bottom: 0.1em;">{{ function.name }}</h1>
12+
<h1 style="border-bottom: 3px solid #FF7F00;">{{ function.name }}</h1>
1313
<p style="margin-top: 1em;">{{ function['server'].description_html }}</p>
1414
{% endif %}
1515

@@ -18,7 +18,7 @@ <h2>Syntax</h2>
1818
{% for type_name in ['shared', 'client', 'server'] %}
1919
{% if function[type_name] %}
2020
{% if function[type_name].parameters %}
21-
<pre><code class="language-lua">{{ function[type_name].name }}( {% for item in function[type_name].parameters %}{{ item.type }} {{ item.name }}, {% endfor %} )</code></pre>
21+
<pre><code class="language-lua">{{ function[type_name].name }}( {% for item in function[type_name].parameters %}{{ item.type }} {{ item.name }}{% if not loop.last %}, {% endif %}{% endfor %} )</code></pre>
2222
<ul>
2323
{% for item in function[type_name].parameters %}
2424
<li>{{ item.type }} <strong>{{ item.name }}</strong> : {{ item.description_html }}</li>
@@ -71,9 +71,9 @@ <h2>Issues</h2>
7171
<ul>
7272
{% for issue in function[type_name].issues %}
7373
<li>
74-
<p><a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
74+
<a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
7575
mtasa-blue #{{ issue.id }}
76-
</a>: {{ issue.description_html }}</p>
76+
</a>: {{ issue.description_html }}
7777
</li>
7878
{% endfor %}
7979
</ul>

web/scripts/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ def load_and_validate_yaml(file_path, schema):
1717
def to_html(markdown_text, single_paragraph=False):
1818
html = markdown.markdown(markdown_text)
1919
if single_paragraph:
20-
# Remove <p> tags
2120
html = re.sub(r'<p>(.*?)</p>', r'\1', html)
21+
22+
# Custom link syntax
23+
# Replace all [[string|text]] with <a href="/string">text</a>
24+
html = re.sub(r'\[\[(.*?)\|(.*?)\]\]', r'<a href="/\1">\2</a>', html)
25+
# Replace all [[string]] with <a href="/string">string</a>
26+
html = re.sub(r'\[\[(.*?)\]\]', r'<a href="/\1">\1</a>', html)
27+
2228
return html

0 commit comments

Comments
 (0)