Skip to content

Commit

Permalink
feat: 代码块美化第一个版本
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 4, 2023
0 parents commit c5c5864
Show file tree
Hide file tree
Showing 30 changed files with 1,550 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
node_modules
dist
40 changes: 40 additions & 0 deletions .eslintrc.cjs
@@ -0,0 +1,40 @@
module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:svelte/recommended",
"turbo",
"prettier",
],

parser: "@typescript-eslint/parser",

overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
// Parse the script in `.svelte` as TypeScript by adding the following configuration.
parserOptions: {
parser: "@typescript-eslint/parser",
},
},
],

plugins: ["@typescript-eslint", "prettier"],

rules: {
// Note: you must disable the base rule as it can report incorrect errors
semi: "off",
quotes: "off",
"no-undef": "off",
"no-async-promise-executor": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"turbo/no-undeclared-env-vars": "off",
"prettier/prettier": "error",
},
}
39 changes: 39 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,39 @@
version: 2
updates:
# Fetch and update latest `npm` packages
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
reviewers:
- terwer
assignees:
- terwer
commit-message:
prefix: fix
prefix-development: chore
include: scope
labels:
- "npm dependencies"
- "npm"

# Fetch and update latest `github-actions` pkgs
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
reviewers:
- terwer
assignees:
- terwer
commit-message:
prefix: fix
prefix-development: chore
include: scope
labels:
- "github actions"
- "ci"
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches:
- dev

jobs:
build:
name: Build
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: pnpm/action-setup@v2.2.4
with:
version: 8

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm build

- name: Package
run: pnpm package
103 changes: 103 additions & 0 deletions .github/workflows/release-please.yml
@@ -0,0 +1,103 @@
on:
push:
branches:
- main

name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
# Create release
- name: Create release
uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: release-please-action
## branch to open pull release PR against (detected by default)
default-branch: main
## Should breaking changes before 1.0.0 produce minor bumps? Default false
bump-minor-pre-major: false
## Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default false
bump-patch-for-minor-pre-major: false
## If set, create releases that are pre-major or pre-release version marked as pre-release on GitHub. Defaults false
prerelease: false
## header used within the release PR body, defaults to using :robot: I have created a release *beep* *boop*
pull-request-header: ':robot: A new release will be created'
## A JSON formatted String containing to override the outputted changelog sections
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Code Refactoring","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"perf","section":"Performance Improvements","hidden":false}]'

# Checkout
- name: Checkout
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v3

# Install Node.js
- name: Install Node.js
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'

# Install pnpm
- name: Install pnpm
if: ${{ steps.release.outputs.release_created }}
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false

# Get pnpm store directory
- name: Get pnpm store directory
if: ${{ steps.release.outputs.release_created }}
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# Setup pnpm cache
- name: Setup pnpm cache
if: ${{ steps.release.outputs.release_created }}
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Install dependencies
- name: Install dependencies
if: ${{ steps.release.outputs.release_created }}
run: pnpm install

# Prepare new version
# https://github.com/google-github-actions/release-please-action#outputs
- name: Prepare new version
if: ${{ steps.release.outputs.release_created }}
run: |
pnpm prepareRelease
# Build for production
- name: Build for production
if: ${{ steps.release.outputs.release_created }}
run: pnpm build

# Archive package
- name: Archive package
if: ${{ steps.release.outputs.release_created }}
run: pnpm package

# Upload package to release
# https://github.com/philips-labs/terraform-aws-github-runner/blob/main/.github/workflows/release.yml#L46
- name: Upload package.zip to the release
if: ${{ steps.release.outputs.releases_created }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
ls -l ./build
for f in $(find ./build -name '*.zip'); do
gh release upload ${{ steps.release.outputs.tag_name }} $f
done
9 changes: 9 additions & 0 deletions .gitignore
@@ -0,0 +1,9 @@
.idea
.vscode
.DS_Store
pnpm-lock.yaml
package.zip
node_modules
dev
dist
build
11 changes: 11 additions & 0 deletions .prettierignore
@@ -0,0 +1,11 @@
# platform

# Ignore artifacts:
dist
node_modules

# Ignore all dts files:
*.d.ts

# lib
/pnpm-lock.yaml
31 changes: 31 additions & 0 deletions .prettierrc.cjs
@@ -0,0 +1,31 @@
/*
* 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,
plugins: ["prettier-plugin-svelte"]
}
Empty file added CHANGELOG.md
Empty file.
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 SiYuan 思源笔记

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 48 additions & 0 deletions README.md
@@ -0,0 +1,48 @@
[中文](README_zh_CN.md)

# siyuan-plugin-code-block

<img src="./icon.png" width="160" height="160" alt="icon">

Imitate the Mac-style code block style, and specially adapt to popular themes such as Rem Craft, Savor, Dark+, HBuilderX, etc.️

## FAQ

* Q1: What is the origin of this plugin?

A1: Refer to [Automatically add pinyin as aliases to new files](https://github.com/siyuan-note/siyuan/issues/8396). If the alias is automatically generated, after the alias search is enabled, the efficiency can be greatly improved. Because, you think, typing an English character or pinyin must be faster than Chinese characters, right?

* Q2: Can it be automatically generated when creating a new document?

A2: Yes. v0.0.3 supports automatic generation when renaming the title. Of course, you can also click the button on the top bar to generate.

* Q3: Why can't the automatically generated key be changed?

A3: This is for compatibility with subsequent publishing tools, and this key is actually only concerned by developers. Ordinary users have no obvious perception, it is just a convention. Of course, if there is a strong demand for changes, subsequent versions may also consider supporting custom named keys. Note: The key of non-custom attribute cannot be modified.

* Q4: How to enable alias search?

A4: Go to `Settings` -> `Search`, you can find the switch to enable alias search, you can choose naming, alias and custom attributes.

![](./assets/slug-setting.png)

## Donate

If you approve of this project, invite me to have a cup of coffee, which will encourage me to keep updating and create
more useful tools~

### Wechat

<div>
<img src="https://static-rs-terwer.oss-cn-beijing.aliyuncs.com/donate/wechat.jpg" alt="wechat" style="width:280px;height:375px;" />
</div>

### Alipay

<div>
<img src="https://static-rs-terwer.oss-cn-beijing.aliyuncs.com/donate/alipay.jpg" alt="alipay" style="width:280px;height:375px;" />
</div>

## Thanks

Thanks to [frostime](https://github.com/siyuan-note/plugin-sample-vite-svelte) for the project template
35 changes: 35 additions & 0 deletions README_zh_CN.md
@@ -0,0 +1,35 @@
[English](README.md)

# 代码块美化

<img src="./icon.png" width="160" height="160" alt="icon">

模仿Mac风格的代码块风格,并且对Rem Craft、Savor、Dark+、HBuilderX等热门主题进行专门适配

## FAQ

* Q1:怎么使用?需要操作按钮吗?

A1:本插件没有操作按钮。下载并启用插件之后,打开文档,代码块就自动美化成 Mac 风格。没了。

如果你不想用这个插件,可直接使用 [Zhihu主题](https://github.com/terwer/siyuan-theme-zhihu) 或者自行去抠 [代码块](https://github.com/terwer/siyuan-theme-zhihu/tree/main/style/theme/code-block) 相关的css。

## 捐赠

如果您认可这个项目,请我喝一杯咖啡吧,这将鼓励我持续更新,并创作出更多好用的工具~

### 微信

<div>
<img src="https://static-rs-terwer.oss-cn-beijing.aliyuncs.com/donate/wechat.jpg" alt="wechat" style="width:280px;height:375px;" />
</div>

### 支付宝

<div>
<img src="https://static-rs-terwer.oss-cn-beijing.aliyuncs.com/donate/alipay.jpg" alt="alipay" style="width:280px;height:375px;" />
</div>

## 感谢

感谢 [frostime](https://github.com/siyuan-note/plugin-sample-vite-svelte) 提供的项目模板
Binary file added icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c5c5864

Please sign in to comment.