diff --git a/docs/css/callout.css b/docs/css/callout.css index 54af5044..650ffdcf 100644 --- a/docs/css/callout.css +++ b/docs/css/callout.css @@ -1,4 +1,3 @@ - :root { --ycr-bubble-bg-color: #92c6ce1a; --ycr-bubble-icon-color: #0d545f; @@ -52,7 +51,7 @@ margin: 0 0.2em; white-space: nowrap; font-weight: 300 !important; - color: var(--md-code-fg-color) !important; + color: var(--ycr-bubble-icon-color) !important; font-family: var(--md-code-font-family); } @@ -61,12 +60,13 @@ border: .075rem solid var(--ycr-bubble-fg-color--hover); } - .ycr-regex code { + all: unset; color: var(--ycr-bubble-icon-color) !important; - text-decoration: none; } - a.ycr-callout:focus code,a.ycr-callout:hover code { - background-color: transparent !important; -} +a.ycr-regex:focus code, +a.ycr-regex:hover code { + background: inherit; + background-color: transparent; +} \ No newline at end of file diff --git a/docs/js/navcolor.js b/docs/js/navcolor.js index 8e651e22..13edf3e7 100644 --- a/docs/js/navcolor.js +++ b/docs/js/navcolor.js @@ -1,4 +1,4 @@ -document$.subscribe(async function(el) { +document$.subscribe(async function (el) { const ul = el.querySelector('.md-tabs__list'); if (!ul) { return; @@ -13,20 +13,28 @@ document$.subscribe(async function(el) { } const href = a.getAttribute('href'); - if (href.includes('/course-c/')) { - color = 'red' + config = { + 'default': { + '/course-c/': 'red', + '/course-cpp/': 'cyan', + '/course-python/': 'green', + '/environment/': 'gray', + 'default': 'red' + }, + 'slate': { + '/course-c/': 'black', + '/course-cpp/': 'cyan', + '/course-python/': 'green', + '/environment/': 'gray', + 'default': 'black' + } } - else if (href.includes('/course-cpp/')) { - color = 'cyan' - } - else if (href.includes('/course-python/')) { - color = 'green' - } - else if (href.includes('/environment/')) { - color = 'gray' - } - else { - color = 'red' + + let scheme = document.querySelector('body').getAttribute('data-md-color-scheme'); + for (let key in config[scheme]) { + if (href.includes(key)) { + color = config[scheme][key]; + document.querySelector('body').setAttribute('data-md-color-primary', color); + } } - document.querySelector('body').setAttribute('data-md-color-primary', color); }); \ No newline at end of file diff --git a/hooks/latex/renderer.py b/hooks/latex/renderer.py index 761bc531..474fa5e6 100644 --- a/hooks/latex/renderer.py +++ b/hooks/latex/renderer.py @@ -109,11 +109,11 @@ def __init__(self, output_path=Path("build"), config={}): self.render_hr, self.render_br, # Prior escaping LaTeX special characters + self.render_regex, self.render_codeblock, self.render_codeinline, self.render_math, self.render_math_block, - self.render_regex, self.render_unicode, self.render_navigable_string, self.render_emoji, @@ -284,7 +284,11 @@ def render_regex(self, soup: Tag, **kwargs): class="ycr-regex" target="_blank">/.../ """ for a in soup.find_all("a", class_=["ycr-regex"]): - code = self.get_safe_text(a) + if code_tag := a.find("code"): + code = self.get_safe_text(code_tag) + else: # Fallback to text + code = self.get_safe_text(a) + code = code.replace("&", "\\&").replace("#", "\\#") self.apply(a, "regex", code, url=safe_quote(a.get("href", ""))) return soup diff --git a/hooks/regex.py b/hooks/regex.py index be990113..2ad986b0 100644 --- a/hooks/regex.py +++ b/hooks/regex.py @@ -42,7 +42,6 @@ def handleMatch(self, m, data): el.set("class", classes) el.set("target", target) el.text = f"`{regex}`" - return el, m.start(0), m.end(0) diff --git a/hooks/unicode.py b/hooks/unicode.py index f593654f..a42ed332 100644 --- a/hooks/unicode.py +++ b/hooks/unicode.py @@ -3,29 +3,32 @@ U+XXXX with a tag """ + from xml.etree import ElementTree as etree + from markdown.extensions import Extension from markdown.inlinepatterns import InlineProcessor -BASE_URL = 'https://symbl.cc/fr/' +BASE_URL = "https://symbl.cc/fr/" + class UnicodeProcessor(InlineProcessor): def handleMatch(self, m, data): unicode_code = m.group(1) el = etree.Element("a") - el.set('href', f'{BASE_URL}/{unicode_code}') - el.set('class', 'ycr-callout ycr-unicode') - el.set('target', '_blank') - el.text = f'U+{unicode_code}' + el.set("href", f"{BASE_URL}/{unicode_code}") + el.set("class", "ycr-callout ycr-unicode") + el.set("target", "_blank") + el.text = f"{unicode_code}" return el, m.start(0), m.end(0) class UnicodeExtension(Extension): def extendMarkdown(self, md): - UNICODE_RE = r'\bU\+([0-9A-F]{4,5})\b' + UNICODE_RE = r"\bU\+([0-9A-F]{4,5})\b" unicode_pattern = UnicodeProcessor(UNICODE_RE, md) - md.inlinePatterns.register(unicode_pattern, 'unicode', 175) + md.inlinePatterns.register(unicode_pattern, "unicode", 175) def on_config(config): - config['markdown_extensions'].append(UnicodeExtension()) \ No newline at end of file + config["markdown_extensions"].append(UnicodeExtension()) diff --git a/mkdocs.yml b/mkdocs.yml index 7d2b9220..f18be6f4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -5,7 +5,9 @@ site_name: Le C pour l'ingénieur site_url: https://heig-tin-info.github.io/handbook/ site_author: Yves Chevallier site_description: | - Un manuel pour apprendre le langage C en partant de zéro. + Cours d'informatique pour les étudiants en ingénierie du département des + technologies industrielles à la HEIG-VD. Ce cours concerne le langage C et + les outils associés. copyright: > Copyright © 2019 - 2024 HEIG-VD Yves Chevallier Changer les paramètres des cookies @@ -15,7 +17,10 @@ repo_name: heig-tin-info/handbook repo_url: https://github.com/heig-tin-info/handbook edit_uri: edit/master/docs/ docs_dir: !ENV [DOCS, docs] - +validation: + omitted_files: warn + absolute_links: warn + unrecognized_links: warn theme: name: material language: fr @@ -49,16 +54,16 @@ theme: - toc.follow palette: - scheme: default - #media: "(prefers-color-scheme: light)" + media: "(prefers-color-scheme: light)" toggle: icon: material/lightbulb name: Switch to dark mode primary: red accent: light blue - scheme: slate - #media: "(prefers-color-scheme: dark)" - primary: red - accent: light blue + media: "(prefers-color-scheme: dark)" + primary: black + accent: lime toggle: icon: material/lightbulb-outline name: Switch to light mode @@ -131,7 +136,7 @@ plugins: markdown_extensions: - toc: toc_depth: 3 - permalink: true + permalink: "¤" - pymdownx.betterem: smart_enable: all - tables diff --git a/overrides/home.html b/overrides/home.html index 8c17d0c0..1696f039 100644 --- a/overrides/home.html +++ b/overrides/home.html @@ -73,7 +73,7 @@ top: 0; right: 0; width: 40rem; - position:absolute; + position: absolute; transform: translateX(5rem); height: 100vh; overflow: hidden; @@ -93,20 +93,21 @@
{{ config.site_description }}.
- Cours + Cours en ligne - - Environnement de travail + + Télécharger le PDF