Uh oh!
There was an error while loading. Please reload this page.
Write engine: stop the converter destroying content, add unlisted drafts - #48
Merged
Conversation
The converter turns anything it does not recognise into literal text, and the serializer then escapes its `<` — so an unhandled construct is not ignored on the way in, it is destroyed on the way out. Posts written here always came from the editor, so this stayed latent; a hand-edited index.mdx triggers it. Round-trip fixes: - Escaped delimiters. Every inline pattern now carries `(?<!\\)`. Without it `\$4.00 … \$8.00` matched as math, because the escaping backslash is itself the non-space character the closing delimiter requires. escapeProse escapes `$` for the same reason it escapes `*`, and unescapeProse reverses it. - Inline HTML. <strong>/<b>, <em>/<i>, <s>/<del>, <code> and <u> now read back as styles instead of surviving as text. - Colour spans, read back to their palette names. - Bare YAML flow lists — `tags: [a, b]` no longer fails JSON.parse. - <details>, <Gallery>, <Video>, self-closing <Figure> and local <Image>, none of which the converter could read even though the serializer emits them. - Soft breaks and paragraphs opening with a tag. - Anything still unrepresentable raises a named warning before publish. Divergence detection: index.mdx is what the site builds from, so where it and .write-source.json disagree the markdown wins. Publishing regenerates index.mdx wholesale, so a sidecar left stale by an outside edit would silently revert it. Drafts: `draft: true` now builds and answers at its real URL, but is held out of every listing, the sitemap, RSS and search, and carries a noindex. /drafts lists them; each row and the post itself link into /write with the box unticked. Previously a draft did not build at all. Two deliberate behaviour changes, both covered by updated tests: dollar amounts are now escaped on the way out (`$4-$8` was otherwise unstable across a round-trip), and cover/ogCard/draft frontmatter is read back rather than reset.
Deploying mlsystems with |
| Latest commit: | 010dcfa |
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c71abe64.mlsystems.pages.dev |
| Branch Preview URL: | https://feat-write-engine-parity.mlsystems.pages.dev |
Tip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the write engine up to parity with the fixes and features developed on the sibling site, adapted to this repo's schema (blogs only,
summary/topicId/authorskept as-is). No configurable date — publish dates stay derived, not author-controlled.Why
The converter turns anything it doesn't recognise into literal text, and the serializer then escapes its
<. So an unhandled construct isn't ignored on the way in — it's destroyed on the way out. Posts here have always originated in the editor, which is why this stayed latent. The moment someone hand-edits anindex.mdx(or an agent writes one), reopening and republishing eats content.Round-trip fixes
(?<!\\)on every inline delimiter\$4.00 … \$8.00parsed as math — the escaping backslash is itself the non-space char the closing delimiter needs<strong>/<b>,<em>/<i>,<s>/<del>,<code>,<u><strong>tags: [a, b]bare YAMLJSON.parsethrew, post wouldn't open<details>,<Gallery>,<Video>, self-closing<Figure>, local<Image>Divergence detection
index.mdxis what the site builds from, so where it and.write-source.jsondisagree, the markdown wins. Publishing regeneratesindex.mdxwholesale, so a sidecar left stale by an outside edit would silently revert it. The editor re-serialises the sidecar, compares bodies, and reloads from markdown with a notice when they differ.Drafts
draft: truepreviously excluded a post fromgetStaticPaths— it didn't build at all. Now it builds and answers at its real URL, but is held out of every listing, the sitemap, RSS and search, and carriesnoindex./draftslists them (itself noindexed and out of the sitemap); each row and the post's own banner link into/writewith the draft box unticked and the page scrolled to the actions.Two deliberate behaviour changes
Both have updated test coverage — worth a look during review:
$5 and $10passes through bare. That's safe in isolation, but$4-$8has no space before the closing$, so it matches as math and the round-trip is unstable. Escaping makes it stable; rendered output is identical.cover,ogCardanddraftfrontmatter are read back instead of being reset to defaults on reopen.I deliberately did not port the stricter colour handling from the sibling repo — free-form hex/rgb from pasted markup still works here, and its test is untouched.
Verification
npm test— 84 passedastro check— 0 errors, 0 warningseslint --max-warnings 0— cleannpm run build— cleannoindexpresent, absent from sitemap //blog/ RSS / homepage / tags / pagefind, present on/drafts, publish deep-link correct, and published posts still in the sitemap