Skip to content

Commit

Permalink
docs: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 16, 2023
1 parent b9fabc6 commit 6af39e7
Show file tree
Hide file tree
Showing 39 changed files with 1,196 additions and 4,741 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [X] [zhi-common](https://github.com/terwer/zhi/tree/main/libs/zhi-common)
- [ ] [zhi-common-basic](https://github.com/terwer/zhi/tree/main/libs/zhi-common-basic)
- [ ] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate)
- [ ] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown)
- [X] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown)
- [ ] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version)
- [X] [zhi-blog-api](https://github.com/terwer/zhi/tree/main/libs/zhi-blog-api)
- [X] [zhi-xmlrpc-middleware](https://github.com/terwer/zhi/tree/main/libs/zhi-xmlrpc-middleware)
Expand Down
2 changes: 1 addition & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- [X] [zhi-common](https://github.com/terwer/zhi/tree/main/libs/zhi-common)
- [ ] [zhi-common-basic](https://github.com/terwer/zhi/tree/main/libs/zhi-common-basic)
- [ ] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate)
- [ ] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown)
- [X] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown)
- [ ] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version)
- [X] [zhi-blog-api](https://github.com/terwer/zhi/tree/main/libs/zhi-blog-api)
- [X] [zhi-xmlrpc-middleware](https://github.com/terwer/zhi/tree/main/libs/zhi-xmlrpc-middleware)
Expand Down
15 changes: 15 additions & 0 deletions libs/zhi-blog-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# zhi-blog-api

## 1.6.10

### Patch Changes

- fix deps
- Updated dependencies
- zhi-lib-base@0.4.1

## 1.6.9

### Patch Changes

- Updated dependencies
- zhi-lib-base@0.4.0

## 1.6.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-blog-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-blog-api",
"version": "1.6.8",
"version": "1.6.10",
"type": "module",
"description": "a common blog interface",
"main": "./dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions libs/zhi-common-markdown/.env.development.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_DEBUG_MODE=true
4 changes: 4 additions & 0 deletions libs/zhi-common-markdown/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
}
2 changes: 2 additions & 0 deletions libs/zhi-common-markdown/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.DS_Store
11 changes: 11 additions & 0 deletions libs/zhi-common-markdown/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# platform

# Ignore artifacts:
dist
node_modules

# Ignore all dts files:
*.d.ts

# lib
/pnpm-lock.yaml
30 changes: 30 additions & 0 deletions libs/zhi-common-markdown/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

module.exports = {
semi: false,
singleQuote: false,
printWidth: 120
}
20 changes: 20 additions & 0 deletions libs/zhi-common-markdown/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# zhi-common-markdown

## 0.1.1

### Patch Changes

- fix deps
- Updated dependencies
- zhi-lib-base@0.4.1

## 0.1.0

### Minor Changes

- fix log msg

### Patch Changes

- Updated dependencies
- zhi-lib-base@0.4.0
41 changes: 41 additions & 0 deletions libs/zhi-common-markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# zhi-common-markdown

a universal Markdown parsing tool

## Usage

```js
// usage
```

## Deps

```
## Congregations! zhi-common-markdown need no deps, it is just pure js code 🎉
```

## Dev

```bash
pnpm dev -F zhi-common-markdown
```

## Build

```bash
pnpm build -F zhi-common-markdown
```

## Test

Execute the unit tests via [vitest](https://vitest.dev)

```bash
pnpm test -F zhi-common-markdown
```

## Publish

```bash
pnpm publish -F zhi-common-markdown --tag latest
```
12 changes: 12 additions & 0 deletions libs/zhi-common-markdown/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
This file is for lib hot-load test only, see <a href="/src/index.ts">/src/index.ts</a>
<script type="module" src="/src/index.ts"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions libs/zhi-common-markdown/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "zhi-common-markdown",
"version": "0.1.1",
"type": "module",
"description": "a universal Markdown parsing tool",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown",
"author": "terwer",
"license": "MIT",
"files": [
"dist",
"README.md"
],
"keywords": [
"zhi",
"lib"
],
"scripts": {
"serve": "vite",
"dev": "vite build --watch",
"build": "vite build",
"start": "vite preview",
"test": "npx vitest --watch"
},
"devDependencies": {
"@terwer/eslint-config-custom": "^1.2.0",
"@terwer/vite-config-custom": "^0.5.0",
"@types/showdown": "^2.0.1"
},
"dependencies": {
"showdown": "^2.1.0",
"zhi-lib-base": "workspace:*"
},
"publishConfig": {
"access": "public"
}
}

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions libs/zhi-common-markdown/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import { describe, it } from "vitest"

describe("index", () => {
it("test index", () => {
console.log("hello")
})
})
27 changes: 27 additions & 0 deletions libs/zhi-common-markdown/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import MarkdownUtil from "./lib/markdownUtil"
export { MarkdownUtil }
41 changes: 41 additions & 0 deletions libs/zhi-common-markdown/src/lib/markdownUtil.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import { describe, it, expect } from "vitest"
import path from "path"
import MarkdownUtil from "./markdownUtil"

describe("markdownUtil", () => {
const moduleBase = path.resolve(__dirname, "../../../..")
// lute
require(path.join(moduleBase, "libs/zhi-common-markdown/public/libs/lute/lute-1.7.5-20230410.min.cjs"))

it("test renderHTML", async () => {
const markdownUtil = new MarkdownUtil()
const result = await markdownUtil.renderHTML("# hello")
console.log(result)
expect(result).toBe("<h1>hello</h1>\n")
})
})
75 changes: 75 additions & 0 deletions libs/zhi-common-markdown/src/lib/markdownUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2023, Terwer . All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Terwer designates this
* particular file as subject to the "Classpath" exception as provided
* by Terwer in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
* or visit www.terwer.space if you need additional information or have any
* questions.
*/

import LuteAdaptor from "./md-adaptor/LuteAdaptor"
import ShowdownAdaptor from "./md-adaptor/ShowdownAdaptor"
import MarkdownAdaptor from "./md-adaptor/MarkdownAdaptor"
import { simpleLogger } from "zhi-lib-base"

/**
* Markdown 处理工具类
*
* @author terwer
* @version 1.0.0
* @since 1.0.0
*/
class MarkdownUtil {
private readonly logger
private mdAdaptor: MarkdownAdaptor = new ShowdownAdaptor()

constructor() {
this.logger = simpleLogger("markdown-util", "zhi-common-markdown", false)
}

/**
* 获取当前 MD 解析器名称
*/
private getCurrentAdaptorName() {
if (this.mdAdaptor instanceof LuteAdaptor) {
return "Lute"
} else if (this.mdAdaptor instanceof ShowdownAdaptor) {
return "Showdown"
}
return "None"
}

/**
* 渲染Markdown
*
* @param md - Markdown文本
*/
public async renderHTML(md: string): Promise<string> {
const luteNew = new LuteAdaptor()
this.logger.debug("Lute status =>", luteNew.isAvailable())
if (luteNew.isAvailable()) {
this.mdAdaptor = luteNew
}

this.logger.info(`Using ${this.getCurrentAdaptorName()} as markdown renderer`)
return await this.mdAdaptor.renderMarkdownStr(md)
}
}

export default MarkdownUtil
Loading

0 comments on commit 6af39e7

Please sign in to comment.