From 1a60249cfef4a5afb1d07ce26c2d622ee2838ecf Mon Sep 17 00:00:00 2001
From: Přemysl Eric Janouch <p@janouch.name>
Date: Sat, 5 Mar 2022 12:17:54 +0100
Subject: WIP: hswg: enable preprocessing

WIP: Shouldn't allow it in pass-through mode, at minimum.
---
 hswg/main.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hswg/main.go b/hswg/main.go
index 3c7582e..6afbbd3 100644
--- a/hswg/main.go
+++ b/hswg/main.go
@@ -81,7 +81,12 @@ func Render(r io.Reader, config *configuration.Configuration) (
 	// return
 
 	var doc *types.Document
-	if doc, err = parser.ParseDocument(pr, config); err == nil {
+	var preprocessed string
+	// TODO(p): Ensure that this doesn't pose a security risk.
+	if preprocessed, err = parser.Preprocess(pr, config); err != nil {
+		// Render it raw below.
+	} else if doc, err = parser.ParseDocument(
+		strings.NewReader(preprocessed), config); err == nil {
 		doctype := config.Attributes.GetAsStringWithDefault(
 			types.AttrDocType, "article")
 		problems, verr := validator.Validate(doc, doctype)
-- 
cgit v1.2.3-70-g09d2