You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: enhance documentation generation workflow with improved file processing and Liquid syntax handling
- Simplified the handling of PAGE_TEMPLATES.md by replacing complex commands with safer methods for Liquid syntax replacement.
- Streamlined the processing of markdown files to ensure proper HTML link conversion and front matter injection.
- Improved escaping of Liquid tags outside code blocks while preserving their integrity within code sections.
# Create a temporary file for the jsonc replacement
100
+
cat > replacement_jsonc.txt << 'EOT'
101
+
```jsonc
102
+
{
103
+
// This example shows how a Html (guidance) component can use the available filters
104
+
"title": "Template example for <!-- {{ WmHfSb }} -->?",
105
+
"path": "/example",
106
+
"components": [
107
+
{
108
+
"title": "Html",
109
+
"type": "Html",
110
+
"content": "<p class=\"govuk-body\">Example content (Liquid syntax removed for docs)</p>"
111
+
}
112
+
]
113
+
}
114
+
```
115
+
EOT
83
116
84
-
# Replace problematic jinja2 code block
85
-
awk -v RS='```jinja2' -v ORS='```jinja2' 'NR==1{print} NR==2{print "\n<!-- Liquid template example (commented out for Jekyll compatibility):\n<p class=\"govuk-body\">\n {# Use Liquid\\'s `assign` to create a variable... #}\n {%- assign inEngland = \"/are-you-in-england\" | page -%}\n\n {# Use the reference to `evaluate` the title #}\n {{ inEngland.title | evaluate }}<br>\n\n {# Use the href filter to display the full page path #}\n {{ \"/are-you-in-england\" | href }}<br>\n\n {# Use the `answer` filter to render the user provided answer to a question #}\n {{ \\'TKsWbP\\' | answer }}\n</p>\n-->"; next} 1' "$filename" > "${filename}.tmp1"
117
+
# Use sed to replace the blocks - this is much safer than complex awk commands
118
+
# First find line numbers of the start and end of the blocks
awk -v RS='```jsonc' -v ORS='```jsonc' 'NR==1{print} NR==2{print "\n{\n // This example shows how a Html (guidance) component can use the available filters\n \"title\": \"Template example for <!-- {{ WmHfSb }} -->?\",\n \"path\": \"/example\",\n \"components\": [\n {\n \"title\": \"Html\",\n \"type\": \"Html\",\n \"content\": \"<p class=\\\"govuk-body\\\">Example content (Liquid syntax removed for docs)</p>\"\n }\n ]\n}"; next} NR==3{print} NR>3{print RS $0}' "${filename}.tmp1" > "${filename}.tmp2"
0 commit comments