Skip to content

cmd/scriggo: improve Markdown handling in scriggo serve#996

Open
gazerro wants to merge 4 commits intomainfrom
serve-markdown
Open

cmd/scriggo: improve Markdown handling in scriggo serve#996
gazerro wants to merge 4 commits intomainfrom
serve-markdown

Conversation

@gazerro
Copy link
Member

@gazerro gazerro commented Feb 21, 2026

DO NOT MERGE

cmd/scriggo: improve Markdown handling in scriggo serve

Improve the scriggo serve command handling of Markdown files:

- Serve .md files as-is when explicitly requested (no HTML rendering).

- When a path has no extension, and no corresponding .html file exists 
  but a matching .md file does, render the Markdown and wrap it in a 
  full HTML page before serving.

Closes #974

Previously Markdown-to-HTML conversion after macro calls wrongly used
the caller format instead of the macro format. This caused Markdown
macro output to be lost in HTML contexts.

This commit aligna macro return conversion with call-time semantics so
conversion is driven by the called macro format, and add regression
tests for direct and indirect Markdown macro calls from HTML templates.
Previously template compilation preserved the entry file format even
after rewriting the tree through extends; for example, with 'index.md'
containing '{% extends "layout.html" %}'', the compiled main function
still had Markdown format instead of HTML.

This commit propagates 'tree.Format' while resolving extends chains, so
the compiled main template function reflects the format of the final
extended template.
Implement 'Template.Format', which reports the output format produced
when executing a template.
Improve the scriggo serve command handling of Markdown files:

- Serve .md files as-is when explicitly requested (no HTML rendering).

- When a path has no extension, and no corresponding .html file exists
  but a matching .md file does, render the Markdown and wrap it in a
  full HTML page before serving.

Closes #974
@gazerro gazerro requested a review from zapateo February 21, 2026 21:18
@gazerro gazerro removed the request for review from zapateo February 22, 2026 12:05
Base automatically changed from template-format-method to main February 23, 2026 16:08
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.

1 participant