Fix OCR line breaks and rejoin your paragraphs
Most PDFs store text line by line, so copied or OCR text has a hard return on every line. To fix it, join the lines inside each paragraph and keep the blank lines between paragraphs. ocrtomarkdown joins a line to the next unless it ends a sentence and a capital follows.
Why every line ends in a hard return
A PDF is not a document of paragraphs. It is a set of instructions to draw words at places on a page, and each printed line is drawn on its own. When you copy text out, or when OCR reads a scan, the end of every line becomes a newline character, because nothing in the file says which lines belong together.
Notes apps then treat those returns in their own ways. Standard Markdown reads a single return as a space and a blank line as a new paragraph, and Obsidian’s help page describes a Strict line breaks setting that follows that rule. Where an app shows every return as a break, a pasted sentence is chopped off mid-line. Other apps differ, so paste one wrapped paragraph into yours to see.
Rejoin the lines yourself in six steps
- Check the patternPaste one page into a plain text editor. If most lines stop at about the same width, the breaks are wrap points, not paragraph ends. Lines that stop short and are followed by a blank line are the real paragraph ends.
- Protect the real paragraph breaksUse a find and replace that can match a line break. Word writes it ^p, and code editors use \n with regular expressions on. Replace each blank line, two returns in a row, with a marker found nowhere else, such as @@.
- Join the other linesReplace each remaining single return with a space.
- Bring the paragraphs backReplace the marker with two returns. Each paragraph is now one long line, which every notes app wraps for you.
- Mend the split wordsSearch for a hyphen followed by a space, which is where a word broke across lines, and close it up. Keep the hyphen in real compounds such as self-contained.
- Treat lists and headings by handThis method also glues list items and headings into the text around them, so use it on prose only. Leave tables and code blocks out of the replace.
A wrapped paragraph, before and after
The first block is text as a PDF gives it. The second is what the converter writes for Notion.
The plasma membrane is a selectively perme-
able barrier that controls what enters and
leaves the cell. Some proteins are self-
regulating, others are not.
A second paragraph starts here and
wraps onto a second line.The plasma membrane is a selectively permeable barrier that controls what enters and leaves the cell. Some proteins are self-regulating, others are not.
A second paragraph starts here and wraps onto a second line.The split word perme- and able is one word again, and self- and regulating keep their hyphen.
How the converter decides where to join
Each row is a rule applied to the end of a line, from first to last.
| When a line… | The result | Why |
|---|---|---|
| does not end a sentence | Joined to the next line | The sentence carries on. |
| ends a sentence and the next starts lowercase | Joined | A lowercase start means the sentence went on. |
| ends a sentence and the next starts with a capital | Kept as its own line | It may be a new item or paragraph. |
| ends in a hyphen inside a word | Joined, hyphen dropped | perme- and able become permeable. |
| ends in self-, non-, cross- and similar | Joined, hyphen kept | A short list of prefixes keeps its hyphen. |
| is a short Title Case label | Kept apart from the next line | It reads as a label, not a wrapped line. |
| ends a sentence at the margin of an evenly wrapped block | Joined | Four or more lines at one width read as one paragraph. |
Blank lines stay as paragraph breaks. Lines that start a bullet, heading, table or quote are not joined to the line above.
What goes wrong when lines are rejoined
Two sentences stay on two lines
A line that ends a sentence, followed by a capital, is kept apart, as in “Osmosis is the movement of water.” then “Diffusion is…”. Delete that return by hand.
A heading reads as plain text
A sentence-case line such as “Key terms”, if the OCR did not mark it as a heading, stays plain text, kept on its own line rather than a real #. Add the # by hand where you want it to act like a heading.
A real hyphen goes missing
A compound whose first part is not on the short list, such as sugar-free split across a line, can lose its hyphen. Read for those.
Verse and addresses lose their breaks
Poetry and addresses have real line breaks but often no full stops. The rule reads them as wrapped prose and joins them.
Columns interleave
If the OCR reads two columns across the page, the lines are mixed before any joining. See Scanned book chapter to notes.
Pasted text looks chopped
You pasted the raw text, not the joined file. Paste the converted Markdown, or turn on Strict line breaks in Obsidian.
How ocrtomarkdown helps
ocrtomarkdown applies this rule to every paragraph and list item. It joins wrapped lines, mends split words, keeps blank lines as paragraph breaks and leaves headings, tables and code alone. The tally under the preview says how many paragraphs were rebuilt. Convert on the converter page. Free: 3 files a day, up to 10 pages each, no account. Files over 10 pages are converted up to page 10 on the free allowance; a page code converts the whole file, up to 150 pages. See pricing.
OCR line breaks: your questions
Why does copied PDF text break on every line?
Most PDFs draw each printed line separately and store no paragraphs, so copying turns the end of every line into a return.
How do I remove line breaks but keep paragraphs?
Swap blank lines for a marker, replace single returns with spaces, then swap the marker back to two returns.
Does Obsidian join the lines for me?
Its help page describes a Strict line breaks setting, under Settings then Editor, that follows the standard Markdown rule.
Why was a hyphen kept in some words?
A short list of prefixes, such as self, non, anti and cross, keeps its hyphen when a word is rejoined. Other split words lose it.
Will it join the lines of a poem?
Probably. Verse without full stops looks like wrapped prose, so check poems and addresses against the original.
Does it change lists, headings, tables and code?
They stay as their own blocks. Only a wrapped line inside a list item is joined to that item.
How can I see how many paragraphs were rebuilt?
The tally under the preview counts the paragraphs joined and the repeated lines removed.
Why do two sentences stay on separate lines?
The first line ended a sentence and the next started with a capital, which the rule treats as a possible break.