Obsługiwane formaty¶
snapper classifies text into prose regions (reflowed at sentence boundaries), structure regions (passed through unchanged), and code regions (fenced or delimited source blocks).
Code regions keep fence/open/close lines as structure; the body reflows comment lines when [code.<lang>] is configured, and may run an external formatter when --format-code is set.
The classification depends on the format.
Org-mode (--format org)¶
Regiony strukturalne (zachowane)¶
Non-source
#+BEGIN_*…
#+END_* fences, and the bodies of literal blocks (example, export, comment, verse). An unmatched #+BEGIN_EXPORT is a paragraph (org-element export-block-parser)
Dynamic blocks (
#+BEGIN: NAME…#+END:), including the generated bodyQuote, center, and special-block (NOTE and other unknown NAME) open/close lines
Verse-block body (org-element verse-lines; leftover opaque walker, GitHub #395)
Special-block interiors (NOTE, ABSTRACT, WARNING, …) reflow as prose
:PROPERTIES:…
szuflady :END:
#+KEYWORD:directives (TITLE, AUTHOR, DATE, OPTIONS, NAME, ATTR*, etc.);#+CAPTION:/#+CAPTION[short]:opener onlyStandalone bracket-link lines (
[[file:plot.png]])Wiersze tabeli (linie zaczynające się od
|)Linie komentarzy (zaczynające się od
#, ale nie#+)Column-0 diary-sexp lines (
%%(...); org-element-diary-sexp-parser)Full headline lines (stars, optional TODO keyword, and title text)
List item markers (
-,+,1.); continuation sentences hang at the marker widthLaTeX environments (
\begin{equation}…\end{equation},\begin{align}, etc.). An unmatched\begin{env}is a paragraph (org-element latex-environment-parser)Display math (
\[…\])Line breaks (org-element-line-break-parser:
\\plus optional spaces or tabs at end of line)A line that is only an export snippet (
@@latex:\newpage@@). Trailing prose after the closer stays Prose.
Code regions (#+BEGIN_SRC … #+END_SRC)¶
An unmatched
#+BEGIN_SRCis a paragraph (org-element src-block-parser)Header and footer lines are structure
Body non-comment lines pass through verbatim
Body comment lines reflow at sentence boundaries when the language has
line_commentand/orblock_commentunder[code.<lang>]With
--format-code, optionalformatterargv runs on the body (graceful fallback on failure)
Regiony prozy (przeformatowywane)¶
Tekst akapitowy
List item text (after the marker); continuation sentences hang at the marker width so Org rejoins the item
Quote, center, and special-block inner text
#+CAPTION:value (org-element-parsed-keywords); continuation sentences hang at the opener width. Dual#+CAPTION[short]:keeps the short title on the opener
Tokeny inline (zachowane jako niepodzielne)¶
Te tokeny wewnątrz prozy nie są dzielone między liniami:
Linki:
[[url][opis]]Angular links:
<file:fig. 1.png>(org-link-angle-re; spaces allowed)Emphasis:
\*bold*,/italic/,_underline_,+strike+Kod inline:
~code~,==verbatim==A
~code~or==verbatim==span may contain the marker character; pairing matches pandoc’s org reader, sox = 1stays one spanMarkdown inline code: a run of
nbackticks closes on the next run of the same length (CommonMark / pandoc), so a double span can hold a single backtickInline export snippets:
@@backend:value@@(org-element-export-snippet-parser; backend[-A-Za-z0-9]+sohtml5and hyphen names stay one token)Radio targets:
<<<contents>>>(org-element-radio-target-parser)Angle targets:
<<contents>>(org-element-target-parser)Macros:
{{{name}}}/{{{name(args)}}}(org-element-macro-parser)Inline source:
src_lang{...}/src_lang[headers]{...}(org-element-inline-src-block-parser;\<src_is word-start. After a word,_src_is a subscript, sofoo_src_python{...}is not an object;_src_python{...}after space is)Inline babel call:
call_name(...)/call_name[inside](...)[end](org-element-inline-babel-call-parser; same\<call_/ subscript rule)Inline footnotes:
[fn:: def]/[fn:name: def](org-element-footnote-reference-parser)LaTeX fragments:
\(...\),$...$,\cmd{arg},\cmd[opt]{arg}(org-element-latex-fragment-parser; interior backslash and optional[arg]stay one token). Same-line\[...\]is StructureBrace sub/superscripts:
H_{2. 0}/x^{n. 1}(org-match-substring-regexp brace arm; interior punct stays one wrap token). BareH_2/x^nand no-spaceH_{2.0}are unchanged. Distinct from latex-fragment.URLs:
https://...(trailing sentence punctuation not swallowed)
LaTeX (--format latex)¶
Regiony strukturalne (zachowane)¶
Preambuła (wszystko przed
\begin{document})Non-prose environments: equation, align, tabular, tikzpicture, and their starred variants (plus other non-code envs)
Float chrome (
\begin{figure}/\centering/\end{figure}, andtable/ starred variants): Structure. The\captionlong argument is Prose.Extra names from
[latex].structure_envsin.snapperrc.toml(for examplealgorithm)Wzory wyświetlane:
\[...\]\iffalsethrough\fi(tree-sitterblock_comment)Linie komentarzy (zaczynające się od
%)\end{document}Full sectioning command lines (
\section{...},\subsection{...}, and friends, including title text)
Code regions (minted, lstlisting, verbatim, comment, Piton)¶
\\begin{...}/\\end{...}lines are structurefancyvrb
Verbatim/Verbatim*/BVerbatim/BVerbatim*/LVerbatim/LVerbatim*/SaveVerbatim/VerbatimOut/ fvextraVerbatimWrite/VerbatimBufferare built-in code regions (same FV@Scan class)verbments.sty
pyglistwraps fancyvrbVerbatimOut(raw listing body)texments.sty / pygmentex.sty
pygmentedisVerbatimEnvironmentplusVerbatimOut(raw listing body)fvextra
VerbEnvis the environment form of\Verb(raw body through matching\end{VerbEnv})moreverb
verbatimtabis a built-in code region (tab-expanding verbatim; same raw class asboxedverbatim)moreverb
verbatimwritewrites the env body raw viaverbatim@start(same class asVerbatimOut/tcbverbatimwrite)leftover sverb.sty
verbwrite/ignore/demo/demo*are the samesv@readenvraw grabmoreverb
listing/listingcont/listing*/listingcont*are built-in code regions (verbatim@startraw body; starred twins do not expand tabs)alltt(standardalltt.sty) is a built-in code region (raw line breaks)listings.sty
lstlisting*is the same raw body scan aslstlistingpythonhighlight.sty
python(`lstnewenvironment{python}`) is the same listings raw scan aslstlistingpyluatex.sty
pythonq/pythonreplare verbatim python / REPL bodies (landedpythonstays Code)showexpl.sty
LTXexample(`lstnewenvironment{LTXexample}`) is the same listings raw scan aslstlistingluamplib.dtx
mplibcodeis the same raw grab class asluacodeluacode.sty leftover
luaexecis the same raw grab class asluacodecodehigh.sty
codehigh/demohigh/codehigh*/demohigh*(`NewCodeHighEnv`) are leftover listing envsminted.sty
minted*is the starred twin ofminted(same raw minted body)tcolorbox listings
tcblisting*is the starred twin oftcblisting(same raw listing body)tcolorbox
tcbverbatimwrite/tcbwritetempwrite the env body raw to a file (same class asVerbatimOut)tcolorbox leftover write/listing envs
tcboutputlisting/tcbexternal/dispExample/dispExample*/dispListing/dispListing*are the same raw grab (tcblistingscore / tcbexternal / tcbdocumentation)latexindent
filecontents/filecontents*write the env body raw to a filefilecontentsdef.sty
filecontentsdefwrites the env body verbatim into a macro (same raw grab asfilecontents)filecontentsdef.sty leftover siblings
filecontentsgdef/filecontentsdefmacro/filecontentsgdefmacro/filecontentshereand starred twinsfilecontentsdef*/filecontentsgdef*/filecontentshere*are the same raw grabscontents.sty
scontentsstores the env body verbatim into a sequence;verbatimscis the package verbatim display envspverbatim.sty
spverbatimis a built-in code region (raw line breaks)pythontex.sty
pyblock/pyverbatim/pyconsole/pycode*/pyblock*/pyverbatim*/pyconsole*/pygments/sympycode/sympyblock/sympyverbatim/sympyconsole/pylabcode/pylabblock/pylabverbatim/pylabconsoleand starred twins, plus leftover default-familypyconcode/pyconverbatim/pysub/pyconsub/sympyconcode/sympyconverbatim/sympysub/sympyconsub/pylabconcode/pylabconverbatim/pylabsub/pylabconsub/pythontexcustomcode, plus option-familyusefamilyleftovers (rubycoderepresentative; ruby / rb / julia / juliacon / jl / matlab / octave / bash / sage / rust / rs / R / Rcon / perl / pl / perlsix / psix / javascript / js), are the sameVerbatimEnvironmentclass aspycodesagetex.sty
sageverbatim/sageexample/sagecommandlineare the sameverbatim@startclass as tree-sitter-latexsagesilent/sageblockpiton.sty
Pitonis a built-in code region (verbatim listing env)Extra names from
[latex].verbatim_envsare code regions tooBody follows the same comment-reflow and optional
--format-coderules as other formats when language is known (minted/minted*language arg,lstlisting/lstlisting*language=option)Inline leftover
\verb/\verb*/ leftover\lstinline/ leftover\spverb/ leftover\mintinline/ leftover\mint/ leftover fancyvrb\Verb/\Verb*/ leftover\SaveVerb/ leftover\UseVerb/ leftover\UseVerbatim/ leftover\LUseVerbatim/ leftover\BUseVerbatim/ leftover\DefineShortVerb/\UndefineShortVerb/ leftover fvextra\EscVerb/ leftover fvextra\VerbatimInsertBuffer/\VerbatimClearBuffer/\InsertBuffer/\IterateBuffer/\VerbatimInput/\BVerbatimInput/\LVerbatimInput/ piton.sty leftover\piton/\PitonInputFile/\PitonInputFileT/\PitonInputFileF/\PitonInputFileTF/ listings.sty\lstinputlisting/ minted.sty\inputminted/ tools/verbatim.sty\verbatiminput/ tcolorbox\tcbinputlisting/ pythontex.sty\inputpy/\inputpycon/ leftover inline\py/\pyc/\pys/\pyb/\pyv/\pyconand twins /\sympy/\pylaband twins / leftover usefamily\ruby/\rb/\julia/\jl/\matlab/\octave/\bash/\sage/\rust/\rs/\R/\perl/\pl/\perlsix/\psix/\javascript/\jsand twins /\inputpygments/\pygment/ leftover\pythontexcustomc/ pythonhighlight.sty\inputpython/\inputpythonfile/ leftover\pyth/ catchfilebetweentags.sty\CatchFileBetweenTags/\CatchFileBetweenDelims/\ExecuteMetaData/ catchfile.sty leftover\CatchFileDef/\CatchFileEdef/ moreverb\listinginput/ leftover\verbatimtabinput/\verbatimtabinput*/ leftover\verbatimwrite/\verbatimwrite*/ leftover\listingcont/ sagetex\sageinput/ leftover inline\sageplot/\sagestr/ scontents leftover\Scontents/\Scontents*/\typestored/\getstored/\mergesc/\meaningsc/\foreachsc(and extra[latex].verbatim_commands) stay atomic; inner.!?%do not split or comment. leftover\verb/\verb*/\lstinline/\spverbtake a delimiter or, for\lstinline, optional[...]then a delimiter or{...}; a flush following sentence stays on its own line leftover\mintinline/\minttake optional[...],{lang}, then a delimiter or{...}body; a flush following sentence stays on its own line leftover\SaveVerbtakes optional[...], a{name}, then the same delimiter body as\Verb; a flush following sentence stays on its own line leftover\UseVerb/\UseVerb*take optional[...]then a{name}; leftover\UseVerbatim/\LUseVerbatim/\BUseVerbatimtake optional[...]then a{name}; a flush following sentence stays on its own line leftover\DefineShortVerbtakes optional[...]then a{char}; leftover\UndefineShortVerbtakes a{char}; a flush following sentence stays on its own line leftover\Verbtakes a delimiter like\verb; leftover\EscVerbtakes a delimiter or{code}; a flush following sentence stays on its own line leftover\VerbatimInsertBuffer/\InsertBuffertake optional[...]; leftover\VerbatimClearBuffertakes no args; leftover\IterateBuffertakes optional[...]then a{cmd}; a flush following sentence stays on its own line leftover\piton|...|is verb-like; leftover\piton{...}stays one token via the generic command argument; a flush following sentence stays on its own line\lstinputlisting/\lstinputlisting*take optional[...]then a{filename}; a flush following sentence stays on its own line\inputminted/\inputminted*take optional[...],{lang}, then a{filename}; a flush following sentence stays on its own line\VerbatimInput/\BVerbatimInput/\LVerbatimInputtake optional[...]then a{filename}; a flush following sentence stays on its own line\verbatiminput/\verbatiminput*take a{filename}; a flush following sentence stays on its own line\PitonInputFiletakes optional<...>, optional[...], then a{filename}; a flush following sentence stays on its own line\PitonInputFileT/\PitonInputFileFtake the same optional args then{file}and one extra required brace;\PitonInputFileTFtakes two extra braces; a flush following sentence stays on its own line\tcbinputlistingtakes one required{keyval}group; a flush following sentence stays on its own line\inputpy/\inputpycontake optional[...]then a{filename}; a flush following sentence stays on its own line\py/\pyc/\pys/\pyb/\pyv/\pyconand twins /\sympy/\pylaband twins take optional[...]then a delimiter or{body}; a flush following sentence stays on its own line\inputpygmentstakes optional[...],{lang}, then a{filename};\pygmenttakes{lang}then a delimiter or{code}body; a flush following sentence stays on its own line\inputpythontakes{file}{first}{last};\inputpythonfiletakes{file}then optional[first][last]; a flush following sentence stays on its own line\pythtakes a delimiter or{code}body; a flush following sentence stays on its own line\CatchFileBetweenTagstakes{macro}{file}{tag};\CatchFileBetweenDelimstakes{macro}{file}{start}{end};\ExecuteMetaDatatakes optional[file]then{tag}; a flush following sentence stays on its own line leftover\CatchFileDef/\CatchFileEdeftake{macro}{file}{setup}; a flush following sentence stays on its own line\listinginputtakes optional[interval]then{start}and{filename}; a flush following sentence stays on its own line\verbatimtabinput/\verbatimtabinput*take optional[tabwidth]then a{filename}; a flush following sentence stays on its own line leftover\verbatimwrite/\verbatimwrite*take a{filename}; a flush following sentence stays on its own line leftover\listingconttakes no args; a flush following sentence stays on its own line\sageinputtakes optional[...]then a{filename}; a flush following sentence stays on its own line\sageplottakes optional[ltx opts][fmt]then a{graphics};\sagestrtakes a{code}; a flush following sentence stays on its own line\inputsctakes optional[...]then a{name}; a flush following sentence stays on its own line\pythontexcustomctakes optional[begin|end], a required{type}, then a delimiter or{code}body; a flush following sentence stays on its own line\Scontents/\Scontents*take optional[...]then a standard or verbatim arg;\typestored/\getstored/\mergesc/\meaningsc/\foreachsctake optional[...]then a{seq}; a flush following sentence stays on its own line
Regiony prozy (przeformatowywane)¶
Tekst główny pomiędzy elementami strukturalnymi
\caption{...}long argument inside figure/table (tree-sitter caption curlygroup)
Markdown (--format markdown)¶
Regiony strukturalne (zachowane)¶
Front matter (
---lub+++na początku pliku)Full ATX heading lines (
#…######including title text)Puste nagłówki ATX (linia znacznika bez tekstu tytułu) pozostają Structure
Setext headings (title line plus
====or —— underline)List item markers (
-,\*,+,1.); continuation sentences hang at the marker widthPuste znaczniki listy (także w cytacie) pozostają Structure
Definition-list terms and
: = markers (pulldown =ENABLE_DEFINITION_LIST); the body hangs at the marker widthBlockquote markers (
>/ nested => > =); continuation sentences repeat the quote prefixGFM alert type markers (
[!NOTE]/[!TIP]/[!WARNING]/[!CAUTION]/[!IMPORTANT]); the body hangs and splits like a quoteDefinicje odwołań do łączy (
[label]: dest); cel może być w następnej linii. Definicja wewnątrz akapitu pozostaje ProseDefinicje przypisów GFM (
[^label]:); znacznik jest Structure, a treść wisiHard line breaks (two trailing spaces, or a trailing backslash)
HTML comments (
<!-- ... -->, including multiline);<!-- snapper:off -->/<!-- snapper:on -->remain pragmasZamknięte bloki HTML typu 6 i 7 kończą się na pasującym tagu zamykającym; następująca proza pozostaje Prose
Void type-6 tags (
<hr>/<col>/<link>/<base>) end on the tag line; they have no closer, so leftover following prose stays Prose even without a blankPipe tables
Code regions (fenced ``` / ~~~)¶
Opening and closing fence lines are structure
Indented fence bodies preserve indentation on reflowed comment lines
Language from the fence info string selects
[code.<lang>]; unknown or missing lang passes the body through unchanged (unless--format-codeis not applicable without a formatter entry)
Regiony prozy (przeformatowywane)¶
Tekst akapitowy
List item text (after the marker); continuation sentences hang at the marker width
Definition-list body (after the =: = marker); continuation sentences hang at the marker width
Treść definicji przypisu GFM (po
[^label]:); kolejne zdania wiszą na szerokości znacznikaBlockquote inner text (after the
>marker); continuation sentences repeat the quote prefix
Tokeny inline (zachowane jako niepodzielne)¶
Emphasis:
\*em*,\*\*strong**(CommonMark flanking; a period inside the span does not split)Strikethrough:
~~strike~~(GFM)Inline code: a run of
nbackticks closes on the next run of the same lengthLinks and images:
[text](url),Inline math:
$...$/$$...$$
reStructuredText (--format rst)¶
Regiony strukturalne (zachowane)¶
Non-code opaque directives (
.. math::,.. image::,.. raw::,.. include::,.. csv-table::) and their indented bodiesContainer directive openers (
.. note::,.. warning::,.. figure::,.. topic::,.. sidebar::,.. container::, leftover.. parsed-literal::,.. epigraph::,.. highlights::,.. pull-quote::,.. compound::,.. header::,.. footer::) and their:option:fields; the indented body is proseTreść w tej samej linii po
::na tych kontenerach, leftover.. parsed-literal::,.. header::,.. footer::,.. |name| replace::oraz pola.. meta::wisi i dzieli się. Wyrównane pola bibliograficzne zamykają leftover metaLiteral blocks (text after
::with indented or line-prefix-quoted content)Section titles and underlines (
===,-----, etc.). A wrap cut that would park a solid DocutilsBody.lineadornment at column 0 skip-cuts the token onto the previous line (snapper-7xd3)Field lists (
:Author:,:Date:, etc.)Puste elementy listy, puste otwarcia doctest i puste znaczniki field-list na EOL pozostają Structure
Comments (
..without a directive)Grid and simple tables (lines starting with
|or+)
Code regions (.. code-block:: LANG)¶
Directive line and trailing blank handling stay structure
Indented body uses the language token for
[code.<lang>]comment reflow and optional--format-code
Regiony prozy (przeformatowywane)¶
Paragraph text between structural elements
Indented bodies of container directives (admonitions, figure captions, topic, sidebar, container, leftover parsed-literal, epigraph, highlights, pull-quote, compound); hang spaces stay structure
Tokeny inline (zachowane jako niepodzielne)¶
Substitution references:
|fig. 1|/|version|/|name|_/|name|__(Docutils Inliner.substitutionref). Interior punctuation is not a sentence or wrap boundary. The use stays Prose, not Structure (line-block is|plus space or EOL)
Auto-detection¶
Extensions: .rst, .rest
Zwykły tekst (--format plaintext)¶
Całość traktowana jako proza. Puste linie są zachowane jako separatory akapitów.
Wykrywanie zdań¶
snapper uses Unicode UAX #29 sentence boundary detection as a baseline (or optional --neural / nnsplit), then applies the same post-pipeline: abbreviation merges, then delimiter-span rejoin so dialogue and balanced ()[]{} spans are not fractured.
Delimiter-span policy (residual cases)¶
Balanced ASCII/curly/guillemet quotes, LaTeX double-backtick quotes, and
()[]{}must not gain a semantic line break mid-span (seetests/sentence_delim_props.rs).Unclosed
"(or open‘without’) glues the rest of the paragraph; snapper does not invent closers.Nested semantic ASCII quotes (
say "hi" nowwith an inner pair) remain toggle-ambiguous; prefer typographic quotes or escapes in source.Apostrophes in contractions (
don't,it's) are not treated as dialogue openers.Markdown fences (three backticks) are not treated as LaTeX double-backtick openers.
--neuralruns the same abbreviation + span post-pipeline after the model proposes cuts (English papers can still prefer the rules path for fully offline, deterministic CI).
snapper merges false splits caused by known abbreviations:
Tytuły¶
Mr., Mrs., Ms., Dr., Prof., Sr., Jr., St., Rev., Gen. itp.
Naukowe¶
Fig., Figs., Eq., Eqs., Ref., Refs., Tab., Sec., Ch., Vol., No., Thm., Lem., Prop., Def., Cor., Rem., Ex.
Łacińskie¶
e.g., i.e., et al., cf., etc., viz., ibid., ca., approx.
Pojedyncze inicjały¶
A., B., C., … Z.
Data i czas¶
Jan., Feb., …, Dec., Mon., Tue., …, Sun., a.m., p.m.
Quoted and parenthesized punctuation¶
Sentence punctuation inside quotes or parentheses does not trigger a false split when the next word starts lowercase.
For example, He said "wow!" and left. stays on one line because "!" followed by lowercase and signals a continuation, not a new sentence.
Patterns handled: !", ?", .", !), ?), .), and similar combinations with single quotes or brackets.