Cobertos / md2notion

A better Notion.so Markdown importer
MIT License
654 stars 65 forks source link

Is it possible processing markdown strings instead of md files? #23

Closed realCrush closed 3 years ago

realCrush commented 3 years ago

Is it possible processing markdown strings instead of md files? On my server backend, if I can processing markdown strings instead of md files, time delay would be hugely reduced, because don't have to do I/O operations, is it possible?

Cobertos commented 3 years ago

If you're writing a script yourself, then yes, convert takes a file or a string

def convert(mdFile, notionPyRendererCls=NotionPyRenderer):
    """
    Converts a mdFile into an array of NotionBlock descriptors
    @param {file|string} mdFile The file handle to a markdown file, or a markdown string
    @param {NotionPyRenderer} notionPyRendererCls Class inheritting from the renderer
    incase you want to render the Markdown => Notion.so differently
    """

If you're using the CLI, then no, there's currently no way to use stdin to read the markdown text unfortunately

realCrush commented 3 years ago

If you're writing a script yourself, then yes, convert takes a file or a string

def convert(mdFile, notionPyRendererCls=NotionPyRenderer):
    """
    Converts a mdFile into an array of NotionBlock descriptors
    @param {file|string} mdFile The file handle to a markdown file, or a markdown string
    @param {NotionPyRenderer} notionPyRendererCls Class inheritting from the renderer
    incase you want to render the Markdown => Notion.so differently
    """

If you're using the CLI, then no, there's currently no way to use stdin to read the markdown text unfortunately

thanks, I will try later 😄