Support full URL when linking to file within code block
Discussed in https://github.com/imfing/hextra/discussions/799
Originally posted by Aerosand August 27, 2025 https://imfing.github.io/hextra/versions/latest/docs/guide/syntax-highlighting/#link-to-file
The way to link a file in a code block is not convenient now when I write my own docs.
The base_url attribute provides a base URL that will be combined with the file name to generate a link.
Some file url may not follow this kind of format.
Is it more general to use the file's full url directly?
For this issue I am proposing to replace this line:
{{- $file_url := urls.JoinPath $base_url $filename -}}
with the following logic that supports an optional full_url, while also keeping the old logic for base_url + filename:
{{- $file_url := "" -}}
{{- if $full_url -}}
{{- $file_url = $full_url -}}
{{- else if $base_url -}}
{{- $file_url = urls.JoinPath $base_url $filename -}}
{{- else -}}
{{- $file_url = $filename -}}
{{- end -}}
Declaring $file_url first ensures the variable exists before the conditional assignments.
If full_url is provided, it will be used directly. Otherwise, it falls back to combining base_url and filename, or just using filename if no base_url exists. This way the old method still works while also supporting full URLs that do not fit the old standard formatting.
This looks reasonable. Could you please submit a pull request?