Merge branch 'callouts'

This commit is contained in:
mDuo13
2016-06-13 17:35:53 -07:00
37 changed files with 3197 additions and 107 deletions

View File

@@ -29,6 +29,7 @@ targets:
- multicode_tabs
- standardize_header_ids
- buttonize
- callouts
- name: ripple.com
filters:

27
tool/filter_callouts.py Normal file
View File

@@ -0,0 +1,27 @@
################################################################################
## Callouts filter ##
## Author: Rome Reginelli ##
## Copyright: Ripple Labs, Inc. 2016 ##
## ##
## Looks for sections starting **Note:** or **Caution:** and gives them CSS ##
## classes like "callout note" so they can be styled accordinglyselfselfself. ##
################################################################################
import re
CALLOUT_CLASS_MAPPING = {
"note": "devportal-callout note",
"warning": "devportal-callout warning",
"caution": "devportal-callout caution",
"tip": "devportal-callout tip",
}
def filter_soup(soup, target=None, page=None):
"""replace underscores with dashes in h1,h2,etc. for backwards compatibility"""
callout_intro = re.compile(r"(Note|Warning|Tip|Caution):?$", re.I)
callouts = soup.find_all(name=["strong","em"], string=callout_intro)
for c in callouts:
if not c.previous_sibling: #This callout starts a block
callout_type = c.string.replace(":","").lower()
if callout_type in CALLOUT_CLASS_MAPPING:
c.parent["class"] = CALLOUT_CLASS_MAPPING[callout_type]
#c.parent["class"] = "callout %s" % callout_type

View File

@@ -2,7 +2,7 @@
{% block head %}
<!-- syntax highlighting -->
<link rel="stylesheet" href="assets/vendor/docco.min.css">
<link rel="stylesheet" href="assets/vendor/docco.min.css" />
<script src="assets/vendor/highlight.min.js"></script>
<!-- syntax selection js -->
@@ -17,6 +17,9 @@
<script src="assets/js/expandcode.js"></script>
<script src="assets/js/fixsidebarscroll.js"></script>
<!-- fontawesome icons -->
<link rel="stylesheet" href="assets/vendor/fontawesome/css/font-awesome.min.css" />
{% endblock %}
{% block sidebar %}