Markdown knowledge import removes literal hashes from headings (C# becomes C)

オープン 初心者向け
#41,907 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

api/core/rag/extractor/markdown_extractor.py の MarkdownExtractor.markdown_to_tups から始め、extract() のエントリポイントを追ってください。C# や Issue #123 のような見出しを含む例を再現し、その後 extract() を通じたパラメーター化されたリグレッションカバレッジを追加してください。見出しテキスト内のリテラルなハッシュが保持されたまま、開始マーカーと有効な任意の終了マーカーが処理されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Self Checks
  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.
Dify version

main at 5e51fe2640 (api version 1.17.0)

Cloud or Self Hosted

Self Hosted (Source). Reproduced at the extractor level; no running deployment was used.

Steps to reproduce

The built-in Markdown extractor is selected for .md, .markdown, and .mdx knowledge uploads when using the default ETL path. Its heading cleanup removes every #, including characters that belong to the title text.

A minimal extractor reproduction, run from api/ in a configured development environment:

from pathlib import Path
from tempfile import TemporaryDirectory
from core.rag.extractor.markdown_extractor import MarkdownExtractor

with TemporaryDirectory() as directory:
    path = Path(directory) / "example.md"
    path.write_text("# C#\nLanguage reference.\n\n## Issue #123\nIssue details.\n", encoding="utf-8")
    docs = MarkdownExtractor(str(path), encoding="utf-8").extract()
    for doc in docs:
        print(repr(doc.page_content))
✔️ Expected Behavior

The nonempty documents retain C# and Issue #123 as their titles. Opening heading markers and optional closing heading markers may still be removed, as they are today.

❌ Actual Behavior

The titles become C and Issue 123. This silently changes the text ingested into the knowledge base, including programming language names and issue references.

The cause is re.sub(r"#", "", key) in MarkdownExtractor.markdown_to_tups, which removes hashes throughout the title.

This differs from #30940, which requested retaining the Markdown heading markers themselves. This report concerns literal characters in the heading content.

I would like to contribute a small fix that removes only the opening marker and valid optional closing markers, with parameterized regression coverage through extract(). Could a maintainer confirm the approach and assign this issue to @gallonyin?

主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。