-
Notifications
You must be signed in to change notification settings - Fork 3
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
8 changed files
with
414 additions
and
4 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,139 @@ | ||
--- | ||
title: 提示 | ||
--- | ||
|
||
PageForge 支持使用 markdown 实现了提示相关信息。 | ||
|
||
!!! danger "注意" | ||
|
||
需要注意的是必须要使用 `!!!` 包裹,且后面的内容需要缩进。 | ||
|
||
!!! | ||
|
||
支持的类型有: | ||
|
||
- `info` | ||
- `danger` | ||
- `success` | ||
- `warning` | ||
- `dark` | ||
|
||
## Info | ||
|
||
--- | ||
|
||
`info` 类型的提示信息可以使用如下的语法: | ||
|
||
```markdown | ||
!!! info "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! info "一行" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
|
||
## Danger | ||
|
||
--- | ||
|
||
`danger` 类型的提示信息可以使用如下的语法: | ||
|
||
```markdown | ||
!!! danger "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! danger "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
|
||
## Success | ||
|
||
--- | ||
|
||
`success` 类型的提示信息可以使用如下的语法: | ||
|
||
```markdown | ||
!!! success "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! success "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
|
||
## Warning | ||
|
||
--- | ||
|
||
`warning` 类型的提示信息可以使用如下的语法。 | ||
|
||
```markdown | ||
!!! warning "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! warning "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
|
||
## Dark | ||
|
||
--- | ||
|
||
`dark` 类型的提示信息可以使用如下的语法。 | ||
|
||
```markdown | ||
!!! dark "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! dark "标题" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
|
||
## 不设置标题 | ||
|
||
--- | ||
|
||
如果不设置标题,可将 `""` 内容设置为空字符串。 | ||
|
||
```markdown | ||
!!! info "" | ||
|
||
这是一个提示信息 | ||
|
||
!!! | ||
``` | ||
|
||
!!! info "" | ||
|
||
这是一个提示信息 | ||
|
||
!!! |
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,31 @@ | ||
--- | ||
title: 超链接 | ||
--- | ||
|
||
PageForge 支持 Markdown 的默认超链接语法。您可以使用 `[]()` 格式来创建链接,例如 `[链接文本](链接URL)`。 | ||
|
||
PageForge 实现了更多的语义,支持更多的超链接格式。 | ||
|
||
## 基本语法 | ||
|
||
--- | ||
|
||
``` | ||
[链接文本](链接URL) | ||
``` | ||
|
||
## 带标题 | ||
|
||
--- | ||
|
||
``` | ||
[链接文本](链接URL "可选标题") | ||
``` | ||
|
||
## 带打开方式 | ||
|
||
--- | ||
|
||
``` | ||
[链接文本](链接URL "可选标题" "打开方式") | ||
``` |
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,81 @@ | ||
--- | ||
title: 图片 | ||
--- | ||
|
||
PageForge 支持 Markdown 的默认图片语法。您可以使用 `` 格式来插入图片,例如 ``。 | ||
|
||
PageForge 实现了更多的语义,支持更多的图片格式。 | ||
|
||
## 基本语法 | ||
|
||
--- | ||
|
||
``` | ||
 | ||
``` | ||
|
||
## 带标题 | ||
|
||
--- | ||
|
||
``` | ||
 | ||
``` | ||
|
||
## 宽高格式 | ||
|
||
--- | ||
|
||
设置宽高的时候必须以 `=` 开始 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 | ||
|
||
只设置宽度 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 | ||
|
||
只设置高度 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 | ||
|
||
## 对齐方式 | ||
|
||
--- | ||
|
||
设置对齐方式的时候必须要设置宽高,支持的值有 `left` `center` `right` | ||
|
||
左对齐 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 | ||
|
||
中对齐 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 | ||
|
||
右对齐 | ||
|
||
``` | ||
 | ||
``` | ||
|
||
 |
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,90 @@ | ||
const {marked} = require("marked"); | ||
const {loadComponent} = require("../../component-loader"); | ||
|
||
const VALID_TYPES = ['info', 'danger', 'success', 'warning', 'dark']; | ||
|
||
const PageForgeAlertExtension = { | ||
name: 'pageforgeAlert', | ||
level: 'block', | ||
start(src) { | ||
return src.match(/^!!!\s/) ? 0 : -1; | ||
}, | ||
tokenizer(src, tokens) { | ||
// 分割成行来检查空行要求 | ||
const lines = src.split('\n'); | ||
|
||
// 1. 检查开始行格式 | ||
const firstLine = lines[0]; | ||
const startRule = /^!!!\s+(\w+)\s+"([^"]*)"$/; | ||
const match = firstLine.match(startRule); | ||
|
||
if (!match) { | ||
return false; | ||
} | ||
|
||
const [_, type, title] = match; | ||
|
||
if (!VALID_TYPES.includes(type)) { | ||
return false; | ||
} | ||
|
||
// 2. 查找结束标记 | ||
let endIndex = lines.findIndex((line, idx) => idx > 0 && line.trim() === '!!!'); | ||
if (endIndex === -1) { | ||
return false; | ||
} | ||
|
||
// 3. 验证格式要求 | ||
// 标题行后必须有空行 | ||
if (lines[1]?.trim() !== '') { | ||
return false; | ||
} | ||
|
||
// 结束标记前必须有空行 | ||
if (lines[endIndex - 1]?.trim() !== '') { | ||
return false; | ||
} | ||
|
||
// 4. 获取内容行(排除首尾空行) | ||
const contentLines = lines.slice(2, endIndex - 1); | ||
|
||
// 检查是否有内容及缩进 | ||
if (!contentLines.some(line => line.trim())) { | ||
return false; | ||
} | ||
|
||
// 检查所有非空行是否都有足够的缩进 | ||
if (!contentLines.every(line => line.trim() === '' || line.startsWith(' '))) { | ||
return false; | ||
} | ||
|
||
// 5. 处理内容(移除缩进) | ||
const content = contentLines | ||
.map(line => line.startsWith(' ') ? line.slice(4) : line) | ||
.join('\n') | ||
.trim(); | ||
|
||
// 6. 生成 tokens | ||
const contentTokens = this.lexer.blockTokens(content); | ||
|
||
return { | ||
type: 'pageforgeAlert', | ||
raw: lines.slice(0, endIndex + 1).join('\n'), | ||
alertType: type, | ||
title: title, | ||
content: content, | ||
tokens: contentTokens | ||
}; | ||
}, | ||
renderer(token) { | ||
const content = this.parser.parse(token.tokens); | ||
|
||
return loadComponent(`alert`, { | ||
type: token.alertType, | ||
title: token.title, | ||
content: content | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = PageForgeAlertExtension; |
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
Oops, something went wrong.