package org.dromara.knowledge.data;

import org.dromara.common.core.exception.ServiceException;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * Markdown 文档解析器
 * 直接返回 Markdown 文本内容，保留格式供后续处理
 *
 * @author pengles
 */
@Component
public class MarkdownDocumentParser implements DocumentParser {
    @Override
    public String parse(byte[] bytes, String filename) {
        try {
            return new String(bytes, StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new ServiceException("Markdown解析失败: " + e.getMessage());
        }
    }
}
