From 24e4510884e26c05849319c7774356d26a0d0837 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Mon, 8 Feb 2021 14:19:36 +0100 Subject: [PATCH] highlighted file support --- assets/css/itix.css | 24 ++++++++++++++++++++++++ i18n/en.yaml | 2 ++ i18n/fr.yaml | 2 ++ layouts/shortcodes/highlightFile.html | 7 +++++++ 4 files changed, 35 insertions(+) create mode 100644 layouts/shortcodes/highlightFile.html diff --git a/assets/css/itix.css b/assets/css/itix.css index 7575ad8..694f1af 100644 --- a/assets/css/itix.css +++ b/assets/css/itix.css @@ -285,6 +285,30 @@ pre code { padding: 0; } +/* + * Highlighted file has a wrapping div. Some properties are redefined for it + * and reset to their default value for its children. + */ +.highlightedFile { + background: var(--codeblock-background-color); + border-radius: 5px; +} + +.highlightedFile .filename { + border-bottom: 2px solid var(--hover-menu-border-color); + font-family: var(--sans-preferred-font-list) !important; + font-size: larger; + padding: 12px 15px; +} + +.highlightedFile pre { + background: inherit; + border-radius: inherit; + padding: 12px 15px; + margin: 0; +} + + pre:hover { /* Show the horizontal scroll bar when hovering code (if needed) */ overflow-x: auto; diff --git a/i18n/en.yaml b/i18n/en.yaml index 4d76a29..12f0cff 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -36,3 +36,5 @@ translation: Misc. - id: show_menu translation: Show the menu +- id: file + translation: 'File "%s"' diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 6f1c31d..62c5cfd 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -36,3 +36,5 @@ translation: Divers - id: show_menu translation: Afficher le menu +- id: file + translation: 'Fichier "%s"' diff --git a/layouts/shortcodes/highlightFile.html b/layouts/shortcodes/highlightFile.html new file mode 100644 index 0000000..80c7e10 --- /dev/null +++ b/layouts/shortcodes/highlightFile.html @@ -0,0 +1,7 @@ + +
+{{- with .Get 0 -}} +
{{ printf (i18n "file") . | safeHTML }}
+{{- end -}} +{{- highlight (trim .Inner "\n") (.Get 1) (.Get 2) -}} +
\ No newline at end of file