-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
175 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
order: -6 | ||
--- | ||
|
||
# Asides | ||
|
||
## Note | ||
|
||
{.dj-djot-demo} | ||
``` | ||
{tag=aside .note} | ||
::: | ||
Objects in mirror may be closer than they appear | ||
::: | ||
``` | ||
|
||
## Tip | ||
|
||
{.dj-djot-demo} | ||
``` | ||
{tag=aside .tip} | ||
::: | ||
Objects in mirror may be closer than they appear | ||
::: | ||
``` | ||
|
||
## Important | ||
|
||
{.dj-djot-demo} | ||
``` | ||
{tag=aside .important} | ||
::: | ||
Objects in mirror may be closer than they appear | ||
::: | ||
``` | ||
|
||
## Caution | ||
|
||
{.dj-djot-demo} | ||
``` | ||
{tag=aside .caution} | ||
::: | ||
Objects in mirror may be closer than they appear | ||
::: | ||
``` | ||
|
||
## Warning | ||
|
||
{.dj-djot-demo} | ||
``` | ||
{tag=aside .warning} | ||
::: | ||
Objects in mirror may be closer than they appear | ||
::: | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
md_flavor: gfm | ||
--- | ||
|
||
# GitHub Markdown demos | ||
|
||
## Alerts | ||
|
||
### H3 | ||
|
||
```md | ||
> [!NOTE] | ||
> Useful information that users should know, even when skimming content. | ||
``` | ||
|
||
> [!NOTE] | ||
> Useful information that users should know, even when skimming content. | ||
```md | ||
> [!TIP] | ||
> Helpful advice for doing things better or more easily. | ||
``` | ||
|
||
> [!TIP] | ||
> Helpful advice for doing things better or more easily. | ||
```md | ||
> [!IMPORTANT] | ||
> Key information users need to know to achieve their goal. | ||
``` | ||
|
||
> [!IMPORTANT] | ||
> Key information users need to know to achieve their goal. | ||
```md | ||
> [!WARNING] | ||
> Urgent info that needs immediate user attention to avoid problems. | ||
``` | ||
|
||
> [!WARNING] | ||
> Urgent info that needs immediate user attention to avoid problems. | ||
```md | ||
> [!CAUTION] | ||
> Advises about risks or negative outcomes of certain actions. | ||
``` | ||
|
||
> [!CAUTION] | ||
> Advises about risks or negative outcomes of certain actions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { DjockeyDoc, DjockeyPlugin } from "../types.js"; | ||
import { applyFilter } from "../engine/djotFiltersPlus.js"; | ||
import { djotASTToText, getHasClass } from "../util.js"; | ||
import { Block } from "@djot/djot"; | ||
|
||
// These happen to correspond to Djockey's 'aside' classes, so we're just going | ||
// to replace the 'div' tag with the 'aside' tag and remove the starting paragraph. | ||
const GITHUB_ALERT_CLASSES = ["note", "tip", "important", "warning", "caution"]; | ||
|
||
export class GFMAlertsPlugin implements DjockeyPlugin { | ||
name = "GitHub Flavored Markdown Alerts"; | ||
|
||
onPass_write(doc: DjockeyDoc) { | ||
applyFilter(doc.docs.content, () => ({ | ||
div: (node) => { | ||
for (const cls of GITHUB_ALERT_CLASSES) { | ||
if (getHasClass(node, cls) && !node.attributes?.tag) { | ||
const newNode = structuredClone(node); | ||
|
||
const children = newNode.children || ([] as Block[]); | ||
if ( | ||
!children.length || | ||
children[0].tag !== "p" || | ||
djotASTToText(children[0]).toLowerCase() !== cls | ||
) | ||
if (newNode.children && newNode.children.length) | ||
newNode.attributes = { ...node.attributes, tag: "aside" }; | ||
newNode.children = newNode.children.slice(1); | ||
return newNode; | ||
} | ||
} | ||
}, | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters