Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- name: Run Clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: Run tests
if: github.event_name == 'push'
run: cargo test --workspace --locked

publish:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Test

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
Expand All @@ -26,3 +28,15 @@ jobs:
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: Run tests and require complete region coverage
run: cargo bake --locked test:coverage --package bake-markdown --all-targets true --all-features true

test-result:
if: always()
needs: [test]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Require successful tests and coverage
env:
JOB_RESULTS: ${{ toJSON(needs) }}
run: |
echo "$JOB_RESULTS" | jq -e 'all(.[]; .result == "success")'
30 changes: 8 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bake-markdown"
version = "0.3.0"
version = "0.3.1"
edition = "2024"
rust-version = "1.85"
license = "MIT"
Expand All @@ -25,3 +25,6 @@ socketry-markdown = "0.3.0"

[dev-dependencies]
tempfile = "3.27"

[patch.crates-io]
bake-markdown = { path = "." }
4 changes: 2 additions & 2 deletions bake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ edition = "2024"
publish = false

[dependencies]
bake = ">=0.19.0"
bake = "0.19"
bake-markdown = { path = ".." }
socketry-project = ">=0.3.3"
socketry-project = ">=0.3.7"
23 changes: 4 additions & 19 deletions context/markdown-normalization.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
# Markdown Normalization

`bake-markdown` exposes `normalize_document` for Rust callers and the
`markdown:normalize` Bake task for project files. Normalization parses
CommonMark, GitHub Flavored Markdown, YAML and TOML front matter, and math,
then serializes it with soft source line breaks joined as spaces. This keeps
inline code and other parsed syntax such as tables, task list state, footnotes,
strikethrough, code blocks, and math in the syntax tree for serialization.
Rust callers can select another syntax with `normalize_document_with_options`,
such as MDX.
`bake-markdown` exposes `normalize_document` for Rust callers and the `markdown:normalize` Bake task for project files. Normalization parses CommonMark, GitHub Flavored Markdown, YAML and TOML front matter, and math, then serializes it with soft source line breaks joined as spaces. This keeps inline code and other parsed syntax such as tables, task list state, footnotes, strikethrough, code blocks, and math in the syntax tree for serialization. Rust callers can select another syntax with `normalize_document_with_options`, such as MDX.

The serializer preserves explicit Markdown hard breaks, code contents, and
block boundaries. YAML and TOML front matter are parsed as front matter so
their delimiters and content remain intact. The serializer canonicalizes
line endings to LF and emits a trailing newline for non-empty documents. The
normalizer does not wrap paragraphs to a target line width. It uses the
serializer's default `-` marker for unordered lists.
The serializer preserves explicit Markdown hard breaks, code contents, and block boundaries. YAML and TOML front matter are parsed as front matter so their delimiters and content remain intact. The serializer canonicalizes line endings to LF and emits a trailing newline for non-empty documents. The normalizer does not wrap paragraphs to a target line width. It uses the serializer's default `-` marker for unordered lists.

The task accepts one or more positional paths, resolved relative to the Bake
project root. For example, the shell expands a glob before Bake receives the
paths:
The task accepts one or more positional paths, resolved relative to the Bake project root. For example, the shell expands a glob before Bake receives the paths:

```sh
cargo bake markdown:normalize **/*.md
```

Use `::` before another task because the variadic path list consumes all
positional values up to the end of the command:
Use `::` before another task because the variadic path list consumes all positional values up to the end of the command:

```sh
cargo bake markdown:normalize **/*.md :: null
Expand Down
20 changes: 4 additions & 16 deletions license.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# MIT License

Copyright, 2026, by Samuel Williams.
Copyright, 2026, by Samuel Williams.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 changes: 14 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# `bake-markdown`

Markdown normalization for Bake projects. It joins soft source line breaks in
Markdown files while preserving explicit hard breaks, code, and block
boundaries.
Markdown normalization for Bake projects. It joins soft source line breaks in Markdown files while preserving explicit hard breaks, code, and block boundaries.

## Motivation

Hard-wrapped paragraphs are difficult to edit consistently. This crate uses
the `socketry-markdown` syntax tree and serializer so normalization follows
Markdown structure instead of changing lines with regular expressions.
Hard-wrapped paragraphs are difficult to edit consistently. This crate uses the `socketry-markdown` syntax tree and serializer so normalization follows Markdown structure instead of changing lines with regular expressions.

## Usage

Expand All @@ -34,8 +30,19 @@ Rust callers can use `bake_markdown::normalize_document` directly.
## Releases

<!-- bake-readme:releases:start -->

See [releases.md](releases.md) for the full release history.

### v0.3.1

- Resolve development task dependencies to the current checkout.

- Adopt `socketry-project` 0.3.7 for shared project tasks and Markdown normalization.

- Require the aggregate test and coverage result for pull request merges.

- Avoid duplicate ordinary test runs in pull request publishing checks.

### v0.3.0

- Normalize unordered Markdown lists with hyphen markers.
Expand All @@ -44,10 +51,6 @@ See [releases.md](releases.md) for the full release history.

- Accept Markdown paths as positional arguments to `markdown:normalize`.

### v0.1.0

- Add the `markdown:normalize` task to join soft source line breaks in Markdown
files while preserving explicit hard breaks, code, and block boundaries.
<!-- bake-readme:releases:end -->

## See Also
Expand All @@ -60,4 +63,4 @@ Please open an issue or pull request on [GitHub](https://github.com/socketry/bak

### Agent Context

Before contributing, read `.agents/context/index.md` and the relevant context files it links. If the index is missing or out of date, run `cargo bake agent:context:install` to install context from dependencies and refresh the index.
Run `cargo bake agent:context:install` to install shared context and skills. Read `.agents/context/index.md` to find relevant guides, follow `agents.md` if present, and apply skills under `.agents/skills/`. The installer preserves repository-owned `agents.md`; it does not create or regenerate that file.
13 changes: 11 additions & 2 deletions releases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Releases

## v0.3.1

- Resolve development task dependencies to the current checkout.

- Adopt `socketry-project` 0.3.7 for shared project tasks and Markdown normalization.

- Require the aggregate test and coverage result for pull request merges.

- Avoid duplicate ordinary test runs in pull request publishing checks.

## v0.3.0

- Normalize unordered Markdown lists with hyphen markers.
Expand All @@ -10,5 +20,4 @@

## v0.1.0

- Add the `markdown:normalize` task to join soft source line breaks in Markdown
files while preserving explicit hard breaks, code, and block boundaries.
- Add the `markdown:normalize` task to join soft source line breaks in Markdown files while preserving explicit hard breaks, code, and block boundaries.
Loading