Skip to content

[Feature Request / Bug] Issues with mid-sentence image insertion, internal link escaping, and output file extension #1107

Description

@yura0148

Title:

[Feature Request / Bug] Issues with mid-sentence image insertion, internal link escaping, and output file extension

Body:

### Summary
First off, thank you for developing Marker — it is an outstanding tool for document conversion.

While running batch conversions on complex academic and medical literature (multi-page books and papers with embedded figures), we encountered a few structural and formatting issues in the core output generation that could be significantly improved natively in Marker:

---

### 1. Figures split sentences and paragraphs in half (Block Ordering Issue)
**Problem:**
When a figure and its caption are embedded in the middle of a column on a PDF page, Marker often injects the image markdown `![](_page_X_Figure_Y.jpeg)` and caption directly into the middle of an incomplete sentence based on vertical coordinates.
Furthermore, the text following the figure sometimes gets glued to the end of the caption line without a newline break.

**Example from generated Markdown:**
```markdown
Mechanical loading influences bone remodeling following a U-shaped curve: As mentioned before, an

![](_page_39_Figure_8.jpeg)

Fig. 3.2 Remodeling increases in states of disuse (yellow) and overuse (orange)... partially offsetting the bone loss induced by the increased bone remodeling increase in bone remodeling activity corresponds to a decrease in bone mass.
  • Notice how "As mentioned before, an" was sliced.
  • Notice how "increase in bone remodeling activity..." is glued directly to the end of the caption.

Proposed Improvement:
During layout assembly, if an image block interrupts an active paragraph (where the preceding block doesn't end with sentence-ending punctuation like ., !, ?, or : followed by a capitalized continuation), defer the image + caption block to the end of the current paragraph / block before rendering.


2. Malformed / double-escaped brackets in internal citation anchors

Problem:
When Marker generates cross-references and internal page anchors, the square brackets often end up improperly escaped or duplicated, breaking standard Markdown link parsers.

Examples observed in output:

  • [\[52](#page-43-0)]
  • [[53\]](#page-43-0)
  • [\[56](#page-43-0)]
  • [.8,9](#page--1-0) (leading dot before citation numbers)
  • Unclosed anchor spans left in the text body: <span id="page-1-0"> without matching closing tags.

Proposed Improvement:
Ensure bracket sanitization is performed cleanly prior to generating Markdown links, so citations reliably format as [52](#page-43-0) or [53](#page-43-0).


3. Word agglutination / missing spaces in caption OCR

Problem:
In certain figure captions (especially when using Surya line detection with tightly-kerned fonts), words occasionally get merged without spaces.

Example:

Fig. 4.1 NormalrighthipX-ray:femoralshaftaxis(redline), lateral offset (blue line)...

(Expected: Normal right hip X-ray: femoral shaft axis (red line)...)

Environment

  • Marker Version: 2.0 (latest)
  • Backend: LlamaCPP (CUDA) / Surya
  • OS: Windows 10/11 x64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: outputPoor markdown/HTML output quality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions