Skip to content

/api/convert

pandoc

  • 🔥 使用 Pandoc 进行文件转换
  • /api/convert/pandoc

请求

ts
/**
 * execute pandoc command to convert file
 */
export interface IPayload {
    /**
     * pandoc command-line parameter list
     */
    readonly args: string[];
    /**
     * working directory name
     * workspace/temp/convert/pandoc/:dir
     * If not set, a random directory name is used
     */
    readonly dir?: string;
}
json5
/**
 * schemas/kernel/api/convert/pandoc/payload.schema.json5
 * 调用 pandoc 转换文件
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#pandoc
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/pandoc.go#L27-L59
 * @pathname: /api/convert/pandoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/convert/pandoc/payload.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'execute pandoc command to convert file',
            type: 'object',
            additionalProperties: false,
            required: [
                'args',
            ],
            properties: {
                args: {
                    type: 'array',
                    description: 'pandoc command-line parameter list',
                    items: {
                        type: 'string',
                    },
                },
                dir: {
                    // 可选参数, 如果未设置则使用随机目录名称
                    type: 'string',
                    description: 'working directory name\nworkspace/temp/convert/pandoc/:dir\nIf not set, a random directory name is used',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/convert/pandoc/payload.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "execute pandoc command to convert file",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "args"
            ],
            "properties": {
                "args": {
                    "type": "array",
                    "description": "pandoc command-line parameter list",
                    "items": {
                        "type": "string"
                    }
                },
                "dir": {
                    "type": "string",
                    "description": "working directory name\nworkspace/temp/convert/pandoc/:dir\nIf not set, a random directory name is used"
                }
            }
        }
    }
}

响应

ts
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * response data
 */
export interface IData {
    /**
     * the path of output file under the workspace
     */
    readonly path: string;
}
json5
/**
 * schemas/kernel/api/convert/pandoc/payload.schema.json5
 * 调用 pandoc 转换文件
 * REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#pandoc
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/pandoc.go#L27-L59
 * @pathname: /api/convert/pandoc
 * @version: 2.9.3
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/convert/pandoc/response.schema.json5',
    $comment: 'v2.9.3',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: '',
            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'response data',

            type: 'object',
            additionalProperties: false,
            required: [
                'path',
            ],
            properties: {
                path: {
                    // 相对于工作空间目录的路径
                    type: 'string',
                    description: 'the path of output file under the workspace',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/convert/pandoc/response.schema.json",
    "$comment": "v2.9.3",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "response data",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "path"
            ],
            "properties": {
                "path": {
                    "type": "string",
                    "description": "the path of output file under the workspace"
                }
            }
        }
    }
}