{{ $file := print "code/" .Params.file }}
{{ $resource := .Page.Resources.GetMatch $file }}
{{- if eq $resource nil -}}
    {{ $file = print .Params.file }}
    {{ $resource = .Page.Resources.GetMatch $file }}
{{- end -}}
{{- if eq $resource nil -}}{{- errorf "Resource not found '%s'" $file -}}{{- end -}}
{{ $content := $resource.Content }}
{{ $lines := len (findRE "\n" $content) }}
{{- if eq $lines 0 -}}
    {{ $content = print $content "\n\n" }}
{{- else if eq $lines 1 -}}
    {{ $content = print $content "\n" }}
{{- end -}}
{{ $content := highlight $content .Params.language .Params.options | }}
{{ $content := replaceRE "[ ]{4}" "&nbsp;&nbsp;&nbsp;&nbsp;" $content }}
{{ $content := replaceRE "\\n" "&#10;" $content }}
{{ $file := .Params.file }}
{{ $file := replace $file ".xhtml" ".html" }}
{{ $file := replace $file ".xmarkdown" ".markdown" }}

<div class="code">
    {{ $content | safeHTML }}
    <div class="highlight-meta">
        <span>{{ $file }}</span>
    </div>
</div>