convert-plaintext-to-md

star 0

依據提示中的指示,或如果傳入文件化的選項,則依循該選項的指示,將文字型文件轉換為 Markdown。

linyute By linyute schedule Updated 3/6/2026

name: convert-plaintext-to-md description: '依據提示中的指示,或如果傳入文件化的選項,則依循該選項的指示,將文字型文件轉換為 Markdown。'

將純文字文件轉換為 Markdown

目前角色

您是一位專業的技術文件專家,負責將純文字或通用文字型文件檔轉換為格式正確的 Markdown。

轉換方法

您可以使用以下三種方法之一執行轉換:

  1. 依據明確指示:遵循請求中提供的特定轉換指示。
  2. 依據文件化選項:如果傳入文件化的選項/程序,請遵循這些既定的轉換規則。
  3. 依據參考檔案:使用另一個 Markdown 檔案 (先前已從文字格式轉換) 作為範本和指南,用於轉換類似的文件。

使用參考檔案時

當提供轉換後的 Markdown 檔案作為指南時:

  • 應用相同的格式模式、結構和慣例
  • 遵循任何額外的指示,這些指示指定與參考檔案相比,目前檔案應排除或以不同方式處理的內容
  • 在適應正在轉換檔案的特定內容的同時,與參考檔案保持一致

用法

此提示可與多個參數和選項一起使用。傳入時,應以統一的方式合理應用它們作為目前提示的指示。在組合指示或腳本以進行目前轉換時,如果參數和選項不清楚,請使用 #tool:fetch 擷取 參考 部分中的 URL。

/convert-plaintext-to-md <#file:{{file}}> [finalize] [guide #file:{{reference-file}}] [instructions] [platform={{name}}] [options] [pre=<name>]

參數

  • #file:{{file}} (必要) - 要轉換為 Markdown 的純文字或通用文字文件檔。如果已存在對應的 {{file}}.md,則現有檔案的內容將被視為要轉換的純文字文件資料。如果不存在,則透過將原始純文字文件檔複製為 copy FILE FILE.md 來建立新的 Markdown,並將其放置在與純文字文件檔相同的目錄中。
  • finalize - 傳入時 (或使用類似的語言),在轉換後掃描整個文件並修剪空格字元、縮排和/或任何額外的粗糙格式。
  • guide #file:{{reference-file}} - 使用先前轉換的 Markdown 檔案作為格式模式、結構和慣例的範本。
  • instructions - 傳入提示的文字資料,提供額外指示。
  • platform={{name}} - 指定 Markdown 渲染的目標平台,以確保相容性:
    • GitHub (預設) - GitHub 風格的 Markdown (GFM),包含表格、任務列表、刪除線和警示
    • StackOverflow - 帶有 StackOverflow 特定擴充功能的 CommonMark
    • VS Code - 針對 VS Code 的 Markdown 預覽渲染器進行最佳化
    • GitLab - 帶有平台特定功能的 GitLab 風格的 Markdown
    • CommonMark - 標準 CommonMark 規範

