Skip to content

Added support for @@include tag which will allow embedding html files from the '_partial' folder#27

Closed
seemantr wants to merge 1 commit intoFransBouma:masterfrom
FlexSearch:feature-include
Closed

Added support for @@include tag which will allow embedding html files from the '_partial' folder#27
seemantr wants to merge 1 commit intoFransBouma:masterfrom
FlexSearch:feature-include

Conversation

@seemantr
Copy link
Copy Markdown
Contributor

@seemantr seemantr commented Mar 5, 2016

Include tag allows embedding file into the generated document. This is very useful if you want to embed the same text more than once across different pages. This is a very simplistic implementation which does not require changes to the underlying Markdown parser and uses regex expression.

@FransBouma
Copy link
Copy Markdown
Owner

Ah I was under the impression it included markdown snippets :) (so it would parse the markdown file first for includes, parse those for includes using a set of already includes to avoid cycles etc. till no includes are found, merge included markdown in-place, then return that as the markdown to use). (which would require markdown parser adjustments)

Having @@include include literal fragments would make that of course not possible anymore. Hmm... Not sure what the best option is. @@include-html or @@includeliteral or @@includefragment all sound verbose.

It also might be done on-the-fly though: @@include("bla.md") is included into the markdown as-is, but so is @@include("bla.htm"). So before parsing/handling markdown. The markdown parser can deal with html, so that's not a problem (although I haven't tested that in full, e.g. a markdown pre block whether that's still converted or not I don't know). IF the markdown parser can deal with it without a problem, a recursive include is best, before parsing.

What are your thoughts on this?

@seemantr
Copy link
Copy Markdown
Contributor Author

seemantr commented Mar 6, 2016

I feel @@include on the fly is the best option as it is very simple to implement without touching the markdown parser. I really like the idea of embedding the source content before handing things over to markdown parser, that way the same include block can support both html and markdown.

Should be a very simple change. I will make it and submit a new pr. I can use the same approach for adding support for @@render tags also.

@FransBouma
Copy link
Copy Markdown
Owner

Sounds good! Your regexp version does a 1 level include I think? (the included markdown isn't parsed for include statements again). That's fine though, it can always be extended to be a recursive include :)

@seemantr seemantr closed this Mar 7, 2016
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