Skip to content

Commit

Permalink
feat!: Python Markdown nesting syntax is no longer supported. Use nes…
Browse files Browse the repository at this point in the history
…ting code blocks instead.
  • Loading branch information
valentine195 committed Feb 25, 2022
1 parent ae661d8 commit 3e65292
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 55 deletions.
27 changes: 0 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,33 +141,6 @@ This is in the original admonition.
`````
``````

Admonitions may also be nested inside each other using the [Python Markdown](https://python-markdown.github.io/extensions/admonition/) syntax.

> :warning: **Please note that this syntax _cannot_ be used for the original admonition. It must be a codeblock (```).**
Example:

````
```ad-note
title: Nested Admonitions
collapse: open
Hello!
!!! ad-note
title: This admonition is nested.
This is a nested admonition!
!!! ad-warning
title: This admonition is closed.
collapse: close
This is in the original admonition.
```
````

![](https://raw.githubusercontent.com/valentine195/obsidian-admonition/master/images/nested.png)

## Rendering Code Blocks inside Admonitions

Code blocks may be nested inside admonitions using a method similar to [Nesting Admonitions](#Nesting-Admonitions) above.
Expand Down
28 changes: 0 additions & 28 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,34 +1042,6 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
let { title, collapse, content, icon, color } =
getParametersFromSource(type, src, this.admonitions[type]);

let match = new RegExp(`^!!! ad-(${this.types.join("|")})$`, "gm");

let nestedAdmonitions = content.match(match) || [];

if (nestedAdmonitions.length) {
let matches = [getMatches(content, 0, nestedAdmonitions[0])];
for (let i = 1; i < nestedAdmonitions.length; i++) {
matches.push(
getMatches(
content,
matches[i - 1].end,
nestedAdmonitions[i]
)
);
}

let split = content.split("\n");

for (let m of matches.reverse()) {
split.splice(
m.start,
m.end - m.start + 1,
`\`\`\`ad-${m.type}\n${m.src}\n\`\`\``
);
}
content = split.join("\n");
}

if (this.data.autoCollapse && !collapse) {
collapse = this.data.defaultCollapseType ?? "open";
} else if (collapse && collapse.trim() === "none") {
Expand Down

0 comments on commit 3e65292

Please sign in to comment.