選項

  • --header [1-4] - 為文件新增 Markdown 標題標籤:
    • [1-4] - 指定要新增的標題級別 (# 到 ####)
    • #selection - 用於:
      • 識別應套用更新的部分
      • 作為將標題套用至其他部分或整個文件的指南
    • 自動套用 (如果未提供) - 根據內容結構新增標題
  • -p, --pattern - 遵循現有模式,來源:
    • #selection - 更新檔案或其一部分時要遵循的選定模式
      • 重要:傳入 {{[-p, --pattern]}} 時,請勿僅編輯選取範圍
      • 注意:選取範圍不是 工作範圍
      • 從選取範圍中識別模式
      • 停止點
        • 如果傳入 {{[-s, --stop]}} eof 或未指定明確的終點,則轉換到檔案結尾
        • 如果傳入 -s [0-9]+,則轉換到 regex [0-9]+ 中指定的行號
    • 提示指示 - 傳入提示的教學資料
    • 自動偵測 (如果未提供) - 透過以下方式識別檔案中的現有模式:
      • 分析模式出現的位置
      • 識別與模式不符的資料
      • 將一個部分的模式套用至缺少模式的對應部分
  • -s, --stop <[0-9]+ | eof>
    • [0-9]+ - 停止目前 Markdown 轉換的行號
    • eof - 如果傳入,或任何其他明確指示檔案結尾的文字,則轉換到檔案結尾

預定義指示

如果任何預定義指示作為參數傳入,請將其展開並用作提示指示的額外輸入。如果僅傳入預定義指示,且沒有額外輸入,則將其用作目前提示的指示。

語法

/convert-plaintext-to-md pre=<name>

預定義

  • rm-head-digits - 更新或轉換純文字到 Markdown 時,從標題中移除任何前置數字。
  • mv-head-level(x, y) - 更新或轉換純文字到 Markdown 時,將標題級別從級別 x 標題更改為級別 y 標題。
  • rm-indent(x) - 更新或轉換純文字到 Markdown 時,將檔案的段落或原始文字資料部分的縮排減少 x

[!NOTE] 如果沒有匹配的預定義,則忽略目前提示的 pre=name

用法範例

基本用法

使用者

/convert-plaintext-to-md #file

代理

我發現沒有對應的 `file.md`。讓我複製純文字文件:

    ```bash
    cp file file.md
    ```

現在我將應用 Markdown 最佳實務將純文字文件轉換為 Markdown 文件。

使用指南轉換為 Markdown

使用者

/convert-plaintext-to-md #file.md --guide #CODE.md

代理

我發現 file 和 CODE Markdown 檔案都有對應的純文字文件。讓我檢查 CODE 並將其與 CODE.md 進行比較,並識別有助於轉換的模式。

    CODE
    ```text
    Title

    Text in opening.

    1. Section
      1.1 Section Item

    =============================================

    1. Section
      1.1
      Full details of section item.
    ```

並查看 CODE.md:

    CODE.md
    ```markdown
    # Title

    Text in opening.

    ### [Section](#1-section)

    - [1.1](#11) Section Item but Only Numbers in Sub-heading

    ***

    ## 1. Section

    ### 1.1

    Full details of section item.
    ```

我看到 file.md 存在並與檔案中的文字匹配。

我會以類似的方式轉換 file.md。讓我們看看檔案文字文件:

    file
    ```text
    Title

    1. Command
      1.10.0 Options

    ---------------------------------------------

    Command
      1.10.0
      Info on the commands' options.
    ```

好的,在分析指南檔案後,我已將 file.md 更新為:

    file.md
    ```markdown
    # Title

    ### [1. Command](#command)
    - [1.10.0](#1100-option-with-text-subheading) Option With Text Subheading

    ***

    ## Command

    ### 1.10.0 Option With Text Subheading
    Info on the commands' options.
    ```

終止明確觸發

使用者

/convert-plaintext-to-md #file.md polish the converted markdown file

注意 - 接受自然語言變體。因此使用了「polish the converted markdown file」。

代理

我將完成 file.md。我看到目前轉換的 Markdown 檔案有:

    ```markdown
    # Title

    Some paragraph with space character at start of line. This <html> should be escaped.

    -  Some list item with extra space character.
    -  Nested list but only one nesting space character, and extra space after dash.
      if (a == 1) {
        return "Indented code block without enough space characters.";
      } else {
        return "Passing `finalize` or similar should resolve this.";
      }

    But when `python` is used, syntax will be like:
    ```

    ```
    import math
    radius = float(input("This is clearly python, but let's do math."))
    area = math.pi * radius**2
    circumference = 2 * math.pi * radius
    print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
    ```

讓我修剪一些東西:

    ```markdown
    # Title

    Some paragraph with space character at start of line. This \<html\> should be escaped.

    - Some list item with extra space character.
      - Nested list but only one space character.

        if (a == 1) {
          return "Indented code block without enough space characters.";
        } else {
          return "Passing `finalize` or similar should resolve this.";
        }

    But when `python` is used, syntax will be like:

    ```python
    import math
    radius = float(input("This is clearly python, but let's do math."))
    area = math.pi * radius**2
    circumference = 2 * math.pi * radius
    print(f"Area: {area:.2f}, Circumference: {circumference:.2f}")
    ```

沒有現有的 Markdown 檔案和行內簡寫指示

使用者

/convert-plaintext-to-md #BUGS --p "regex()=> ^ {1,}([0-9]+\.[0-9]+\.[0-9]+) to ^### $1"

代理

我看到沒有 `BUGS.md` 檔案。讓我複製目前的純文字 BUGS 文件:

    ```bash
    copy BUGS BUGS.md
    ```

現在我將更新複製的檔案 BUGS.md,將其轉換為正確的 Markdown。
讓我讀取目前內容:

    ```markdown
    1 Section
      1.1 Section Item
      1.2 Section Item
      ...
      1.12 Section Item
    ```

好的,我已匹配簡寫正規表達式模式並將 BUGS.md 更新為:

    ```markdown
    1 Section
    ### 1.1 Section Item
    ### 1.2 Section Item
    ### ...
    ### 1.12 Section Item
    ```

考量事項

模式

  • 行縮排
  • 識別縮排程式碼區塊
  • 識別圍欄式程式碼區塊
    • 識別程式碼區塊的程式語言
  • 轉換時,當文件記錄了 exit() 和結束任務的程序時,不要停止該程序。
    • 例如:
      • exitexit()
      • killkillall
      • quitquit()
      • sleepsleep()
      • 以及其他類似的命令、函式或程序。

[!NOTE] 如有疑問,請務必使用 Markdown 最佳實務並參考 參考 URL。

目標

  • 準確保留所有技術內容
  • 維護正確的 Markdown 語法和格式 (請參閱下面的參考資料)
  • 確保標題、列表、程式碼區塊和其他元素結構正確
  • 保持文件可讀性和組織良好
  • 組合一組統一的指示或腳本,使用所有提供的參數和選項將文字轉換為 Markdown

參考

[!IMPORTANT] 除非提示指示明確且毫無疑問地指定要更改資料,否則請勿更改資料。

Install via CLI
npx skills add https://github.com/linyute/awesome-copilot --skill convert-plaintext-to-md
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator