raw2md
Copyright (c) the raw2md authors
License: GPL-3.0-or-later (see LICENSE)

The package `raw2md_engine` in this distribution is a modified copy of the
software below. Datalab wrote the original packages. Datalab does not
endorse or support raw2md.

Original packages
-----------------

marker-pdf (package `marker`)
  Author:     Datalab
  Repository: https://github.com/datalab-to/marker
  Tag:        v1.10.2
  Commit:     5a41cdbac6232a10aaf4fad29f8e6c1a0c2a0808
  License:    GPL-3.0-or-later
  Copy:       src/raw2md_engine/marker/ (license text in LICENSE there)

surya-ocr (package `surya`)
  Author:     Datalab
  Repository: https://github.com/datalab-to/surya
  Tag:        v0.17.1
  Commit:     411fb1895a02ed629928d5ae59df96f44ac9dc41
  License:    GPL-3.0-or-later
  Copy:       src/raw2md_engine/surya/ (license text in LICENSE there)

pdftext
  Author:     Datalab
  Repository: https://github.com/datalab-to/pdftext
  Tag:        v0.6.3
  Commit:     d76a57535d33e9467fd92c5d3c42d80d8c84f686
  License:    Apache-2.0
  Copy:       src/raw2md_engine/pdftext/ (license text in LICENSE there)

Changes
-------

The copy differs from the original packages in the ways below. The history
of the repository holds each change with its diff.

- The import paths `marker.`, `surya.`, and `pdftext.` are rewritten to
  `raw2md_engine.marker.`, `raw2md_engine.surya.`, and
  `raw2md_engine.pdftext.`.
- The parts that raw2md does not call are removed: the LLM pass, the
  extraction converter, the config parser, the input formats other than
  PDF, the output formats other than Markdown, and the command-line and
  browser applications.
- The PDF converter builds its provider and its Markdown renderer
  directly.
- The settings are fixed values. They do not load from environment
  variables or from a `local.env` file.
- The copy downloads nothing: no font when the converter starts and no
  model weights. `marker/models.py` takes the folder of the weights from
  its caller.
- The models build their non-persistent buffers on the CPU, and the
  loaders build them again after the load of the weights, before the move
  to the device (2026-10-19). Changed files, under
  src/raw2md_engine/surya/: `common/load.py`, `common/adetr/decoder.py`,
  `common/surya/decoder/__init__.py`, `common/surya/encoder/__init__.py`,
  `ocr_error/model/encoder.py`, `foundation/loader.py`,
  `table_rec/loader.py`, and `ocr_error/loader.py`.
- The copy follows the API of transformers 5 (2026-10-19): the tied
  weights as a mapping, `post_init` in every model, the default rotary
  frequencies and the head mask in the copy itself, the tokenizer helpers
  from their new module, and no head pruning or ONNX configuration.
  Changed files, under src/raw2md_engine/surya/: `common/pretrained.py`,
  `common/adetr/decoder.py`, `common/donut/encoder.py`,
  `common/surya/__init__.py`, `common/surya/decoder/__init__.py`,
  `common/surya/decoder/config.py`, `ocr_error/model/config.py`,
  `ocr_error/model/encoder.py`, `ocr_error/tokenizer.py`,
  `table_rec/model/encoder.py`, and `table_rec/model/encoderdecoder.py`.
- The copy fixes defects of its text extraction and its Markdown output,
  drops code that raw2md never runs, and follows the formatting and lint
  rules of raw2md (2026-10-24). Changed files, under src/raw2md_engine/:
  - Text: `pdftext/pdf/pages.py` ignores the blank spans of a line when it
    marks a superscript or a subscript. `marker/schema/text/line.py` keeps
    a dash at the end of a line. `marker/schema/blocks/listitem.py` removes
    only the leading bullet of a list item.
  - Links: `pdftext/pdf/links.py` drops a link whose target is inside the
    document. The page references, the reference processor and block, and
    the span anchors go with it, in `pdftext/schema.py`,
    `pdftext/extraction.py`, `marker/builders/document.py`,
    `marker/providers/`, `marker/schema/`, and
    `marker/renderers/markdown.py`.
  - Tables: `pdftext/tables.py` measures the gap between characters along
    the line and keeps the character boxes of a table run.
    `marker/processors/table.py` splits a run of numbers at the cell
    boundaries.
    `marker/renderers/markdown.py` escapes a vertical bar in a cell and
    writes one separator line for a table of one row.
  - Formats and math: `marker/schema/text/span.py` applies every format of
    a span, with math innermost and bold outermost, and keeps superscript
    markup out of math. `marker/renderers/__init__.py` keeps the minus when
    two inline math spans merge. `marker/renderers/markdown.py` keeps the
    escaped space at the end of math and removes bold from a heading.
  - Layout: `marker/processors/sectionheader.py` sorts the heading heights
    together with their cluster labels, gives one level to neighboring
    clusters of close mean heights, and keeps headers without lines out of
    the clusters. `marker/processors/ignoretext.py`
    counts the repeats of a running header on the even and the odd pages
    apart.
  - Dead code: `marker/converters/pdf.py` drops the line merge, blank page,
    and block relabel processors, and their files go.
  - Imports: `marker/settings.py` imports torch only when the device is
    read. `surya/common/surya/processor/tokenizer.py` imports no torch and
    builds without a special token file.
  - Style: ruff formats every Python file of the copy and applies its safe
    fixes. `surya/detection/heatmap.py` takes its result class from
    `surya/detection/schema.py`, which breaks an import cycle.
- The Markdown renderer returns the HTML that it converts to Markdown
  (2026-11-01). Changed file, under src/raw2md_engine/:
  `marker/renderers/markdown.py`.
- The PDF converter names each of its steps to an optional phase callback
  before the step runs (2026-11-01). Changed file, under
  src/raw2md_engine/: `marker/converters/pdf.py`.
- The repeated text processor hides a copy of a running header only when
  at least two other copies stand at its height, and its text key keeps a
  number that follows a dot (2026-11-08). Changed file, under
  src/raw2md_engine/: `marker/processors/ignoretext.py`.
- The text fixer keeps fullwidth forms and curly quotes, and repairs the
  rest as before. Math keeps the default configuration (2026-11-11).
  Changed files, under src/raw2md_engine/: `marker/util.py`,
  `marker/providers/pdf.py`, `marker/builders/ocr.py`, and
  `marker/processors/table.py`.
- A block that OCR reads as a whole keeps the frames of its detector lines,
  and one block method returns the line frames of any block (2026-11-11).
  Changed files, under src/raw2md_engine/: `marker/builders/ocr.py` and
  `marker/schema/blocks/base.py`.
- A paragraph cut by a page keeps a trailing dash, and it joins without a
  space when Han, kana, or fullwidth punctuation meet at the cut
  (2026-11-11). Changed file, under src/raw2md_engine/:
  `marker/renderers/markdown.py`.
- The text processor joins a paragraph cut by a page, a column, or a
  figure. It steps over pictures, captions, and footnotes, reads the text
  at the cut as well as the line frames, and moves the second half behind
  the first, so the figure follows the joined paragraph. A hyphen `-` at
  the cut stays before a capital or a digit, and a soft hyphen `¬` goes.
  A text block that holds only a label and a number is no half, and a text
  block that repeats on three pages or more is stepped over
  (2026-11-12). Changed files, under
  src/raw2md_engine/: `marker/processors/text.py`,
  `marker/processors/debug.py`, and `marker/renderers/markdown.py`.
- The line height of a block divides the block height by the count of
  detector line frames, so a heading that OCR reads as one text line gets
  the height of one line (2026-11-11). Changed file, under
  src/raw2md_engine/: `marker/schema/blocks/base.py`.
- The nesting of a list item needs the start of its first text line and
  the frame of the item both to move right of the parent (2026-11-12).
  Changed file, under src/raw2md_engine/: `marker/processors/list.py`.
- The equation processor keeps the text of a formula block. A reading
  without math gives the text layer of the block, or a paragraph when the
  block has no text layer. A reading with a word outside its formulas is
  a line with inline math. Any other reading puts each formula on its own
  display line and keeps the punctuation and the numbers between the
  formulas in order. A formula enclosed by brackets or parentheses, or one
  wrapped in square brackets, stays inline on the line under the formula
  before it. A bracketed condition outside the formulas, with a relation
  and no word of three letters or more, is not a word (2026-11-14).
  Changed file, under src/raw2md_engine/: `marker/processors/equation.py`.
- A picture keeps the frame of the layout model, and a detector line goes
  to a picture only when at least half of its area lies inside that frame.
  A text line beside a chart goes to another block by overlap or by
  distance, or to a new text block. A new block whose center equals the
  center of an existing block no longer fails the placement
  (2026-11-13). Changed file, under src/raw2md_engine/:
  `marker/schema/groups/page.py`.
- A new processor hides a picture whose frame lies in the top or the
  bottom 15 % of the page and repeats at one place, each edge within
  0.015 of the page side, on three pages or more. The renderer neither
  shows nor saves a hidden picture, and the block stays in the document
  (2026-11-13). Added file, under src/raw2md_engine/:
  `marker/processors/image_furniture.py`. Changed files:
  `marker/converters/pdf.py` and `marker/renderers/html.py`.
- The Markdown renderer ends each paragraph without continuation without a
  space, so a paragraph that ends in an italic span or an inline formula
  at the foot of a page does not read as a paragraph cut by the page
  (2026-11-13). Changed file, under src/raw2md_engine/:
  `marker/renderers/markdown.py`.
- A table cell joins a line that wraps onto the next line with a space,
  and it keeps each new value on a line of its own. A line wraps when the
  first word of the next line would not fit into the room that the line
  leaves in its column, and the next line starts under it, at most 0.3
  line heights below. The width of a column is its widest line, each line
  counted at most at the width of its cell. A line that opens with a
  bullet is a new value. A hyphen at the end of a wrapped line goes
  before a lowercase letter and stays before a capital or a digit. A cell
  without line frames keeps its lines (2026-11-14).
  Changed file, under src/raw2md_engine/: `marker/processors/table.py`.
- A new processor joins a table that a page break cuts in two. The table
  that closes a page takes the rows of the table that opens the next page,
  when only running headers, footers and hidden blocks stand between them,
  the column counts are equal or differ by one with each column of the
  narrower part over a column of the wider part, and the first rows of the
  second part repeat the first rows of the first part cell for cell or the
  table model reads its first row as data. Past the first row, only a
  header row repeats. The repeated rows go. A table whose first row
  repeats a run of its own cells, records set side by side, stays apart,
  and so does a part where a header row did not repeat or a cell spans
  over the cut. A table cell keeps the header flag of its row from the
  table model (2026-11-14). Added file, under src/raw2md_engine/:
  `marker/processors/table_merge.py`. Changed files:
  `marker/converters/pdf.py`, `marker/processors/table.py` and
  `marker/schema/blocks/tablecell.py`.
- The text processor reads the first line of a second half as indented
  when it starts right of the leftmost line by more than a tolerance. When
  the text at the cut shows a continuation, the tolerance is 1.5 units or
  0.02 of the block width, whichever is larger, so one step of the line
  frames is no indent wherever the block stands on the page. Without that
  text, an offset of more than 0.01 units is an indent (2026-11-15).
  Changed file, under src/raw2md_engine/: `marker/processors/text.py`.
- The text processor joins two text blocks of one page that stand one
  right under the other with no block between them, when the text at the
  cut shows a continuation and the second block does not start indented.
  The gap between the blocks is less than half the median line height of
  the first block and not less than minus half of it. The blocks overlap
  along the horizontal axis by at least half the width of the narrower
  block (2026-11-15). Changed file, under src/raw2md_engine/:
  `marker/processors/text.py`.
- The table merge processor also joins a table that a column break cuts
  on one page. The table that ends a column takes the rows of the table
  that opens the next column, when the second part starts no lower than
  the first and right of its right edge, only running headers, footers
  and hidden blocks stand between them, and the conditions of a page
  break hold. Each column of one part also overlaps its column of the
  other part, with the edges measured as a share of the width of their
  own table (2026-11-15). Changed file, under src/raw2md_engine/:
  `marker/processors/table_merge.py`.
- The table merge processor reads a first row of the second part that
  the table model flags as a header as a data row, at a page break and at
  a column break, when each filled cell of the row has the form of its
  column in the data rows of the first part: a number under numbers, or
  the code that two data rows or more of the column all hold. One cell at
  least falls under such a column, so a row of words over columns of
  numbers stays a header (2026-11-15). Changed file, under src/raw2md_engine/:
  `marker/processors/table_merge.py`.
- The text processor counts a text block as repeated when it holds three
  words split by spaces or eleven letters, so a running line in a script
  without spaces between words counts as well (2026-11-17). Changed file,
  under src/raw2md_engine/: `marker/processors/text.py`.
- The text processor reads text evidence in a script without letter case:
  at a page or column break, a first half that holds 20 characters or
  more besides spaces and ends in a letter or a comma, and a second half
  that opens with a letter without case and no item number (2026-11-17).
  Changed file, under src/raw2md_engine/: `marker/processors/text.py`.
- The lines of one block join without a space where Han, kana, or
  fullwidth punctuation meet at the line end, by the same test as the
  join of a paragraph cut by a page. Hangul and Latin keep the space
  (2026-11-17). Changed files, under src/raw2md_engine/:
  `marker/util.py`, `marker/schema/text/line.py`, and
  `marker/renderers/markdown.py`.
