Set up github pages
This commit is contained in:
parent
fb6bc2d7de
commit
8cefd9fabc
6 changed files with 170 additions and 2 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
gh-pages/
|
||||
/go-org
|
12
.travis.yml
12
.travis.yml
|
@ -1 +1,13 @@
|
|||
language: go
|
||||
script:
|
||||
- make test
|
||||
- make generate-gh-pages
|
||||
deploy:
|
||||
provider: pages
|
||||
github-token: $GITHUB_TOKEN # From travis-ci.org repository settings
|
||||
local-dir: gh-pages
|
||||
target-branch: gh-pages
|
||||
skip-cleanup: true
|
||||
verbose: true
|
||||
on:
|
||||
branch: master
|
||||
|
|
6
Makefile
6
Makefile
|
@ -7,7 +7,7 @@ install:
|
|||
|
||||
.PHONY: build
|
||||
build: install
|
||||
go build main.go
|
||||
go build .
|
||||
|
||||
.PHONY: test
|
||||
test: install
|
||||
|
@ -21,3 +21,7 @@ case=example
|
|||
.PHONY: render
|
||||
render:
|
||||
go run main.go org/testdata/$(case).org html | html2text
|
||||
|
||||
.PHONY: generate-gh-pages
|
||||
generate-gh-pages: build
|
||||
./etc/generate-gh-pages
|
||||
|
|
48
etc/generate-gh-pages
Executable file
48
etc/generate-gh-pages
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
org_files=org/testdata/*.org
|
||||
content="
|
||||
<h1>Sections</h1>
|
||||
<style>
|
||||
.sections { margin-left: 2rem; }
|
||||
.sections a { display: block; padding: 0.25em 0; }
|
||||
.sections a:hover, .sections a:focus, .sections a:active { background: rgba(200, 200, 200, 0.2); }
|
||||
</style>
|
||||
<ul class='sections'>"
|
||||
for org_file in $org_files; do
|
||||
name=$(basename $org_file)
|
||||
content+="<li><a id='toc-${name}' href='#${name}'>${name}</a>"
|
||||
done
|
||||
content+="</ul><hr>"
|
||||
|
||||
for org_file in $org_files; do
|
||||
echo generating content for $org_file
|
||||
name=$(basename $org_file)
|
||||
content+="
|
||||
<h2><a id='${name}' href='#toc-${name}'>${name}</a></h2>
|
||||
<div class='source'>
|
||||
<pre class='org'>$(cat $org_file)</pre>
|
||||
<div class='html'>$(./go-org $org_file html-chroma)</div>
|
||||
</div>"
|
||||
done
|
||||
|
||||
html="<html>
|
||||
<head>
|
||||
<style>$(cat etc/style.css)</style>
|
||||
<style>
|
||||
.source {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 1rem; }
|
||||
|
||||
.org, .html {
|
||||
border: 1px dashed grey;
|
||||
padding: 1em;
|
||||
overflow-x: auto; }
|
||||
</style>
|
||||
</head>
|
||||
<body>$content</body>
|
||||
</html>"
|
||||
|
||||
mkdir -p gh-pages
|
||||
echo "$html" > gh-pages/index.html
|
102
etc/style.css
Normal file
102
etc/style.css
Normal file
|
@ -0,0 +1,102 @@
|
|||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0; }
|
||||
|
||||
html {
|
||||
font: 100%/1.5 sans-serif;
|
||||
word-wrap: break-word;
|
||||
padding: 1.5em; }
|
||||
|
||||
@media (min-width: 768px) {
|
||||
html { font-size: 125%; } }
|
||||
|
||||
h1, h2, h3, h4 {
|
||||
margin: 2.5rem 0 1.5rem 0;
|
||||
line-height: 1.25; }
|
||||
|
||||
.title {
|
||||
font-size: 2.5em; }
|
||||
|
||||
.subtitle {
|
||||
font-weight: normal;
|
||||
font-size: 0.75em;
|
||||
color: #666; }
|
||||
|
||||
a {
|
||||
color: #fa6432;
|
||||
text-decoration: none; }
|
||||
a:hover, a:focus, a:active {
|
||||
text-decoration: underline; }
|
||||
|
||||
p {
|
||||
margin: 1em 0; }
|
||||
p code {
|
||||
background-color: #eee;
|
||||
padding: 0.05em 0.2em;
|
||||
border: 1px solid #ccc; }
|
||||
|
||||
ol, ul {
|
||||
margin: 1em; }
|
||||
ol li ol, ol li ul, ul li ol, ul li ul {
|
||||
margin: 0 2em; }
|
||||
ol li p, ul li p {
|
||||
margin: 0; }
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
padding: 0.5em; }
|
||||
|
||||
blockquote {
|
||||
padding-left: 1em;
|
||||
font-style: italic;
|
||||
border-left: solid 1px #fa6432; }
|
||||
|
||||
table {
|
||||
font-family: monospace;
|
||||
font-size: 1rem;
|
||||
text-align: left;
|
||||
caption-side: bottom;
|
||||
margin-bottom: 2em; }
|
||||
table * {
|
||||
border: none; }
|
||||
table thead, table tr {
|
||||
display: table;
|
||||
table-layout: fixed;
|
||||
width: 100%; }
|
||||
table tr:nth-child(even) {
|
||||
background-color: #ccc; }
|
||||
table tbody {
|
||||
display: block;
|
||||
max-height: 70vh;
|
||||
overflow-y: auto; }
|
||||
table td, table th {
|
||||
padding: 0.25em; }
|
||||
|
||||
table, .highlight > pre, pre.example {
|
||||
max-height: 70vh;
|
||||
margin: 1em 0;
|
||||
padding: 1em;
|
||||
overflow: auto;
|
||||
font-size: 0.85rem;
|
||||
border: 1px solid rgba(250, 100, 50, 0.5); }
|
||||
|
||||
.caption {
|
||||
font-family: monospace;
|
||||
font-size: 0.75em;
|
||||
text-align: center;
|
||||
color: grey;
|
||||
margin-top: 0; }
|
||||
|
||||
.footnote-definition sup {
|
||||
float: left; }
|
||||
|
||||
.footnote-definition .footnote-body {
|
||||
margin: 1em 0;
|
||||
padding: 0 1em;
|
||||
border: 1px solid rgba(250, 100, 50, 0.3);
|
||||
background-color: #ccc; }
|
||||
.footnote-definition .footnote-body p:only-child {
|
||||
margin: 0.2em 0; }
|
2
main.go
2
main.go
|
@ -50,5 +50,5 @@ func highlightCodeBlock(source, lang string) string {
|
|||
l = chroma.Coalesce(l)
|
||||
it, _ := l.Tokenise(nil, source)
|
||||
_ = html.New().Format(&w, styles.Get("friendly"), it)
|
||||
return w.String()
|
||||
return `<div class="highlight">` + w.String() + `</div>`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue