diff --git a/machines/kat-son/doc/0001-fix-pretty-no-defaults.patch b/machines/kat-son/doc/0001-fix-pretty-no-defaults.patch deleted file mode 100644 index 605fadb..0000000 --- a/machines/kat-son/doc/0001-fix-pretty-no-defaults.patch +++ /dev/null @@ -1,25 +0,0 @@ -From f050ca4374c8c4d9d4fa85e46a1dedaaaedec791 Mon Sep 17 00:00:00 2001 -From: catvayor -Date: Wed, 11 Dec 2024 15:34:42 +0100 -Subject: [PATCH] fix: pretty no defaults - ---- - static/js/script.js | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/static/js/script.js b/static/js/script.js -index 56b633b..04234d7 100644 ---- a/static/js/script.js -+++ b/static/js/script.js -@@ -293,7 +293,7 @@ var expandOption = function(el){ - var elDesc = "
Description
" + parseDescription(currentSet[el].description) + "
"; - var elType = "
Type
" + currentSet[el].type + "
"; - //var elNote = ( currentSet[el].note == "" ? "": "
Note
" + currentSet[el].note + "
"); -- var elDefault = "
Default
" + currentSet[el].default + "
"; -+ var elDefault = ( currentSet[el].default == "" ? "" : "
Default
" + currentSet[el].default + "
"); - var elExample = ( currentSet[el].example == "" ? "" : "
Example
" + currentSet[el].example + "
"); - - //var declared_by_str = currentSet[el].declarations[0].name; --- -2.47.0 - diff --git a/machines/kat-son/doc/0001-revert-don-t-parse-md-in-js.patch b/machines/kat-son/doc/0001-revert-don-t-parse-md-in-js.patch new file mode 100644 index 0000000..1aee857 --- /dev/null +++ b/machines/kat-son/doc/0001-revert-don-t-parse-md-in-js.patch @@ -0,0 +1,147 @@ +From 5e5f68209b3b023fce260c9da1625844ca4d3c22 Mon Sep 17 00:00:00 2001 +From: catvayor +Date: Mon, 16 Dec 2024 00:11:47 +0100 +Subject: [PATCH 1/2] revert: don't parse md in js + +--- + static/js/script.js | 106 +------------------------------------------- + 1 file changed, 2 insertions(+), 104 deletions(-) + +diff --git a/static/js/script.js b/static/js/script.js +index 04234d7..d3ec223 100644 +--- a/static/js/script.js ++++ b/static/js/script.js +@@ -27,97 +27,6 @@ function encodeAttr(str) { + return (str+'').replace(/"/g, '"').replace(//g, '>'); + } + +-/** Parse Markdown into an HTML String. */ +-function parseMD(md, prevLinks) { +- let tokenizer = /((?:^|\n+)(?:\n---+|\* \*(?: \*)+)\n)|(?:^``` *(\w*)\n([\s\S]*?)\n```$)|((?:(?:^|\n+)(?:\t| {2,}).+)+\n*)|((?:(?:^|\n)([>*+-]|\d+\.)\s+.*)+)|(?:!\[([^\]]*?)\]\(([^)]+?)\))|(\[)|(\](?:\(([^)]+?)\))?)|(?:(?:^|\n+)([^\s].*)\n(-{3,}|={3,})(?:\n+|$))|(?:(?:^|\n+)(#{1,6})\s*(.+)(?:\n+|$))|(?:`([^`].*?)`)|( \n\n*|\n{2,}|__|\*\*|[_*]|~~)/gm, +- context = [], +- out = '', +- links = prevLinks || {}, +- last = 0, +- chunk, prev, token, inner, t; +- +- function tag(token) { +- let desc = TAGS[token[1] || '']; +- let end = context[context.length-1] == token; +- if (!desc) return token; +- if (!desc[1]) return desc[0]; +- if (end) context.pop(); +- else context.push(token); +- return desc[end|0]; +- } +- +- function flush() { +- let str = ''; +- while (context.length) str += tag(context[context.length-1]); +- return str; +- } +- +- md = md.replace(/^\[(.+?)\]:\s*(.+)$/gm, (s, name, url) => { +- links[name.toLowerCase()] = url; +- return ''; +- }).replace(/^\n+|\n+$/g, ''); +- +- while ( (token=tokenizer.exec(md)) ) { +- prev = md.substring(last, token.index); +- last = tokenizer.lastIndex; +- chunk = token[0]; +- if (prev.match(/[^\\](\\\\)*\\$/)) { +- // escaped +- } +- // Code/Indent blocks: +- else if (t = (token[3] || token[4])) { +- chunk = '
'+outdent(encodeAttr(t).replace(/^\n+|\n+$/g, ''))+'
'; +- } +- // > Quotes, -* lists: +- else if (t = token[6]) { +- if (t.match(/\./)) { +- token[5] = token[5].replace(/^\d+/gm, ''); +- } +- inner = parse(outdent(token[5].replace(/^\s*[>*+.-]/gm, ''))); +- if (t=='>') t = 'blockquote'; +- else { +- t = t.match(/\./) ? 'ol' : 'ul'; +- inner = inner.replace(/^(.*)(\n|$)/gm, '
  • $1
  • '); +- } +- chunk = '<'+t+'>' + inner + ''; +- } +- // Images: +- else if (token[8]) { +- chunk = `${encodeAttr(token[7])}`; +- } +- // Links: +- else if (token[10]) { +- out = out.replace('', ``); +- chunk = flush() + ''; +- } +- else if (token[9]) { +- chunk = ''; +- } +- // Headings: +- else if (token[12] || token[14]) { +- t = 'h' + (token[14] ? token[14].length : (token[13]>'=' ? 1 : 2)); +- chunk = '<'+t+'>' + parse(token[12] || token[15], links) + ''; +- } +- // `code`: +- else if (token[16]) { +- chunk = ''+encodeAttr(token[16])+''; +- } +- // Inline formatting: *em*, **strong** & friends +- else if (token[17] || token[1]) { +- chunk = tag(token[17] || '--'); +- } +- out += prev; +- out += chunk; +- } +- +- return (out + md.substring(last) + flush()).replace(/^\n+|\n+$/g, ''); +-} +- +- +-/************************* +- * END MARKDOWN PARSER +- */ +- + + var search, results, allOptions, currentSet = []; + var lastUpdate = "?"; +@@ -254,22 +163,11 @@ var updateOptionsTable = function(options) { + + + +-function parseDescription(text){ +- +- text = text.replace(/]*))/gi ,'<https$1'); +- text = text.replace(/\[\]\(#opt-(\s*([^)]*))/gi ,'$1').replace(/\)/gi,''); +- //[](#opt-wayland.windowManager.hyprland.plugins) +- text = text.replace(/\{var\}(\s*([^\n]*))/gi ,'$1').replace(/`/gi,'') +- text = text.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'').replace(/:::/,'').replace(/\n/g, '
    ') +- return text; +-} +- + var expandOptionMD = function(el){ + + modalTitle.innerHTML = currentSet[el].title; + +- let dhtml = parseMD(currentSet[el].doc); +- var elDesc = "
    Description
    " + dhtml + "
    "; ++ var elDesc = "
    Description
    " + currentSet[el].doc + "
    "; + var elArgs = "
    Args
    " + currentSet[el].args.join(', ') + "
    "; + // var elNote = ( currentSet[el].note == "" ? "": "
    Note
    " + currentSet[el].note + "
    "); + // var elDefault = "
    Default
    " + currentSet[el].default + "
    "; +@@ -290,7 +188,7 @@ var expandOption = function(el){ + + //console.log(currentSet[el].description.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'').replace(/:::/,'')); + +- var elDesc = "
    Description
    " + parseDescription(currentSet[el].description) + "
    "; ++ var elDesc = "
    Description
    " + currentSet[el].description + "
    "; + var elType = "
    Type
    " + currentSet[el].type + "
    "; + //var elNote = ( currentSet[el].note == "" ? "": "
    Note
    " + currentSet[el].note + "
    "); + var elDefault = ( currentSet[el].default == "" ? "" : "
    Default
    " + currentSet[el].default + "
    "); +-- +2.47.0 + diff --git a/machines/kat-son/doc/0002-chore-remove-useless-dependencies.patch b/machines/kat-son/doc/0002-chore-remove-useless-dependencies.patch index 74b8cb9..9d391f2 100644 --- a/machines/kat-son/doc/0002-chore-remove-useless-dependencies.patch +++ b/machines/kat-son/doc/0002-chore-remove-useless-dependencies.patch @@ -1,4 +1,4 @@ -From d32ae9c3386ad1d896d8a54271138111b579d7e7 Mon Sep 17 00:00:00 2001 +From 957189be0a61f954a1bcfb204f982f59ae6435ea Mon Sep 17 00:00:00 2001 From: catvayor Date: Thu, 12 Dec 2024 17:04:45 +0100 Subject: [PATCH 2/2] chore: remove useless dependencies diff --git a/machines/kat-son/doc/0003-feat-separate-HTML-description-of-MD-description.patch b/machines/kat-son/doc/0003-feat-separate-HTML-description-of-MD-description.patch new file mode 100644 index 0000000..cb8149f --- /dev/null +++ b/machines/kat-son/doc/0003-feat-separate-HTML-description-of-MD-description.patch @@ -0,0 +1,25 @@ +From b0f6c845280bee20bcc28a136436e000bde8a457 Mon Sep 17 00:00:00 2001 +From: catvayor +Date: Mon, 16 Dec 2024 11:25:38 +0100 +Subject: [PATCH] feat: separate HTML description of MD description + +--- + static/js/script.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/static/js/script.js b/static/js/script.js +index d3ec223..5d9fc6e 100644 +--- a/static/js/script.js ++++ b/static/js/script.js +@@ -188,7 +188,7 @@ var expandOption = function(el){ + + //console.log(currentSet[el].description.replace(/:::\ \{\.note\}(\s*([^:::]*))/gi ,'').replace(/:::/,'')); + +- var elDesc = "
    Description
    " + currentSet[el].description + "
    "; ++ var elDesc = "
    Description
    " + currentSet[el].descriptionHTML + "
    "; + var elType = "
    Type
    " + currentSet[el].type + "
    "; + //var elNote = ( currentSet[el].note == "" ? "": "
    Note
    " + currentSet[el].note + "
    "); + var elDefault = ( currentSet[el].default == "" ? "" : "
    Default
    " + currentSet[el].default + "
    "); +-- +2.47.0 + diff --git a/machines/kat-son/doc/0004-fix-indentation-of-ul.patch b/machines/kat-son/doc/0004-fix-indentation-of-ul.patch new file mode 100644 index 0000000..cabfc09 --- /dev/null +++ b/machines/kat-son/doc/0004-fix-indentation-of-ul.patch @@ -0,0 +1,26 @@ +From e31e0330b9b012b6e09f8eb6bc670e4336d1aedc Mon Sep 17 00:00:00 2001 +From: catvayor +Date: Mon, 16 Dec 2024 12:53:27 +0100 +Subject: [PATCH] fix: indentation of
      + +--- + static/css/nucleus.css | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/static/css/nucleus.css b/static/css/nucleus.css +index a4674a8..9ada521 100644 +--- a/static/css/nucleus.css ++++ b/static/css/nucleus.css +@@ -533,7 +533,8 @@ p { + + ul, ol { + margin-top: 1.7rem; +- margin-bottom: 1.7rem; } ++ margin-bottom: 1.7rem; ++ margin-left: 1rem; } + ul ul, ul ol, ol ul, ol ol { + margin-top: 0; + margin-bottom: 0; } +-- +2.47.0 + diff --git a/machines/kat-son/doc/default.nix b/machines/kat-son/doc/default.nix index f97458f..308ce0c 100644 --- a/machines/kat-son/doc/default.nix +++ b/machines/kat-son/doc/default.nix @@ -20,6 +20,7 @@ let attrNames filter head + getExe ; inherit (lib.strings) sanitizeDerivationName @@ -71,21 +72,34 @@ let name = "<${innerPath}>"; url = "${translate-info.url}${innerPath}"; }; - result = json.generate "options-extranix.json" { + result' = json.generate "options-extranix-fileDesc.json" { last_update = "-/-"; options = mapAttrsToList (title: val: { inherit title; inherit (val) type readOnly - description loc + description ; + descriptionHTML = pkgs.runCommand "option-${title}.html" { } '' + ${getExe pkgs.pandoc} -f markdown ${pkgs.writeText "option-${title}.md" val.description} > $out + ''; example = val.example.text or ""; default = val.default.text or ""; declarations = map path-translation val.declarations; }) filtered-opts; }; + result = + pkgs.runCommand "options-extranix.json" + { + nativeBuildInputs = [ pkgs.jq ]; + } + '' + jq -r '.options[].descriptionHTML | "--rawfile\n" + . + "\n" + .' ${result'} | xargs \ + jq -c '.options |= map(.descriptionHTML as $desc | .descriptionHTML |= $ARGS.named.[$desc])' ${result'} \ + > $out + ''; in result; diff --git a/machines/kat-son/doc/hugo-theme-extranix-options-search.nix b/machines/kat-son/doc/hugo-theme-extranix-options-search.nix index df95ade..f53daa5 100644 --- a/machines/kat-son/doc/hugo-theme-extranix-options-search.nix +++ b/machines/kat-son/doc/hugo-theme-extranix-options-search.nix @@ -10,13 +10,15 @@ stdenv.mkDerivation { src = fetchFromGitHub { owner = "mipmip"; repo = "hugo-theme-extranix-options-search"; - rev = "1b5cdc63b3127ab81aed2736b0dea7ed09b7ec72"; - hash = "sha256-oowopWC9JdZIex548S0W91MIPSDCaJ3isuNLfesjT9U="; + rev = "3252b5bd98adcbbe629327d72c8416c25014a0d6"; + hash = "sha256-XV7Js1KaBiWv9qao8iyzQ546nT1KkwCtvyAs++oeXFo="; }; patches = [ - ./0001-fix-pretty-no-defaults.patch + ./0001-revert-don-t-parse-md-in-js.patch ./0002-chore-remove-useless-dependencies.patch + ./0003-feat-separate-HTML-description-of-MD-description.patch + ./0004-fix-indentation-of-ul.patch ]; installPhase =