Skip to content

Support rendering multiple source files in a single session #180

Description

@airvzxf

Summary

mdfried currently accepts a single positional [SOURCE]. A shell
glob like mdfried **/PRO*.md that expands to multiple paths is
rejected with clap's generic error: unexpected argument ... found,
and the user has to either quote the glob or run mdfried once per
file.

This issue asks for first-class multi-source support: pass several
files on the command line, render them in sequence, and place a thin
separator between them so the boundary is visible.

Reproduction

touch a.md b.md
mdfried a.md b.md
# error: unexpected argument 'b.md' found

or, in a tree with multiple matches:

mdfried **/PRO*.md
# error: unexpected argument 'firefox-extension-efficient-tab-manager/PROPOSAL.md' found

Expected

mdfried a.md b.md

should render a.md and b.md in sequence, with a single muted
separator between them that includes the next file's name, e.g.

\u2500\u2500\u2500\u2500\u2500 File: a.md \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
   1 \u2502 # a
   2 \u2502 body of a
\u2500\u2500\u2500\u2500\u2500 File: b.md \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
   1 \u2502 # b
   2 \u2502 body of b

The path in the separator should be exactly what the user typed on the
command line (so a relative glob like firefox-extension-.../PROPOSAL.md
stays relative and scannable), not an absolute / canonicalized path.
Content of each file is unchanged.

Why

This matches the ergonomics of bat, which is the most-cited
alternative when users reach for a glob in the first place. It also
removes the friction of having to wrap shell loops around mdfried
to view a directory of proposals, READMEs, or notes.

Scope (v1)

  • File paths only.
  • Each file's relative ![](img.png) resolves against that file's
    own basepath (so images in subdir/a.md resolve to
    subdir/img.png, not to the first file's basepath).
  • A separator is rendered before every file (including the first),
    matching bat.
  • --watch is rejected when more than one source is passed, with a
    friendly usage error (--watch is only supported with a single source).
  • URLs (http://, https://), github:owner/repo, and -
    (stdin) remain single-source for v1. Mixing them with file paths
    fails with a friendly usage error pointing at the limitation.
  • No new dependencies.

Out of scope (v2 follow-ups)

  • URL / github / stdin mixed with file paths.
  • Multi-file --watch.
  • A multi-file :back history.
  • Per-file deep_fry overrides.

Notes

This issue is independent of #178 / #179 (the friendlier error
message for the current rejection). When this lands, the friendly
error in #179 becomes unnecessary because the rejection no longer
happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions