Skip to content

Fix: Fix conversion of subpages of pages with titles ending with a period - #196

Open
El1as42 wants to merge 2 commits into
theohbrothers:masterfrom
El1as42:fix/fix-conversion-of-subpages-of-pages-with-titles-ending-with-a-period
Open

El1as42 wants to merge 2 commits into
theohbrothers:masterfrom
El1as42:fix/fix-conversion-of-subpages-of-pages-with-titles-ending-with-a-period

Conversation

@El1as42

@El1as42 El1as42 commented Oct 12, 2026 •

Copy link
Copy Markdown

Fixes #197

Subpages fail to convert when their parent page's title ends with a period (e.g. Mult. Diff.).

Cause: Windows strips trailing periods from file and folder names. The subpage folder is created as Mult.-Diff by New-Item and pandoc, but on Powershell 5 the .md is then read via the long path \\?\...\Mult.-Diff.\Extrema.md, which keeps the period. Every subpage then fails with:

Failed to rename image references to ... Exception: An object at the specified path \\?\C:\...\Mult.-Diff.\Extrema.md does not exist ...
Failed to mutate markdown content: An object at the specified path \\?\C:\...\Mult.-Diff.\Extrema.md does not exist ...

These pages end up with no heading and broken image references.

Changes

  • Remove-InvalidFileNameChars: remove trailing periods and spaces.
  • Truncate-PathFileName: remove trailing periods and spaces left by truncation ($mdFileNameAndFolderNameMaxLength).
  • Separate commit: include the markdown file path in the Failed to mutate markdown content error, since some exceptions (e.g. Windows Defender blocking a file) don't mention it.

Tests: unit tests for both functions, a New-SectionGroupConversionConfig test with a page and subpage whose titles end with a period, and a test for the error message. The new trailing-period tests fail without the fix. Unit tests pass on Windows PowerShell 5.1 and PowerShell 7.0. In this repo's CI (run on my fork), all jobs that can currently run pass: Windows PowerShell 5.1 (windows-2022) and PowerShell 7.1 to 7.4. The other jobs currently fail for any PR, before checkout: the windows-2019 runner image was retired, and the PowerShell 6.0 to 7.0 container images are too old for actions/checkout (GLIBC_2.28' not found).

🤖 Generated with Claude Code

El1as42 and others added 2 commits October 12, 2026 18:46
…riod

Windows strips trailing periods (and spaces) from file and folder names. A page titled e.g. `Mult. Diff.` had its subpage folder created as `Mult.-Diff` by `New-Item` and pandoc, but on Powershell 5 its subpages were then read via the long path `\?\...\Mult.-Diff.\subpage.md`, which does not strip the period. This failed with `Cannot find path ... because it does not exist`, leaving image references and markdown content unprocessed.

Now trailing periods and spaces are removed from file and folder names, including names truncated by `$mdFileNameAndFolderNameMaxLength`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t mutation fails

Some exceptions do not mention the file path (e.g. when Windows Defender blocks a file: `Operation did not complete successfully because the file contains a virus or potentially unwanted software`), making it impossible to tell which page failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@El1as42 El1as42 changed the title Fix conversion of subpages of pages with titles ending with a period Fix: Fix conversion of subpages of pages with titles ending with a period Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subpages of pages with titles ending with a period fail to convert on Powershell 5

1 participant