Start replacing FAQ with MD filter

This commit is contained in:
mDuo13
2021-07-02 15:24:10 -07:00
parent fecd41cc0c
commit b886f6ceaf
3 changed files with 80 additions and 1 deletions

View File

@@ -5,8 +5,12 @@ blurb: Get answers to frequently asked questions, covering topics such as valida
labels: labels:
- Blockchain - Blockchain
#top_nav_grouping: Questions #top_nav_grouping: Questions
template: page-faq2.html.jinja
eyebrow_text: Your Questions About XRPL, Answered
filters:
- faq
--- ---
# Technical FAQ # FAQ
## Validators and Unique Node Lists ## Validators and Unique Node Lists

View File

@@ -0,0 +1,44 @@
{% extends "base.html.jinja" %}
{% block head %}
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
{% endblock %}
{% block bodyclasses %}no-sidebar{% endblock %}
{% block mainclasses %}landing{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block main %}
<div class="position-relative">
<img src="./img/backgrounds/faq-bg.svg" class="landing-bg" id="faq-background">
</div>
<section class="py-26 text-center">
<div class="col-lg-5 mx-auto text-center">
<div class="d-flex flex-column-reverse">
<h1 class="mb-0">{{page.name}}</h1>
<h6 class="green-500 mb-3">{{page.eyebrow_text}}</h6>
</div>
</div>
</section>
<section class="container-new py-26" id="faq-content">
{{content}}
</section>
{% endblock %}
{% block endbody %}
<script type="application/javascript">
gtag('config', 'UA-157720658-3', {'content_group1': 'Hub Pages'});
</script>
{% endblock %}

31
tool/filter_faq.py Normal file
View File

@@ -0,0 +1,31 @@
################################################
## FAQ Formatter
## Author: Rome Reginelli
## Copyright: Ripple Labs, 2021
##
## Styles the FAQ as an accordion of questions.
################################################
from bs4 import NavigableString
Q_TAG = "h4"
def filter_soup(soup, **kwargs):
qs = soup.find_all(Q_TAG)
for q in qs:
stuff_to_wrap = []
el = q
while el.next_sibling:
el = el.next_sibling
if isinstance(el, NavigableString):
stuff_to_wrap.append(el)
elif el.name != Q_TAG:
stuff_to_wrap.append(el)
else:
# We probably found the next question, stop here
break
wrapper = soup.new_tag("div", class_="q-wrapper")
[wrapper.append(el) for el in stuff_to_wrap]
q.replace_with(wrapper)
wrapper.insert(0, q)