Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support parts from more file formats #402

Open
dwang20151005 opened this issue Oct 25, 2022 · 1 comment
Open

support parts from more file formats #402

dwang20151005 opened this issue Oct 25, 2022 · 1 comment

Comments

@dwang20151005
Copy link

Hi, may I contribute a PR to add support for quoting parts from file
formats other than ocaml and shell?

We internally use mdx to write documentation, some of which benefits
from quoting other file types. I sometimes work around this by using
other preprocessors (e.g., cinaps) to generate both the mdx and the
source file. But also I sometimes try to keep docs up to date manually
instead, and then they get stale and users are confused. :-(

Anyway, I have a working implementation which adds support for several
common file types, based on the file name extension:

| "c" | "cpp" | "h" | "hpp" | "java" | "js" -> Some slash_star_and_star_slash
| "hs" -> Some double_dash_and_nothing
| "html" | "md" | "mdx" -> Some html_style
| "org" | "py" | "sh" | "t" -> Some hash_and_nothing

It allows the user to specify additional comment syntaxes in-line by
adding comment-begin and (optionally) comment-end attributes. E.g.,

<!-- $MDX file=./foo.bat,part=part1,comment-begin=REM -->
<!-- $MDX file=./foo.clj,part=part1,comment-begin=(comment,comment-end=) -->

Limitations:

  1. MDX part delimiters must be single-line comments that take up a
    whole line (modulo whitespace), even when the underlying syntax
    supports multiline comments and mixed code/comment lines.

    (This might be fixed by $MDX delimiters in ocaml cut off any code on the same line #374 / Add prefix of the part-end delimiter to the part #387 . I was experimenting with an
    older vendored copy and haven't rebased yet.)

  2. Comment-begin and comment-end values may not include commas.

These are not fundamental, only consequences of existing
implementation details in the parsing code.

Happy to rebase and submit a PR if this sounds in principle like a
change you would accept.

@askvortsov1
Copy link

askvortsov1 commented Mar 8, 2023

As a fellow MDX user, this would be pretty cool! For my use case, it would be nice to insert content from other .md and .mdx files as block quotes.

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

No branches or pull requests

2 participants