frontend: typeset the LaTeX, and let a sentence start a new line
Two things a paper needs that the paragraph model could not express.
**Formulas.** A sentence stores the LaTeX the writer typed — `$\ell$`,
`$$ … \tag{1} $$` — because that is the editable form, and it was being printed
as source. `src/utils/math.ts` now splits a sentence into text and formulas,
gives the formulas to KaTeX and escapes everything else; `math-error` in red
when KaTeX cannot read one, rather than an exception that blanks the paragraph
(the paper in the database has 106 sentences with formulas, 29 of them
display). Four delimiters are recognised — `$$…$$`, `\[…\]`, `$…$`, `\(…\)` —
and an unmatched `$` is left alone instead of swallowing the rest of the
paragraph. A display formula is a block, so it takes its own line and centres
itself without any flagging; text goes through `v-html` escaped, and KaTeX runs
with trust off.
**Line breaks.** A paragraph is its sentences run together, which is right for
prose and wrong for a display formula, a list of items or an author line.
`paper_sentence.line_break_before` is that request: a flag rather than a
newline inside `content`, because content folds its whitespace on purpose (a
sentence really is one line) and because a break hidden in a string is one
nobody can see or remove. It prints a `<br>`, it is a checkbox on the
sentence's row in the editor, and it *replaces* the separator rather than
adding to it — the new line already separates, and a space as well would indent
the line by a blank.
Verified against the real paper in the browser: 214 inline formulas and 29
display formulas typeset with zero failures and no `$$` left on the page; a
sentence flagged for a break lands on its own line while its neighbour stays
inline; the display formula centres on a line of its own and the sentence after
it starts below. 54 paper checks (2 new), 61 reference checks and 76 MCP checks
pass, with `vue-tsc` and the build clean.
Also: `.pnpm-store/` is ignored — pnpm put its content-addressed store in the
project root rather than the home directory.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""give a sentence the option to start a new line
|
||||
|
||||
A paragraph is its sentences concatenated, which is right for prose and wrong
|
||||
for the things a paper also puts inside a paragraph: a display formula, a list
|
||||
of items, an author line. Those want a line break between them, and until now
|
||||
there was nowhere to say so — text pasted with newlines was folded onto one line
|
||||
on purpose, so the writer had no way to ask for one.
|
||||
|
||||
So the sentence carries the request: ``line_break_before`` prints a break before
|
||||
this sentence and nothing else. It is a property of the sentence rather than a
|
||||
character in its content because the content is a sentence — folding whitespace
|
||||
is what keeps it one — and because a break the writer cannot see cannot be
|
||||
removed.
|
||||
|
||||
Existing rows default to 0: today's documents render exactly as they did.
|
||||
|
||||
Revision ID: f8c2d5a73b91
|
||||
Revises: 063f6def01fa
|
||||
Create Date: 2026-09-22
|
||||
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "f8c2d5a73b91"
|
||||
down_revision: str | None = "063f6def01fa"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"paper_sentence",
|
||||
sa.Column(
|
||||
"line_break_before",
|
||||
sa.Boolean(),
|
||||
server_default=sa.text("0"),
|
||||
nullable=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("paper_sentence", "line_break_before")
|
||||
Reference in New Issue
Block a user