Skip to content

Fix ALK section to say it is disabled #168

Fix ALK section to say it is disabled

Fix ALK section to say it is disabled #168

name: build html version of the ss3 user manual
on:
push:
paths:
- '**.tex'
- 'html_usermanual_snippets.html'
- '**.yml'
pull_request:
paths:
- '**.tex'
- 'html_usermanual_snippets.html'
- '**.yml'
workflow_call:
inputs:
ref:
default: ${{ github.ref }}
required: false
type: string
jobs:
build-html:
runs-on: ubuntu-20.04
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
steps:
- name: Set up Git repository
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
- name: Update Ubuntu packages
run: sudo apt-get update
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
- name: setup pandoc
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: '2.14.0.3'
- name: Convert tex to html
run: pandoc SS330_User_Manual.tex -s -o SS330_User_Manual.html --toc --self-contained --mathjax --default-image-extension=png --number-sections --citeproc --variable linkcolor=#0033CC
# Note: for the following R code, may be a single command to deal with the double header issue before rendering.
- name: Edit html to improve formatting
run: |
html_txt <- readLines("SS330_User_Manual.html")
#read html snippits to add
html_snips <- readLines("html_usermanual_snippets.html")
# remove inline style
style_sec <- grep("style>", html_txt)
html_txt <- html_txt[-(style_sec[1]:style_sec[2])]
# add in the navbar
navbar_snip <- grep("div", html_snips)
navbar_snip <- html_snips[navbar_snip[1]:navbar_snip[2]]
html_txt <- append(html_txt, navbar_snip, after = grep("<html", html_txt))
html_txt <- gsub(
"<p>_add:nnn<span>Catalog</span><span>Lang</span><span>(enUS)</span></p>",
"", html_txt, fixed = TRUE)
# add link to css
css_snip <- grep("<link", html_snips, value = TRUE)
html_txt <- append(html_txt, css_snip, after = grep("<title>", html_txt))
# Add styling to tables add 1 because first col is on next row
first_lines <- grep("^<tr class=[[:punct:]]{1}[oe]", html_txt) + 1
tmp_lines <- html_txt[first_lines]
tmp_lines <- gsub("<td style=\"text-align: left;\">",
"<td style=\"text-align: left;white-space: nowrap;\">",
tmp_lines)
html_txt[first_lines] <- tmp_lines
# remove Typical Value double header
label <- grep(">Typical Value<", html_txt, fixed = TRUE)
diff_label <- diff(label)
to_rm <- which(diff_label <10)
# one to get rid of is test
to_rm_lines <- label[to_rm+1]
for (i in to_rm_lines) {
start <- grep("<tr", html_txt, fixed = TRUE)
end <- grep("/tr", html_txt, fixed = TRUE)
start <- max(start[start %in% (i-5):(i-1)])
end <- min(end[end %in% (i+1):(i+5)])
if(length(start) == 1 & length(end) == 1) {
html_txt[start:end] <- ""
}
}
# remove Value double header
label <- grep(">Value<", html_txt, fixed = TRUE)
diff_label <- diff(label)
to_rm <- which(diff_label <10)
to_rm_lines <- label[to_rm+1]
for (i in to_rm_lines) {
start <- grep("<tr", html_txt, fixed = TRUE)
end <- grep("/tr", html_txt, fixed = TRUE)
start <- max(start[start %in% (i-5):(i-1)])
end <- min(end[end %in% (i+1):(i+5)])
if(length(start) == 1 & length(end) == 1) {
html_txt[start:end] <- ""
}
}
# remove LO HI INIT etc double header
label <- grep(">LO<", html_txt, fixed = TRUE)
diff_label <- diff(label)
to_rm <- which(diff_label < 20)
to_rm_lines <- label[to_rm+1]
for (i in to_rm_lines) {
start <- grep("<tr", html_txt, fixed = TRUE)
end <- grep("/tr", html_txt, fixed = TRUE)
start <- max(start[start %in% (i-10):(i-1)])
end <- min(end[end %in% (i+1):(i+10)])
if(length(start) == 1 & length(end) == 1) {
html_txt[start:end] <- ""
}
}
# remove Pattern N Parameters etc double header
label <- grep(">N Parameters<", html_txt, fixed = T)
diff_label <- diff(label)
to_rm <- which(diff_label == 5)
to_rm_lines <- label[to_rm+1]
for (i in to_rm_lines) {
start <- grep("<tr", html_txt, fixed = TRUE)
end <- grep("/tr", html_txt, fixed = TRUE)
start <- max(start[start %in% (i-2):(i-1)])
end <- min(end[end %in% (i+1):(i+2)])
if(length(start) == 1 & length(end) == 1) {
html_txt[start:end] <- ""
}
}
# Add title to table of contents
where_add <- grep('<nav id="TOC" role="doc-toc">',
html_txt, fixed = TRUE)
html_txt <- append(html_txt,
"<h1>Table of Contents</h1>",
after = where_add[1])
# Add title to references
where_add <- (grep("references csl-bib-body hanging-indent",
html_txt, fixed = TRUE) - 1)
html_txt <- append(html_txt,
'<h1 data-number="17" id="sec:references"><span class="header-section-number">17</span> References</h1>',
after = where_add)
# Add references to table of contents
where_add <- grep("</nav>", html_txt, fixed = TRUE)-2
html_txt <- append(html_txt,
'<li><a href="#sec:references"><span class="toc-section-number">17</span> References</a></li>',
after = where_add)
writeLines(html_txt, "SS330_User_Manual.html")
shell: Rscript {0}
- name: upload html file as artifact
uses: actions/upload-artifact@v3
with:
name: SS330_User_Manual.html
path: SS330_User_Manual.html