mermaid2conf

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Markdown To Confluence

Markdown 转 Confluence

Pre-Requisites

前提条件

  1. Confirm
    uv
    is installed
    shell
    command -v "uv" || echo "NOT INSTALLED"
    If
    uv
    is not installed prompt for approval to install
    uv
    shell
      curl -LsSf https://astral.sh/uv/install.sh | sh
  2. Confirm
    mermaid-cli
    is installed
    shell
    npm list -g @mermaid-js/mermaid-cli || echo "NOT INSTALLED" 
    If
    mermaid-cli
    is not installed prompt for approval to install
    uv
    shell
      npm install -g @mermaid-js/mermaid-cli
  3. Confirm confluence configuration exists
    shell
    [ -f ~/.config/markdown-to-confluence/confluence_config.json ] && echo "Exists" || echo "Does not exist" 
    If Confluence Configuration file does not exist, direct user to visit Configure Confluence Credentials and terminate
  1. 确认已安装
    uv
    shell
    command -v "uv" || echo "NOT INSTALLED"
    如果未安装
    uv
    ,请确认是否同意安装
    uv
    shell
      curl -LsSf https://astral.sh/uv/install.sh | sh
  2. 确认已安装
    mermaid-cli
    shell
    npm list -g @mermaid-js/mermaid-cli || echo "NOT INSTALLED" 
    如果未安装
    mermaid-cli
    ,请确认是否同意安装
    mermaid-cli
    shell
      npm install -g @mermaid-js/mermaid-cli
  3. 确认Confluence配置文件已存在
    shell
    [ -f ~/.config/markdown-to-confluence/confluence_config.json ] && echo "Exists" || echo "Does not exist" 
    如果Confluence配置文件不存在,请引导用户访问配置Confluence凭据并终止操作

Inputs

输入信息

  1. Ask the user for the path to the markdown file. Wait for their response before proceeding. This value will be referred to by $SOURCE_MD
  2. Read the $SOURCE_MD markdown file and check for YAML frontmatter with:
  • confluence_url
    ($CONFLUENCE_URL)
  1. If
    confluence_url
    is not present in the YAML frontmatter, prompt the user for a Confluence url ($CONFLUENCE_URL)
    1. Extract the $PAGE_ID from $CONFLUENCE_URL - it is the numeric segment after
      /pages/
      in the path.
    2. Extract the $SECTION_NAME from $CONFLUENCE_URL - it is the string after
      #
      at the end of the URL
      • If not found, use an empty string instead ""
  1. 询问用户Markdown文件的路径,等待用户回复后再继续。该路径将用$SOURCE_MD表示
  2. 读取$SOURCE_MD对应的Markdown文件,检查是否包含带有以下内容的YAML前置信息:
  • confluence_url
    ($CONFLUENCE_URL)
  1. 如果YAML前置信息中没有
    confluence_url
    ,请提示用户输入Confluence地址($CONFLUENCE_URL)
    1. 从$CONFLUENCE_URL中提取$PAGE_ID - 即路径中
      /pages/
      之后的数字部分
    2. 从$CONFLUENCE_URL中提取$SECTION_NAME - 即URL末尾
      #
      之后的字符串
      • 如果未找到,则使用空字符串""

Execution

执行步骤

Substitute all variable references with their exact values
  1. Process the mermaid diagram
    shell
    uvx mermaid2conf process "$SOURCE_MD"
  2. Publish the document to confluence
    shell
    uvx mermaid2conf publish "$PAGE_ID" "$SECTION_NAME"
将所有变量替换为对应的确切值
  1. 处理Mermaid图表
    shell
    uvx mermaid2conf process "$SOURCE_MD"
  2. 将文档发布到Confluence
    shell
    uvx mermaid2conf publish "$PAGE_ID" "$SECTION_NAME"