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

Indented code block is not working properly #283

Open
ypyl opened this issue Jan 17, 2025 · 0 comments
Open

Indented code block is not working properly #283

ypyl opened this issue Jan 17, 2025 · 0 comments

Comments

@ypyl
Copy link

ypyl commented Jan 17, 2025

Hello, thank you for the great library!

Not sure how to properly set up library to correctly identifier code blocks like (where code is indented)

### Sample Code Review

1. **Variable Naming:**
   - **Observation:** The variable `total` is used to store the sum of the prices and their tax. While it is functional, the name could be more descriptive.
   - **Suggestion:** Consider renaming `total` to `total_price` to make the variable name more explicit and aligned with its purpose.

   **Updated Code:**
   ```python
   total_price = 0

Is there any particular reason why findCompleteCodeBlock and codeBlockLookBack contain regex that ignores spaces before ```?
e.g. would it be useful to modify findCompleteCodeBlock to have

const regex = new RegExp(
    `${startEndGroup}.*\n([\\s\\S]*?)\n\\s*${startEndGroup}`,
  );

and codeBlockLookBack

export const parseCompleteMarkdownCodeBlock: ParseFunction = (
  codeBlock,
  userOptions,
) => {
  const options = getOptions(userOptions);
  const startEndGroup = getStartEndGroup(options.startEndChars);
  return parseMarkdownCodeBlock(codeBlock, startEndGroup, `\n\\s*${startEndGroup}`);
};

export const parsePartialMarkdownCodeBlock: ParseFunction = (
  codeBlock,
  userOptions,
) => {
  const options = getOptions(userOptions);
  const startGroup = getStartEndGroup(options.startEndChars);
  const endGroup = `(\n\\s*${options.startEndChars
    .map((char) => `${char}{0,2}$`)
    .join("|")}|$)`;
  return parseMarkdownCodeBlock(codeBlock, startGroup, endGroup);
};

Or am I just missing something here and it will break something else? Actually, GitHub has the same issue with indented code blocks and I am assuming there is a reason for that.
Thank you

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

1 participant