sysprog21 / lkmpg

The Linux Kernel Module Programming Guide (updated for 5.0+ kernels)
https://sysprog21.github.io/lkmpg/
Open Software License 3.0
7.55k stars 509 forks source link

Use GitHub Actions for site building and format conversion. #25

Open Hsins opened 3 years ago

Hsins commented 3 years ago

There are a bunch of static site generator that creates HTML pages from templates or components and the given content source. Besides, we can also automate, customize, and execute workflows right in the repository with GitHub Actions.

The OI Wiki Project is an example:

  1. The contents are written in Markdown.
  2. Then the build and build-pdf workflows are triggered whenever there is any push or pull request event.
    • build workflow runs mkdocs for creating HTML pages from *.md files.
    • build-pdf workflow coverted *.md files to *.tex files (by running this JavaScript script) and compiled them to output.pdf.

Besides, the site 《大家來學 LaTeX》 is another site created with Hugo and use utteranc as the comment system. It would be a possible solution to use pandoc for coverting *.tex to *.md.

jserv commented 3 years ago

make4ht is used for HTML generation (#20), and I would like to stick to LaTeX script at present.

Hsins commented 3 years ago

Sure that we can keep the source files in *.tex format but find out another solution for HTML/EPUB generating. It's not really convenient to use TeX4ht with custom HTML template although it's enough at present.

fennecJ commented 3 years ago

I think build a markdown file then convert it into html sounds promising. However pandoc doesn't support some extensions used in lkmpg.tex and caused several code blocks to be omitted.

Hsins commented 3 years ago

More packages make more possible dependency issue but we don't have bunch of packages.

I've check that currently the format conversion of code block from tex to md would be like something below:

LaTeX Markdown
```plain \subsection{Kernel module package} \label{sec:packages} Linux distributions provide the commands \emph{modprobe}, \emph{insmod} and \emph{depmod} within a package. On Ubuntu/Debian: \begin{codebash} sudo apt-get install build-essential kmod \end{codebash} ``` ```plain ## Kernel module package {#sec:packages} Linux distributions provide the commands *modprobe*, *insmod* and *depmod* within a package. On Ubuntu/Debian: ::: codebash sudo apt-get install build-essential kmod ::: ```

It seems that we can do something tricky: TeX -> Markdown -> HTML. Just replace ":::" with "```" and "codebash" (or something else programming languages) with "bash" before converting to HTML from Markdown.

Hsins commented 3 years ago

Also, I found that we can use listings package instead of minted in LaTeX and pandoc handle the lstlisting environment well.

image

Hsins commented 3 years ago

After creating and running with a custom pandoc filter for minted package. Now it can handle the code block environment with minted package well:

image

It may take me some time for creating the pandoc filter to deal with the \newminted[codebash] environment that @jserv created.

fennecJ commented 3 years ago

Consider using \begin{minted}[linenos]{c} instead of \begin{minted}{c} so the line number can be shown.

Hsins commented 3 years ago

There is a POC (Proof of Concept) site building with Pandoc + Hugo (theme: book) could be check at here. It seems that:

Now, waiting for #26 resolved so that I could split one page into several chapters.