Skip to content

Commit

Permalink
Upload build logs; update build pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
arcatdmz committed Jun 25, 2024
1 parent 042a0fb commit 15099fc
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
SYSTEM_NAME_COMMAND: systemname
SYSTEM_NAME: griffith

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
Expand All @@ -30,14 +34,18 @@ jobs:
container: arcatdmz/texlive
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Build PDF file
run: latexmk -pdf && latexmk -c && mkdir -p docs && cp *.pdf ./docs/
run: latexmk -pdf
- name: Run scripts
run: node scripts/abstract.js > abstract.log
- name: Organize files to upload
run: mkdir -p docs && cp *.pdf *.log ./docs/
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
# Upload "docs" directory
path: "docs"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
%% of authors' names for this purpose.
\renewcommand{\shortauthors}{Trovato et al.}

\newcommand{\systemname}{Griffith}

%%
%% The abstract is a short summary of the work to be presented in the
%% article.
Expand All @@ -208,6 +210,7 @@
article presents and explains many of the common variations, as well
as many of the formatting elements an author may use in the
preparation of the documentation of their work.
If I were to name this system, it should be \systemname.
\end{abstract}

%%
Expand Down
80 changes: 80 additions & 0 deletions scripts/abstract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const fs = require("fs");

const sysinExp = `\\${process.env.SYSTEM_NAME_COMMAND || "systemname"}`;
const sysout = process.env.SYSTEM_NAME || "Geollery";

function WordCount(str) {
return str.split(/\s+/).length;
}

function Analyze(a) {
var res = a.trim();
// begin re_abstract
const startWord = "\\begin{abstract}";
let start = res.indexOf(startWord),
end = res.indexOf("\\end{abstract");
if (start >= 0 && end >= start) {
res = res.substring(start + startWord.length, end).trim();
}

// ieee \re_abstract
re_abs = /\\re_abstract{(.+)}/gm;
match = re_abs.exec(res);
if (match && match[1]) {
res = match[1];
}

// citations
res = res.replace(/\\cite\{[\w\d,:]+\}/g, "");
res = res.replace(/\\ref\{[\w\d,:]+\}/g, "X");
res = res.replace(/\\begin\{[\w\d,:]+\}\[.+\]/g, "");
res = res.replace(/\\end\{[\w\d,:]+\}/g, "");
res = res.replace(/\\label\{[\w\d,:]+\}/g, "");
res = res.replace(/\\centering/g, "");
res = res.replace(/\\caption/g, "");
res = res.replace(
/\\includegraphics[\[\w\d\,\.\:\=\/\\]+\]\{[\w\d,\.\:\/\\\_]+\}/g,
""
);

// latex symbols
res = res.replace(/\\degree/g, "°");
res = res.replace(/\\times/g, "×");
res = res.replace(/\\etal/g, "et al.");
res = res.replace(/``/g, '"');
res = res.replace(/""/g, '"');
res = res.replace(/\'\'/g, '"');
res = res.replace(/\\&/g, "&");
res = res.replace(/ \./g, ".");
let sysin = new RegExp("\\" + sysinExp, "g");
res = res.replace(sysin, sysout);

// comments
res = res.replace(/([^\\]|^)%.+/gm, ""); // Fixed for Firefox

// emph and italics
res = res.replace(/\{\\\w+/gm, "").replace(/\\\/\}/g, "");

// textit, $, and ~
res = res
.replace(/\\\w+{/gm, "")
.replace(/[\}\$]/g, "")
.replace(/\~/g, " ");
res = res.replace(/\\sim/g, "~");

// double white spaces
res = res.replace(/\n/g, " ");
res = res.replace(/\s\s+/g, " ");
res = res.replace(/([\.,])(\s)([\.,])/g, "$1$3");

// \% percentage
res = res.replace(/\\\%/g, "%");
res = res.trim();

return { wc: WordCount(res), res };
}

const content = fs.readFileSync("main.tex", { encoding: "utf8" });
const { wc, res } = Analyze(content);
console.log("Word count: %d", wc);
console.log(res);

0 comments on commit 15099fc

Please sign in to comment.