From: A-Larsen Date: Tue, 6 Oct 2026 14:07:55 +0000 (-0400) Subject: first commit X-Git-Url: https://nyquistdev.net/git/?a=commitdiff_plain;h=4227988e9f6801c02e4115420bb2cecee21e5efb;p=readme-to-html.git first commit --- 4227988e9f6801c02e4115420bb2cecee21e5efb diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..9cbfdd9 --- /dev/null +++ b/README.adoc @@ -0,0 +1,24 @@ += Readme To HTML + +My asciidoctor docinfo files for turning a _README.adoc_ files to _render.html_ +files. The _render.html_ is what is seen in the readme summary on my gitweb for +each git repository. + + +== How to install + +simply run: + +---- +sudo ./install.sh +---- + + +== How to use in project + +1. edit your _README.adoc_ file. +2. edit the _docinfo.conf_ file appropriately + * make sure `HOSTNAME` is the name of you're websites hostname +3. run `readme-to-html` + +IMPORTANT: make sure to keep docinfo.html and docinfo.js outside of your repo. diff --git a/docinfo.conf b/docinfo.conf new file mode 100644 index 0000000..fc4596c --- /dev/null +++ b/docinfo.conf @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +HOSTNAME=nyquistdev.net +DOCINFODIR=/usr/local/share/asciidoctor-styles/dark1/ diff --git a/docinfo.html b/docinfo.html new file mode 100644 index 0000000..7a3b4b3 --- /dev/null +++ b/docinfo.html @@ -0,0 +1,584 @@ + + + + + + + + + + + + diff --git a/docinfo.js b/docinfo.js new file mode 100644 index 0000000..e55aded --- /dev/null +++ b/docinfo.js @@ -0,0 +1,99 @@ +const link_variable = "https://www.lua.org/manual/5.3/manual.html#2.1"; +const link_table = "https://www.lua.org/manual/5.3/manual.html#3.4.9"; + +function setTypeHtml(type, link) { + type.innerHTML = `<${type.outerText}>` +} + +function zebraChecklist(element) { + let f = 0; + for (let i = 0; i < element.length; ++i) { + children = element[i].children; + if (children) { + for (let i = 0; i < children.length; ++i) { + if (f % 2 == 0) { + children[i].querySelector("p").style.backgroundColor = "black"; + } + let innerChild = children[i].querySelector("ul.checklist"); + if (innerChild) { + zebraChecklist(innerChild); + } + f++; + } + } + f++; + } +} + +function hideTocChildren() { + const tocList = document.querySelector(".sectlevel1"); + + for (let i =0; i < tocList.children.length; ++i) { + let child = tocList.children[i]; + let lis = child.querySelectorAll("li"); + for (let j = 0; j < lis.length; ++j) { + lis[j].style.display = "none"; + } + } +} + +window.onload = function() { + const class_api_type = document.querySelectorAll(".api-type"); + const class_checklist = document.querySelectorAll("ul.checklist"); + const class_download = document.querySelectorAll(".download"); + const id_footer = document.querySelector("#footer"); + const tocList = document.querySelector(".sectlevel1"); + + + // document.querySelector(".sectlevel1").children[1].querySelectorAll("li")[0] + + class_api_type.forEach(type => { + switch(type.outerText) { + case "number" : { + setTypeHtml(type, link_variable); + break; + } + case "string" : { + setTypeHtml(type, link_variable); + break; + } + case "table" : { + setTypeHtml(type, link_table); + break; + } + } + }); + + class_download.forEach(span => { + let atag = span.querySelector("a"); + let href = atag.getAttribute("href"); + let regex_FileAtEndOfPath = /\/[\w-_]*.\w*$/; + let fileName = href.match(regex_FileAtEndOfPath)[0].slice(1); + atag.setAttribute("download", fileName); + atag.innerHTML = fileName; + }) + + zebraChecklist(class_checklist); + // let footer = document.createElement("footer"); + // footer.style.color = "black"; + // footer.style.textAlign = "center"; + // footer.style.backgroundColor = "white"; + // footer.style.opacity = ".5" + // footer.innerHTML = "

powered by asciidoctor

"; + // document.body.appendChild(footer); + + for (let i =0; i < tocList.children.length; ++i) { + let child = tocList.children[i]; + let lis = child.querySelectorAll("li"); + for (let j = 0; j < lis.length; ++j) { + lis[j].style.display = "none"; + } + + child.addEventListener("click", event => { + hideTocChildren(); + for (let j = 0; j < lis.length; ++j) { + lis[j].style.display = "block"; + } + }) + } +} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..7a24a89 --- /dev/null +++ b/install.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +d=/usr/local/share/readme-to-html +b=/usr/local/bin + +mkdir -p $d +cp docinfo.{html,js} $d +cp readme-to-html $b +chmod 755 ${b}/readme-to-html +chmod u+x ${b}/readme-to-html diff --git a/readme-to-html b/readme-to-html new file mode 100755 index 0000000..a5248d9 --- /dev/null +++ b/readme-to-html @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +. docinfo.conf + +echo "make render.html for website $HOSTNAME" + +appendAttributes () { +cat < + + + + + + +Readme To HTML + + + + + + + + + + + + + + + + + + + + +
+
+
+
+

My asciidoctor docinfo files for turning a README.adoc files to render.html +files. The render.html is what is seen in the readme summary on my gitweb for +each git repository.

+
+
+
+
+

How to install

+
+
+

simply run:

+
+
+
+
sudo ./install.sh
+
+
+
+
+
+

How to use in project

+
+
+
    +
  1. +

    edit your README.adoc file.

    +
  2. +
  3. +

    edit the docinfo.conf file appropriately

    +
    +
      +
    • +

      make sure HOSTNAME is the name of you’re websites hostname

      +
    • +
    +
    +
  4. +
  5. +

    run readme-to-html

    +
  6. +
+
+
+ + + + + +
+ + +make sure to keep docinfo.html and docinfo.js outside of your repo. +
+
+
+
+
+ + + + \ No newline at end of file