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

fix: formatting YAML properties and exporting a cjs build #12

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

adamdehaven
Copy link
Contributor

@adamdehaven adamdehaven commented Jan 14, 2025

Fixes

  • Fixes YAML block property indentation for nested block components
  • Fixes markdown unordered list, ordered list, and task list indentation

Refactor

  • Refactored the folding range provider to use and export an isomorphic getDocumentFoldingRanges function

Chore

  • Augments the build process:
    • Move the unbuild config to a file (for readability).
    • Export CommonJS build artifact for use in https://github.com/nuxtlabs/vscode-mdc to allow a single source of truth for the formatter utility.

I'm utilizing the exported formatter and getDocumentFoldingRanges functions in nuxtlabs/vscode-mdc#41 in order to source the MDC formatting and folding logic from a single source of truth rather than replicating the code there.

The formatter function should remain "unbound" to the monarch (or textmate) language, as it can be used standalone as a utility for properly formatting MDC strings in any downstream project.

adamdehaven added a commit to adamdehaven/vscode-mdc that referenced this pull request Jan 14, 2025
This PR depends on nuxtlabs/monarch-mdc#12 to
export a cjs build in order to consume the formatter from a single
source of truth.
Fix formatting YAML props in nested block components.

Output a CommonJS module in addition to ESM, primarily for utilizing
the formatter function in @nuxtlabs/vscode-mdc.
@adamdehaven
Copy link
Contributor Author

@farnabaz anything else I can do for this PR? I’d like to pick up the formatting fix in my downstream repo

@adamdehaven adamdehaven marked this pull request as draft January 30, 2025 18:50
@adamdehaven adamdehaven marked this pull request as ready for review January 30, 2025 19:54
@farnabaz
Copy link
Collaborator

farnabaz commented Feb 5, 2025

Thanks @adamdehaven and sorry for keeping you waiting

I checked the changes and it LGTM.

My main concern however is to define a standard spec for formatting. Soon we will have a linter (it is WIP) and we should use the same spec for both. Besides these two we should respect the standard markdown spec which is supported by lots of libraries, linters, and formatters. This way we provide consistency between tools.

Before merging: I'll add some tests to check the formatted markdown with markdownlint and ideally some tests with Prettier for basic markdown usage.

@adamdehaven
Copy link
Contributor Author

and ideally some tests with Prettier for basic markdown usage

My only concern here is that Prettier itself is opinionated and oftentimes conflicts with other lint rules, e.g. ESLint

@farnabaz
Copy link
Collaborator

farnabaz commented Feb 6, 2025

@adamdehaven With my latest commit, are you happy with removing formatter.spec.ts?

@adamdehaven
Copy link
Contributor Author

@farnabaz yep works for me!

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.

2 participants