- The table merge processor relaxes the test of a flagged first row. A
  placeholder `-`, `/`, `*` or `_` counts as a number, a column of three
  values or more holds numbers when 80 % of its values or more are
  numbers, and a cell over several columns takes any form. A row that
  fills only the first column reads as data when the first later row
  that fills another column reads as data (2026-11-18). Changed file,
  under src/raw2md_engine/: `marker/processors/table_merge.py`.
- The copy imports the text tests that raw2md shares with its cleaning
  from the module `raw2md.mdtext.seams`, which imports no code of the
  copy. The text processor reads the end of a sentence there: a sentence
  mark, past closing quotes and brackets (2026-11-19). It reads there as
  well the text evidence that the two halves of a cut paragraph carry on
  one sentence, in a script with letter case and in one without
  (2026-11-19). Changed file, under src/raw2md_engine/:
  `marker/processors/text.py`.
- The test that two lines meet without a space, at Han, kana, and
  fullwidth text, moves from `marker/util.py` to the same module
  `raw2md.mdtext.seams` unchanged (2026-11-19). Changed files, under
  src/raw2md_engine/: `marker/util.py`, `marker/schema/text/line.py`,
  and `marker/renderers/markdown.py`.
- The text processor reads the label and the number that open a caption
  from the same module `raw2md.mdtext.seams`. A label is a capitalized
  word of up to 12 letters or a word of the config option
  `caption_labels`, which raw2md fills from its own word list. The number
  is arabic, with its sections, or roman (2026-11-19). Changed file,
  under src/raw2md_engine/: `marker/processors/text.py`.
- The table merge processor reads the form of a number from the module
  `raw2md.mdtext.tables`, which the cleaning reads too. A number may open
  on a point, as in `.690`, and parentheses may enclose it, as in
  `(12.4)` (2026-11-19). Changed file, under src/raw2md_engine/:
  `marker/processors/table_merge.py`.
- A line-end hyphen that the copy used to delete becomes a soft hyphen
  (U+00AD): at the end of a line of a block, at a hyphenated break inside
  a span, at the cut of a paragraph that continues, and at a wrapped line
  of a table cell. The cleaning of raw2md keeps or drops the hyphen by the
  spellings of the text. At the end of a line of a block, the soft hyphen
  follows a letter only, and a hyphen after a digit or a space goes as
  before. A hyphen that the copy keeps before a capital or a digit stays
  (2026-11-20). Changed files, under src/raw2md_engine/:
  `marker/util.py`, `marker/schema/text/line.py`,
  `marker/schema/text/span.py`, `marker/renderers/markdown.py`, and
  `marker/processors/table.py`.
- The table processor no longer removes the dot leaders from a cell line.
  The cleaning of raw2md removes them from each line of a pipe-table cell
  (2026-11-20). Changed file, under src/raw2md_engine/:
  `marker/processors/table.py`.
- The table processor no longer joins a column of dollar signs with its
  neighbour. The cleaning of raw2md does it on the pipe table
  (2026-11-20). Changed file, under src/raw2md_engine/:
  `marker/processors/table.py`.
- The Markdown renderer no longer removes bold from a heading. The
  cleaning of raw2md removes each bold run from a heading on every route
  (2026-11-20). Changed file, under src/raw2md_engine/:
  `marker/renderers/markdown.py`.
- The table processor joins the wrapped lines of each cell before it
  splits the rows that the table model merged, so a value that wraps to a
  second line keeps its row (2026-11-20). Changed file, under
  src/raw2md_engine/: `marker/processors/table.py`.
- The copy imports no transformers module that a release of transformers 5
  removed: the mask of fully masked rows is computed in the copy itself,
  and the tokenizer base class comes from the top level of transformers
  (2026-11-21). Changed files, under src/raw2md_engine/surya/:
  `common/adetr/decoder.py`, `common/surya/__init__.py`, and
  `common/surya/processor/__init__.py`.
- The OCR builder re-reads a line of the text layer on a scan page, a page
  that one image covers by 90 % or more. The line holds `^` or U+FFFD and
  its center lies outside a picture, a figure, a table, a form, and a table
  of contents. The recognition model reads the line inside its frame, with
  a token limit by the length of the line. A reading replaces the line
  when it is not empty and holds no `^` or U+FFFD outside math, no group of
  three characters or more five times in a row, and no empty group `{}` in
  math. The page keeps its text layer for the other lines (2026-11-26).
  Changed files, under src/raw2md_engine/: `marker/providers/pdf.py` and
  `marker/builders/ocr.py`.

Each changed file of `pdftext/` carries a notice at its top.

Last change: 2026-11-26.
