I’m looking for a way to print the markdown content from a file.
We’d like to use a custom output format to create a markdown file combining all the pages in a section, then build a PDF from that combined file. We got as far as looping through the pages and printing each title into the file, but not sure about how to print the body, without html tags.
{{ .Content }} results in HTML tags, and {{ .RawContent }} seems to bring in the front matter. Any advice is greatly appreciated!
For the files in the “input-files” folder, we’re using a JSON frontmatter with multiple fields and generate a table from these in the output using the layout files in layouts/input-files. Maybe this is why .RawContent doesn’t work as expected.
To create the file combining all topics in the section:
There’s a custom output format called “MINE”, linked to a mediatype with suffix “md”, and a layout for type “list” (to loop over pages) in the folder layouts/_default/list.mine.md
I’m trying to add the “print_content” template bit to this file. I found a way to generate the markdown table from the frontmatter fields, but don’t know how to pull in the content itself.
Does anyone have experience with this?
Thanks for having a look and let me know if I didn’t explain something clearly enough!
if you are only putting the frontmatter inside markdown file, make sure after the frontmatter you add newline \n.
As i can see here in sandbox/user/content/input-files/common/fx-rates.md, you only put the frontmatter without any content. please add newline after the frontmatter last curly bracket.
{
"title":"File B"
...
}
now hugo wil treat it as frontmatter, and .RawContent will work.