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

feat: replace relative path to path trace logic for included #556

Merged

Conversation

makamekm
Copy link
Contributor

@makamekm makamekm commented Nov 7, 2024

No description provided.

@makamekm
Copy link
Contributor Author

makamekm commented Nov 8, 2024

Algorithm:

md2md:

  • includes/collect
    1. it runs 'recursive' function to collect all includes
    2. It creates the hash (ex. ./a.md:../_includes/b.md) from const key = [...includedParentPath, relativePath];
    3. If if finds include then it propagates relativePath into the children witch calls copyFile and transform(includedParentPath: key)
    4. It stores the data into the map
    5. At the end it writes the stored map into the pattern {% included (${includedRelativePath}) %}\n${includeContent}\n{% endincluded %}

md2html:

  • Before parsing the content it runs preprocessors by passing md state and options. (src/transform/yfmlint/index.ts, src/transform/md.ts, src/transform/utilsFS.ts)
    1. It finds included pattern and parse the path into absolute one by reducing the includePath array via let includePath = getFullIncludePath(includePaths[0], root, path);
    2. It stores the parsed data into md.included[includePath] = data;
  • Includes/index & links/index
    1. It checks the existed data at const included = md.included?.[pathname]; and then passes it to getFileTokens

@makamekm makamekm force-pushed the replace-relative-path-to-path-trace-logic-for-included branch from 2df2018 to 83287f9 Compare November 8, 2024 09:58
@makamekm makamekm merged commit a3d8f52 into master Nov 13, 2024
1 check passed
@makamekm makamekm deleted the replace-relative-path-to-path-trace-logic-for-included branch November 13, 2024 09:18
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