Skip to content

Commit

Permalink
added mermaid and some fixes from PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MonicaG committed Feb 7, 2024
1 parent 8f5d005 commit 8a863cf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
14 changes: 1 addition & 13 deletions docs/devhub/content-syntax-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ Use a single backtick for `inline code blocks`.

## Admonitions

Admonitions, also known as call-outs, are supported. Refer to the [official documentation](https://squidfunk.github.io/mkdocs-material/reference/admonitions/#admonitions) for the full list of features and syntax. Note: You do not need to add the list of extensions to your mkdocs.yml file as described in the documentation. The extensions are included by default.

Include two tabs of whitespace at the start of the text block for it to be included in the admonition block.

```markdown
!!! note
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris faucibus elit vehicula, auctor turpis eget, tempus ligula. Vestibulum at lectus pellentesque magna interdum elementum. Sed luctus erat eget mi accumsan, nec interdum nulla dictum. In commodo ligula a porttitor elementum.

Sed id dictum massa. Sed dolor libero, imperdiet hendrerit sollicitudin eu, euismod a arcu. Phasellus malesuada sagittis leo at fringilla.
Sed id dictum massa. Sed dolor libero, imperdiet hendrerit sollicitudin eu, euismod a arcu. Phasellus malesuada sagittis leo at fringilla.
```

!!! note
Expand All @@ -153,7 +151,6 @@ Text blocks with no or 1 tab of whitspace will not be included in the admonition

## Tabs

Tabs are supported. Refer to the [offical documentation](https://facelessuser.github.io/pymdown-extensions/extensions/tabbed/) for full details.

```markdown
=== "Tab 1"
Expand Down Expand Up @@ -193,15 +190,6 @@ Tabs are supported. Refer to the [offical documentation](https://facelessuser.gi

## Mermaid diagrams

````markdown
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
````
```mermaid
graph TD;
A-->B;
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ repo_url: https://github.com/bcgov/bcdg
edit_uri: edit/main/docs/
plugins:
- techdocs-core
markdown_extensions:
- markdown_inline_mermaid
- md_in_html

nav:
- Introduction: index.md
Expand Down
42 changes: 42 additions & 0 deletions patcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import logging
import re


def patch(lines):
new_lines = []
for index, line in enumerate(lines):
# if we don't do any twiddling, carry the line through as-is
new_line = line

# match lines starting with a dash or bullet, with leading white space or not
bullet = re.match(r"^[\s]*[-\*]{1}\s", new_line)

if bullet:
logging.debug(f"Found line starting with bullet: '{new_line}'")

# match lines with leading white space
has_leading_white_space = re.match(r"^[\s]+[-\*]{1}\s", new_line)
prior_line_is_bullet = re.match(r"^[-\*]{1}", lines[index - 1].lstrip())
prior_line_is_blank = re.match(r"^\n", lines[index - 1].lstrip())

if not prior_line_is_bullet and not prior_line_is_blank:
logging.debug(f"Adding a new line before '{new_line}'")
new_lines.append("\n")

# first item in a bullet list - need to make sure it has no leading whitespace. leave as-is if it's not 1st
if has_leading_white_space and not prior_line_is_bullet:
logging.debug(f"Fixing line with bad whitespace: '{new_line}'")
new_line = new_line.lstrip()

# match details element
details_element = re.match(r"<(details+)(?![^>]*\/>)[^>]*>", new_line)

# add markdown=1 attribute so mkdocs will parse markdown within the details HTML element.
if details_element:
logging.debug(f"found line with details element: '{new_line}'")
new_line = new_line.replace("details", "details markdown=\"1\" ")
logging.debug(f"repaired line with details element: '{new_line}'")

new_lines.append(new_line)
return new_lines

0 comments on commit 8a863cf

Please sign in to comment.