---
title: "Comment by Ahmet Özel on \"Building DocPilot Part 2: From Raw Documentation to a Markdown Ingestion Pipeline\" | Hashnode"
description: "One edge case for extract_title is an H1-looking line inside a fenced code example. A document can begin with a shell or Markdown sample containing a line that"
url: "https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf"
---

[Discussion](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49)

Comment [Building DocPilot Part 2: From Raw Documentation to a Markdown Ingestion Pipeline](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49)

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 1](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf)

One edge case for extract\_title is an H1-looking line inside a fenced code example. A document can begin with a shell or Markdown sample containing a line that starts with # before its actual title; the current scan will treat that example as the document heading.

A fixture with a fenced block followed by the real H1 would make that boundary explicit. Tracking fenced regions would be a small extension before adopting a full parser, and it would keep the human-readable title reliable when those source paths later appear as citations or retrieval labels.

[tarini sunil](https://hashnode.com/@tarinisunil)

[Nov 2](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf#reply-6ae81993a8f62719719fb9dc)

Thanks for pointing this out. It is indeed an error.

The current extract\_title() implementation is intentionally simple, but you're right that fenced code blocks can lead to incorrect title extraction.

I'll add a test case for this scenario and improve the function to skip headings inside fenced blocks before moving to a full Markdown parser.

Appreciate the feedback!

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 6](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf#reply-6aedf7a89e48a18824c99a4c)

That is a sensible small step before adopting a parser. I would include both backtick and tilde fences, plus a longer opening fence containing a shorter run inside the example. Closing a fenced region on any fence-looking line would reintroduce the false heading in a less obvious form.

Also keep a no-heading fixture and assert the intended filename fallback. Then the tests cover both extracting the real title after a code example and handling a document that genuinely has no H1.

[tarini sunil](https://hashnode.com/@tarinisunil)

[Nov 12](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf#reply-6af5fe7060870fcc5c4d2fb9)

Thanks for the additional suggestions! I’ve been working on Markdown-aware chunking in the next part of DocPilot, including handling backtick and tilde fences and matching fence lengths.

I’ve now applied the same approach to title extraction and added tests for these edge cases, including the filename fallback. Appreciate the detailed feedback—it helped make the ingestion pipeline more reliable!

[Ahmet Özel](https://hashnode.com/@ahmetozel)

[Nov 16](https://hashnode.com/posts/building-docpilot-part-2-from-raw-documentation-to-a-markdown-ingestion-pipeline/6ae604204643050e2531ea49/comment/6ae79097721b6268168e2cbf#reply-6afb7761ba8669b3bad282eb)

Applying the same fence handling to title extraction and chunking keeps those two interpretations aligned. I would preserve a shared fixture containing a fenced example before the real H1 and assert both the extracted title and the first chunk's heading metadata.

That catches a future change where one path adopts the improved parser while the other quietly falls back to the earlier scan, even though both functions still pass their own simpler examples.
