<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python | Silas Kieser</title><link>/category/python/</link><atom:link href="/category/python/index.xml" rel="self" type="application/rss+xml"/><description>Python</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Wed, 05 Nov 2025 00:00:00 +0000</lastBuildDate><image><url>/media/icon_hu0144edc3649b1995b32e914262035870_346211_512x512_fill_lanczos_center_3.png</url><title>Python</title><link>/category/python/</link></image><item><title>Linebreaker: Intelligent Line Breaking for Markdown</title><link>/post/linebreaker/</link><pubDate>Wed, 05 Nov 2025 00:00:00 +0000</pubDate><guid>/post/linebreaker/</guid><description>&lt;ul>
&lt;li>&lt;a href="#semantic-line-breaking-for-markdown">Semantic Line Breaking for Markdown&lt;/a>&lt;/li>
&lt;/ul>
&lt;h1 id="semantic-line-breaking-for-markdown">Semantic Line Breaking for Markdown&lt;/h1>
&lt;p>A feature of markdown (Quarto) is that it ignores line breaks.
A line break is just a space. (A double line break is a new paragraph).&lt;/p>
&lt;p>Also it is a good practice to not have endless long lines in markdown files.
Because if you put 3 sentence on one line and you make one change in one word git would change the whole line.
But on the other hand you do not want to break a sentence at random places just that it fits to a 60-80 character line length.&lt;/p>
&lt;p>Mattt developed the idea of &lt;a href="https://sembr.org/" target="_blank" rel="noopener">semantic line breaks&lt;/a>, where you break lines at meaningful places in the semantic logic of the sentence.
I find the concept very convincing.
Now with semantic linebreaks the markdown text is almost better readable than the rendered pdf or html without the line breaks.&lt;/p>
&lt;p>To break lines automatically according to semantic line breaks I one would need a tool that understands natural language.&lt;/p>
&lt;p>And they did, &lt;a href="https://github.com/admk/sembr" target="_blank" rel="noopener">sembr&lt;/a>, but for me it screwed up my quarto markdown files.&lt;/p>
&lt;p>So what I did is to create a simpler rule based line braker that works well with markdown and even quarto files.&lt;/p>
&lt;p>Hope it helps you with writing!&lt;/p>
&lt;h2 id="features">Features&lt;/h2>
&lt;p>&lt;strong>Linebreaker&lt;/strong> provides intelligent line breaking for Markdown and text files with sophisticated handling of:&lt;/p>
&lt;h3 id="smart-punctuation-handling">Smart Punctuation Handling&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Citations&lt;/strong>: Preserves &lt;code>[@...]&lt;/code> format citations (DOIs contain punctuation)&lt;/li>
&lt;li>&lt;strong>Numbers&lt;/strong>: Keeps decimal numbers intact (e.g., 3.14, 1,000.50)&lt;/li>
&lt;li>&lt;strong>Abbreviations&lt;/strong>: Recognizes common abbreviations (Dr., Prof., vs., et al., etc.)&lt;/li>
&lt;/ul>
&lt;h3 id="intelligent-breaking">Intelligent Breaking&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>Semantic breaks&lt;/strong>: Splits at conjunctions, commas, and logical connectors&lt;/li>
&lt;li>&lt;strong>Length-aware&lt;/strong>: Skips breaking sentences that are already short&lt;/li>
&lt;li>&lt;strong>Context-aware&lt;/strong>: Handles parentheses and brackets appropriately&lt;/li>
&lt;/ul>
&lt;h3 id="markdown-aware">Markdown-Aware&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>YAML headers&lt;/strong>: Skips frontmatter blocks&lt;/li>
&lt;li>&lt;strong>Code blocks&lt;/strong>: Preserves all code content unchanged&lt;/li>
&lt;/ul>
&lt;h2 id="installation">Installation&lt;/h2>
&lt;p>Install from PyPI using pip:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install linebreaker
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Or using pixi:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pixi add --pypi linebreaker
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>