Help us shape the future of Go! Take the 2026 Go Developer Survey

markdown

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package markdown 为 converter 注册 Markdown→OFD 导入器(输入格式 "markdown")。

该包依赖 internal/layout 与 goldmark,单独成包是为了让只做 OFD→X 的使用方 不必链接这些依赖;需要 Markdown→OFD 时按空白导入启用:

import _ "github.com/zc310/ofd/pkg/converter/import/markdown"

之后即可使用 converter.Convert(ctx, "md", "ofd", ...)。出于安全和确定性考虑, 远程图片不会被下载,只在日志中给出警告。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(ctx context.Context, input any, output io.Writer) error

Convert 将 Markdown 输入转换为 OFD,input 支持文件路径、[]byte 或 io.Reader。 传入文件路径时会以该文件所在目录解析相对图片路径;在主要处理阶段之间响应取消。

Example
package main

import (
	"bytes"
	"context"
	"fmt"

	markdown "github.com/zc310/ofd/pkg/converter/import/markdown"
)

func main() {
	var output bytes.Buffer
	err := markdown.Convert(context.Background(), []byte("# 标题\n\n正文"), &output)
	fmt.Println(err == nil)
	fmt.Println(bytes.HasPrefix(output.Bytes(), []byte("PK")))
}
Output:
true
true

func ConvertFile

func ConvertFile(ctx context.Context, mdPath, ofdPath string) (err error)

ConvertFile 是 Convert 的按路径便捷形式。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL