-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Like Transforms but for preprocessing instead of postprocessing #2587
Comments
I really like this request and my first thought would be something like transforms but for preprocessing instead of postprocessing files. If something like this is implemented, we should clearly document that imported things after the post processing stage (like a nunjucks import) will not be affected by this (or at least I think it shouldn't be affected). Also this type of "scripts with docs" is also really common in other filetypes like Jupyter Notebooks, MatLab files, or others. Supporting these documentation generating purposes could be really interesting and open up 11ty to other usecases. |
I think the best solution here would be to expose an API that provides the equivalent of |
Considerations for this feature:
Moving this to the enhancement queue.
|
@zachleat Thanks for looking into it.
I believe this should come first because the goal is to prepare the input and then forward it to a "default" template engine.
Regarding both the following comments:
Since I opened this issue, I was able to improve the situation in my code. In the past, I had to re-instantiate the differents const markdownContent = transformFsxToMarkdown(content);
const markdownText = await eleventyConfig.getFilter("renderTemplate")(markdownContent, "md");
// Replace " with " because some markdown renderers escape the quotes
// and it breaks the nunjucks compilation
const fixedMarkdownText = markdownText.replace(/"/g, '"');
return await eleventyConfig.getFilter("renderTemplate")(fixedMarkdownText, "njk"); This makes the code much easier to work with and a little bit less brittle. I still had some stuff breaking when upgrading to the latest alpha of Eleventy but it was probably because I don't always provide the actual page data/context or fake it correctly depending on where I am calling these functions. |
I believe #3298 solves this (with the approach @j-f1 suggested). For folks that want this, please follow along to #3298 (which is coming to 3.0 soon). With that issue shipping soon and your comments regarding finding a workaround @MangelMaxime, I don’t think we need this on the enhancement queue any more either? |
#3298 is shipping with 3.0.0-alpha.11 |
@zachleat I need to give it a try but from what I understand yes. |
I do also want to cross-link one of the highest ranking issues on the enhancement queue (#188) too |
Is your feature request related to a problem? Please describe.
In some languages, it is possible to embed documentation inside of a script file so user can benefit from compiler type checking when writing their documentation/blog post.
For example, in F# you can write a "real F# script" like that:
and once transformed by a tool/plugin it could become something equivalent to that:
Describe the solution you'd like
I would like the ability to pre-process a file to transform it into markdown for example, and then have the standard eleventy pipeline kicks in to benefit from all the features.
In the past, I opened a discussion to ask for help on how to workaround front-matter/plugins limitations. #2505
But after, coming back to it, I do think that this could be a more generalised need in order to support literate programming for languages that supports it.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
I tried to use the plugin system but I found 2 problems:
(***
and***)
to have valid F# code I need to use these delimiters even in the markdown files, which leads to bad tooling experience for the userAnother, alternative I can think of would be to have a tool running before/side by side with eleventy which would transorm all
script1.fsx
into ascript1.fsx.md
so Elventy would see thescript1.fsx.md
as a normal file.And I would probably be able to add
*.fsx.md
to the.gitignore
configuration file.However, looks more like a hack than a transparent user experience.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: