Add (a bad) comparison to goorgeous to github pages
The stylesheet would have to be adapted to get a fair visual comparison - but this should be enough for comparing behavior
This commit is contained in:
parent
0eb3baf1bb
commit
5afba92f5f
2 changed files with 79 additions and 20 deletions
34
etc/_goorgeous.go
Normal file
34
etc/_goorgeous.go
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/chaseadamsio/goorgeous"
|
||||||
|
"github.com/russross/blackfriday"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
log.SetFlags(0)
|
||||||
|
log.SetOutput(os.Stdout)
|
||||||
|
|
||||||
|
path := os.Args[1]
|
||||||
|
in, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
flags := blackfriday.HTML_USE_XHTML
|
||||||
|
flags |= blackfriday.LIST_ITEM_BEGINNING_OF_LIST
|
||||||
|
flags |= blackfriday.HTML_FOOTNOTE_RETURN_LINKS
|
||||||
|
parameters := blackfriday.HtmlRendererParameters{}
|
||||||
|
parameters.FootnoteReturnLinkContents = "<sup>↩</sup>"
|
||||||
|
renderer := blackfriday.HtmlRendererWithParameters(flags, "", "", parameters)
|
||||||
|
log.Print(string(goorgeous.Org(in, renderer)))
|
||||||
|
}
|
|
@ -1,24 +1,35 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
org_files=org/testdata/*.org
|
examples_style="
|
||||||
examples="
|
.source {
|
||||||
<h1>Sections</h1>
|
display: grid;
|
||||||
<style>
|
grid-template-columns: 1fr 1fr;
|
||||||
|
grid-gap: 1rem;
|
||||||
|
}
|
||||||
|
.org, .html {
|
||||||
|
border: 1px dashed grey;
|
||||||
|
padding: 1em;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
.sections { margin-left: 2rem; }
|
.sections { margin-left: 2rem; }
|
||||||
.sections a { display: block; padding: 0.25em 0; }
|
.sections a { display: block; padding: 0.25em 0; }
|
||||||
.sections a:hover, .sections a:focus, .sections a:active { background: rgba(200, 200, 200, 0.2); }
|
.sections a:hover, .sections a:focus, .sections a:active { background: rgba(200, 200, 200, 0.2); }"
|
||||||
</style>
|
|
||||||
|
org_files=org/testdata/*.org
|
||||||
|
go_org_examples="
|
||||||
|
<h1>Sections</h1>
|
||||||
|
<style>$examples_style</style>
|
||||||
<ul class='sections'>"
|
<ul class='sections'>"
|
||||||
for org_file in $org_files; do
|
for org_file in $org_files; do
|
||||||
name=$(basename $org_file)
|
name=$(basename $org_file)
|
||||||
examples+="<li><a id='toc-${name}' href='#${name}'>${name}</a>"
|
go_org_examples+="<li><a id='toc-${name}' href='#${name}'>${name}</a>"
|
||||||
done
|
done
|
||||||
examples+="</ul><hr>"
|
examples+="</ul><hr>"
|
||||||
|
|
||||||
for org_file in $org_files; do
|
for org_file in $org_files; do
|
||||||
echo generating content for $org_file
|
echo generating content for $org_file
|
||||||
name=$(basename $org_file)
|
name=$(basename $org_file)
|
||||||
examples+="
|
go_org_examples+="
|
||||||
<h2><a id='${name}' href='#toc-${name}'>${name}</a></h2>
|
<h2><a id='${name}' href='#toc-${name}'>${name}</a></h2>
|
||||||
<div class='source'>
|
<div class='source'>
|
||||||
<pre class='org'>$(sed 's/&/\&/g; s/</\</g; s/>/\>/g;' $org_file)</pre>
|
<pre class='org'>$(sed 's/&/\&/g; s/</\</g; s/>/\>/g;' $org_file)</pre>
|
||||||
|
@ -91,21 +102,10 @@ convert="
|
||||||
index="<html>
|
index="<html>
|
||||||
<head>
|
<head>
|
||||||
<style>$(cat etc/style.css)</style>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
$convert
|
$convert
|
||||||
$examples
|
$go_org_examples
|
||||||
</body>
|
</body>
|
||||||
</html>"
|
</html>"
|
||||||
|
|
||||||
|
@ -120,8 +120,33 @@ convert="<html>
|
||||||
</html>"
|
</html>"
|
||||||
|
|
||||||
mkdir -p gh-pages
|
mkdir -p gh-pages
|
||||||
|
go get github.com/chaseadamsio/goorgeous
|
||||||
|
cp etc/_goorgeous.go gh-pages/goorgeous.go
|
||||||
|
go build -o gh-pages/goorgeous gh-pages/goorgeous.go
|
||||||
|
go_org_vs_goorgeous_examples="<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
$(cat etc/style.css)
|
||||||
|
$examples_style
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>"
|
||||||
|
for org_file in $org_files; do
|
||||||
|
echo generating content for $org_file
|
||||||
|
name=$(basename $org_file)
|
||||||
|
go_org_vs_goorgeous_examples+="
|
||||||
|
<h2><a id='${name}' href='#toc-${name}'>${name}</a></h2>
|
||||||
|
<div class='source'>
|
||||||
|
<div class='html'>$(./gh-pages/goorgeous $org_file)</div>
|
||||||
|
<div class='html'>$(./go-org $org_file html-chroma)</div>
|
||||||
|
</div>"
|
||||||
|
done
|
||||||
|
go_org_vs_goorgeous_examples+="</body></html>"
|
||||||
|
rm gh-pages/goorgeous gh-pages/goorgeous.go
|
||||||
|
|
||||||
echo "$index" > gh-pages/index.html
|
echo "$index" > gh-pages/index.html
|
||||||
echo "$convert" > gh-pages/convert.html
|
echo "$convert" > gh-pages/convert.html
|
||||||
|
echo "$go_org_vs_goorgeous_examples" > gh-pages/go-org-vs-goorgeous.html
|
||||||
cp etc/_wasm.go gh-pages/wasm.go
|
cp etc/_wasm.go gh-pages/wasm.go
|
||||||
GOOS=js GOARCH=wasm go build -o gh-pages/main.wasm gh-pages/wasm.go
|
GOOS=js GOARCH=wasm go build -o gh-pages/main.wasm gh-pages/wasm.go
|
||||||
rm gh-pages/wasm.go
|
rm gh-pages/wasm.go
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue