跳至主要內容

Processor class

LincZero大约 8 分钟

The first three chapters introduce the various selectors, focusing on the list text to tree structure of the graph

Processor class

More Processor(Decorate Processor)

Block Name

This is quite useful and high frequency,and I gave you a grammar candy: start with # Give the block a name, and you can automatically identify the type of the modified block. It can easily be:

  • Add to table: Center table title
  • Add to code: filename

Table heading

table heading

1

2

3

4

code file name

According to the reason, the file name should be the same color as the code block. If the color is different, I will adjust it in the css file. find --pre-background-color ,at css file the fifth line,just change the color value. (Tried using js to get code block color again, but failed)

#include <stdio.h>

int main()
{
    printf("Hello, World! \n");

    return 0;
}

ohter block name

111 222

  • 1
    • 2
      • 3
    • 2

fold

This is the code I used to force the list2table effect with dataviewjs before writing anyblock. The content is long, so here to demonstrate

展开

const lines = files .filter((file) => { // 本篇笔记 return file.path == dv.current().file.path }) .map(async (file) => { // 转列表 const content = await app.vault.cachedRead(file)
const lines = content.split("\n") return lines })

Promise.all(lines).then(linesTmp => { let lines = linesTmp.flat()

// 先搜索关键词
let index = 0
for(let i=0; i<lines.length; i++){
	if(lines[i].contains(keyword)){
		index = i
		break
	}
}

// 获取参数
const args = lines[index].replace(keyword, "").replace(/^|/, "").split("|")


// 先不考虑异常缩进了
let levelArr = []
let contentArr = []
for(let i=index+1; i<lines.length; i++){
	if(/^\s*?-\s(.*?)/.test(lines[i])){
		contentArr.push(lines[i].replace(/^\s*?-\s/, ""))
		levelArr.push(lines[i].replace(/-\s(.*?)$/, "").length/2)
	}
	else{
		break
	}
}

// 再弄成正确的层次关系,暂时先只考虑三层
let tableData = []
let lastArr = []
let lastLevel = 0
for(let i=0; i<levelArr.length; i++){
	if(levelArr[i]==0){
		if(lastArr.length!=0) {// 是否不为第一个数据
			tableData.push(lastArr)
			lastArr = []
		}
		lastLevel = 0
		lastArr.push(contentArr[i])
	}
	else if(levelArr[i]==1){
		if (lastLevel<1){ // 是否新起一行
			lastArr.push(contentArr[i])
			lastLevel = 1
		}
		else{
			tableData.push(lastArr)
			lastArr = []
			lastLevel = 1
			lastArr.push("^^")
			lastArr.push(contentArr[i])
		}
	}
	else if(levelArr[i]==2){
		if (lastLevel<2){ // 是否新起一行
			lastArr.push(contentArr[i])
			lastLevel = 2
		}
		else{
			tableData.push(lastArr)
			lastArr = []
			lastLevel = 2
			lastArr.push("^^")
			lastArr.push("^^")
			lastArr.push(contentArr[i])
		}
	}
}
tableData.push(lastArr)
lastArr = []

console.log(tableData)
dv.table(args, tableData)

})


## Overflow folding

Like many blogs, there are overflow collapses of code blocks. AnyBlock also has this processor, whether it's a block of code or something else.
**Notes are useful when writing down long blocks of code**
(@todo This does not match the light pattern, and does not necessarily match the user's code block background)

[overfold]
```js
const&nbsp;keyword&nbsp;=&nbsp;"%"+"toTable" // 不能合并
const&nbsp;files&nbsp;=&nbsp;app.vault.getMarkdownFiles()


const&nbsp;lines&nbsp;=&nbsp;files
	.filter((file) => {  // 本篇笔记
		return file.path == dv.current().file.path
	})
	.map(async&nbsp;(file)&nbsp;=>&nbsp;{  // 转列表
		const&nbsp;content&nbsp;=&nbsp;await&nbsp;app.vault.cachedRead(file)  
		const&nbsp;lines&nbsp;=&nbsp;content.split("\n")
		return&nbsp;lines
	})
	
Promise.all(lines).then(linesTmp&nbsp;=> {
	let lines = linesTmp.flat()

	// 先搜索关键词
	let index = 0
	for(let i=0; i<lines.length; i++){
		if(lines[i].contains(keyword)){
			index = i
			break
		}
	}
	
	// 获取参数
	const args = lines[index].replace(keyword, "").replace(/^|/, "").split("|")
	

	// 先不考虑异常缩进了
	let levelArr = []
	let contentArr = []
	for(let i=index+1; i<lines.length; i++){
		if(/^\s*?-\s(.*?)/.test(lines[i])){
			contentArr.push(lines[i].replace(/^\s*?-\s/, ""))
			levelArr.push(lines[i].replace(/-\s(.*?)$/, "").length/2)
		}
		else{
			break
		}
	}

	// 再弄成正确的层次关系,暂时先只考虑三层
	let tableData = []
	let lastArr = []
	let lastLevel = 0
	for(let i=0; i<levelArr.length; i++){
		if(levelArr[i]==0){
			if(lastArr.length!=0) {// 是否不为第一个数据
				tableData.push(lastArr)
				lastArr = []
			}
			lastLevel = 0
			lastArr.push(contentArr[i])
		}
		else if(levelArr[i]==1){
			if (lastLevel<1){ // 是否新起一行
				lastArr.push(contentArr[i])
				lastLevel = 1
			}
			else{
				tableData.push(lastArr)
				lastArr = []
				lastLevel = 1
				lastArr.push("^^")
				lastArr.push(contentArr[i])
			}
		}
		else if(levelArr[i]==2){
			if (lastLevel<2){ // 是否新起一行
				lastArr.push(contentArr[i])
				lastLevel = 2
			}
			else{
				tableData.push(lastArr)
				lastArr = []
				lastLevel = 2
				lastArr.push("^^")
				lastArr.push("^^")
				lastArr.push(contentArr[i])
			}
		}
	}
	tableData.push(lastArr)
	lastArr = []
	
	console.log(tableData)
	dv.table(args, tableData)
})  

大类型

解析方法

解析方法zh

渲染方法

渲染方法zh

可转md/html

tree

ul-list

ul树 (一叉多层树)

2ut/2mdut

转表格(规范)

md/html

li-list

li树 (一叉多层树)

2lt/mdlt

转列表格

html

ab-tree

二层树 也叫 "消除最高级" (一叉二层树)

2timeline

转时间线

mermaid

2tab

转标签栏

html

2chat

转对话

tree-list

树列表 (多叉多层树)

2table/2mdtable

转树表格

html

2mermaid

转流程图

mermaid/html

2mindmap

转思维导图

html

2tree

长得像树的树状图

html

2xuri

旭日图

html

2brace

括弧分类图

html

other

title

标题级(语法糖)

2list+list2xxx

(组合使用,下面提供了几种语法糖)

2tab

2table

2mindmap

code

一定代码

2doctable

转表格(文档生成)

html

json

这个不能转树,只能说转可折叠渲染

common

通用

text

纯文本

md

md

md渲染

md

render

渲染 (理论上为 "渲染修饰器" 但该功能没做)

flod

(折叠类)可折叠

md+

hide

(折叠类)默认折叠

md+

heimu

(折叠类)黑幕遮挡

html

limit()/part()

(折叠类)限高折叠

html

scroll()

(折叠类)限高滚动

html

title()

增加块标题(代码块可能会很常用)

展开

Scroll

The default is to scroll beyond 460px,The processor can also accept arguments,scroll(How much more becomes a roll),Parameters do not need to be added px

const keyword = "%"+"toTable" // 不能合并
const files = app.vault.getMarkdownFiles()

const lines = files .filter((file) => { // 本篇笔记 return file.path == dv.current().file.path }) .map(async (file) => { // 转列表 const content = await app.vault.cachedRead(file)
const lines = content.split("\n") return lines })

Promise.all(lines).then(linesTmp => { let lines = linesTmp.flat()

// 先搜索关键词
let index = 0
for(let i=0; i<lines.length; i++){
	if(lines[i].contains(keyword)){
		index = i
		break
	}
}

// 获取参数
const args = lines[index].replace(keyword, "").replace(/^|/, "").split("|")


// 先不考虑异常缩进了
let levelArr = []
let contentArr = []
for(let i=index+1; i<lines.length; i++){
	if(/^\s*?-\s(.*?)/.test(lines[i])){
		contentArr.push(lines[i].replace(/^\s*?-\s/, ""))
		levelArr.push(lines[i].replace(/-\s(.*?)$/, "").length/2)
	}
	else{
		break
	}
}

// 再弄成正确的层次关系,暂时先只考虑三层
let tableData = []
let lastArr = []
let lastLevel = 0
for(let i=0; i<levelArr.length; i++){
	if(levelArr[i]==0){
		if(lastArr.length!=0) {// 是否不为第一个数据
			tableData.push(lastArr)
			lastArr = []
		}
		lastLevel = 0
		lastArr.push(contentArr[i])
	}
	else if(levelArr[i]==1){
		if (lastLevel<1){ // 是否新起一行
			lastArr.push(contentArr[i])
			lastLevel = 1
		}
		else{
			tableData.push(lastArr)
			lastArr = []
			lastLevel = 1
			lastArr.push("^^")
			lastArr.push(contentArr[i])
		}
	}
	else if(levelArr[i]==2){
		if (lastLevel<2){ // 是否新起一行
			lastArr.push(contentArr[i])
			lastLevel = 2
		}
		else{
			tableData.push(lastArr)
			lastArr = []
			lastLevel = 2
			lastArr.push("^^")
			lastArr.push("^^")
			lastArr.push(contentArr[i])
		}
	}
}
tableData.push(lastArr)
lastArr = []

console.log(tableData)
dv.table(args, tableData)

})


## black curtain

It is similar to the dark screen effect of Mengniang Encyclopedia

[X|addClass(ab-deco-heimu)]
> This is a piece of content that cannot be seen directly
> ...
> ...

## add class / add div

`addClass` (Adds a class name to the current block)、`addDiv` (Append a parent element and append a class name to the parent element)
This can be used to add a custom style to the block (like an `ad` plugin) that can be extended by users who know CSS

# Custom processor

A few processor configurations are recommended to know how to use them.
id and name are arbitrary. Let me show you

[2table]
- Registry matching name| The register is replaced with
- quote|     add([!quote])|quote
- fold |     add([!note]-|qutoe)
- `/mindmap(.*?)/`| rootlist(%1)|mindmap

`%n` ndicates that the n TH match in the regular is replaced at this position
In the example of the map above,`mindmap(name)` will being `rootlist(name)|mindmap`

The functionality is relatively simple and less powerful than adding processors in code. But by combining registries, you can still make nice customization

# More

## FAQ

[Xcode|FAQ]

Q:Midjourney是什么?https://www.midjourney.com/

A:一个AI 生成算图工具,只需输入文字就会自动产生图像,Midjourney目前架设在Discord频道上,因此需要有Discord帐号才能使用。

Q:Discord是什么?https://discord.com/

A:一款专为社群设计的免费通讯社交软体,类似于LINE或Slack,但功能更为强大,自带机器人与各种程式功能,能够在上面发开自己工具,有网页版与手机版App。.

Q:Midjourney是软件吗?需要安装吗?

A:不用,Midjourney并不是软件,也不用安装,它是一个架设在Discord之下的工具,使用方式只需要在Discord输入文字即可,所以与你电脑本身效能无关,运算中关闭Midjourney也没问题,因为真正运算图片的是云端电脑。.

Q:要如何进入Midjourney?

A:目前Midjourney还在Beta封测阶段,需有邀请码才能进入.

Q:如何获得邀请码?

A:目前有2种方式,官网申请,朋友邀请

【官网申请】https://www.midjourney.com这个网址是官方网站,点选「Apply for the Beta」,填写表格即可,如果通过申请官方就会寄邀请码到你信箱,审核时间不一定,有可能很久

【朋友邀请】已经订阅10美金或30美金的使用者会获得5个邀请码,有邀请码的人可以产生邀请链接给其他人,你可以使用这些邀请链接进入Midjourney频道,目前已知一个邀请连结只能给一个人使用,所以如果邀请连结公开,通常这个连结很快会被抢走,后面再点连结的人自然就无法邀请进入,因此建议邀请连结都私下传送。另外特别注意,目前产生邀请码有24小时的时效性,如果这个连结超过24小时没人使用,会自动失效,建议要邀请人的时候再产生邀请吗。

需要【朋友邀请】的可以私信我,有少量码出

Q:已经在Midjourney频道的人可以邀请我进入吗?

A:不行,官方把这个功能锁起来,只能透过邀请连结进入.

Q:如果愿意直接付费,是否也要等邀请码才能购买呢?

A:对,要先有邀请码才能进Midjourney,进Midjourney后才能购买.

Q:想问Midjourney跟Disco Diffusion的差别?

A:运算速度跟运算成果,我觉得都是Midjourney比较好,不需要安装程式码等复杂操作,比较好上手,Disco Diffusion目前最大优势是可以算动画,希望Midjourney之后能追加这功能。.

Q:等不到Midjourney邀请码怎么办?

A:或许可以尝试看看Disco Diffusion,至少它不用排队,或者找我邀请你加入Midjourney