-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix typo and add asciidoctor generator to pdf
- Loading branch information
Vache, Aurelie
committed
Dec 4, 2018
1 parent
577a28f
commit e81317f
Showing
17 changed files
with
3,220 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
# Created by https://www.gitignore.io/api/node | ||
# Edit at https://www.gitignore.io/?templates=node | ||
|
||
### Node ### | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
#DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# End of https://www.gitignore.io/api/node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict' | ||
|
||
process.title = 'asciidoctorjs-pdf' | ||
const cli = require('../lib/cli.js') | ||
|
||
async function main () { | ||
const argv = cli.argsParser().argv | ||
return cli.run(argv) | ||
} | ||
|
||
main() | ||
.then((result) => { | ||
if (result.exit) { | ||
process.exit(0) | ||
} | ||
}) | ||
.catch((error) => { | ||
console.log('error', error) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
@import 'https://fonts.googleapis.com/css?family=Roboto:400,500'; | ||
|
||
@page { | ||
size: 508mm 361mm; | ||
margin: 0.5cm; | ||
padding: 0.5cm; | ||
} | ||
|
||
@page :first { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
html, body { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
color: #4a4a4a; | ||
text-align: justify; | ||
} | ||
|
||
html { | ||
font-family: Roboto, 'DejaVu Sans', Arial, sans-serif; | ||
font-size: 18px; | ||
} | ||
|
||
header { | ||
background-color: #131313; | ||
display: grid; | ||
grid-template-columns: auto 1fr auto; | ||
padding: 0.7cm 12em 0.7cm 0.7cm; | ||
align-items: center; | ||
color: white; | ||
} | ||
|
||
header > a { | ||
color: white; | ||
} | ||
|
||
header > .wordmark { | ||
max-height: 3em; | ||
} | ||
|
||
header > .website { | ||
font-size: 1.4em; | ||
font-weight: 400; | ||
align-self: end; | ||
} | ||
|
||
header > .logo { | ||
position: absolute; | ||
top: 1em; | ||
right: 3em; | ||
max-width: 6em; | ||
} | ||
|
||
h1 { | ||
font-size: 2em; | ||
margin: 0; | ||
padding: 0 0 0 1em; | ||
font-weight: 400; | ||
} | ||
|
||
section.content { | ||
margin: 0.5cm; | ||
padding: 0; | ||
columns: auto calc((100vw / 3) - 3cm); | ||
} | ||
|
||
.admonitionblock div { | ||
font-weight: bold | ||
} | ||
|
||
.sect1 { | ||
max-width: calc((100vw / 3) - 3cm); | ||
margin-right: 1.2cm; | ||
margin-left: 1.2cm; | ||
margin-top: 0.5cm; | ||
break-inside: avoid-region; | ||
} | ||
|
||
h2 { | ||
color: #131313; | ||
font-size: 1.4em; | ||
font-weight: 500; | ||
margin-top: 0; | ||
} | ||
|
||
h3 { | ||
font-size: 1.1em; | ||
font-weight: 500; | ||
} | ||
|
||
.listingblock pre { | ||
background:#fafcfe; | ||
border: 1px solid #d5d4d9; | ||
color: #4a4a4a; | ||
} | ||
|
||
|
||
.listingblock pre,.listingblock pre[class] { | ||
font-size: 0.8em; | ||
line-height: 1.5em; | ||
border-radius: 4px; | ||
word-wrap: break-word; | ||
padding: 1em; | ||
} | ||
|
||
.listingblock { | ||
margin-bottom: 2em; | ||
} | ||
|
||
a { | ||
color: #131313; | ||
text-decoration: none; | ||
} | ||
|
||
.authors { | ||
margin-top: auto; | ||
} | ||
|
||
.author { | ||
display: grid; | ||
grid-template-columns: auto 1fr; | ||
align-items: center; | ||
padding-bottom: 1em; | ||
} | ||
|
||
.author-avatar > img { | ||
border-radius: 50%; | ||
max-height: 2em; | ||
} | ||
|
||
.author-avatar { | ||
grid-row-start: span 2; | ||
padding-right: 1em; | ||
} | ||
|
||
.author-bio { | ||
font-size: 0.9em | ||
} | ||
|
||
.page-break { | ||
page-break-after: always; | ||
} | ||
|
||
pre { | ||
break-inside: avoid; | ||
} | ||
|
||
.single-block { | ||
break-inside: avoid-column; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const getAuthors = function (node) { | ||
const result = []; | ||
const authorCount = node.getAttribute('authorcount') | ||
if (authorCount > 1) { | ||
for (let index = 1; index < authorCount + 1; index++) { | ||
const author = node.getAttribute(`author_${index}`) | ||
const email = node.getAttribute(`email_${index}`) | ||
const bio = node.getAttribute(`authorbio_${index}`) | ||
let twitter; | ||
if (email && email.startsWith("https://twitter.com/")) { | ||
twitter = email.replace("https://twitter.com/", ""); | ||
} | ||
result.push({ name: author, email: email, bio: bio, twitter: twitter }) | ||
} | ||
} else { | ||
const author = node.getAttribute('author') | ||
const email = node.getAttribute('email') | ||
const bio = node.getAttribute(`authorbio`) | ||
let twitter; | ||
if (email && email.startsWith("https://twitter.com/")) { | ||
twitter = email.replace("https://twitter.com/", ""); | ||
} | ||
result.push({ name: author, email: email, bio: bio, twitter: twitter }) | ||
} | ||
return result; | ||
} | ||
|
||
const renderAuthors = function (authors) { | ||
return authors.map(author => { | ||
return `<div class="author"> | ||
<div class="author-avatar"><img src="http://avatars.io/twitter/${author.twitter}"/></div> | ||
<div class="author-name"><a href="${author.email}">@${author.twitter}</a></div> | ||
<div class="author-bio">${author.bio}</div> | ||
</div> | ||
`; | ||
}).join('\n') | ||
} | ||
|
||
|
||
module.exports = [{ | ||
paragraph: (ctx) => `<p class="${ctx.node.getRoles()}">${ctx.node.getContent()}</p>`, | ||
document: (ctx) => `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link href="./template/assets/style.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>${ctx.node.getHeader().getTitle()}</h1> | ||
</header> | ||
<section class="content"> | ||
${ctx.node.getContent()} | ||
<div class="sect1 authors"> | ||
<h3>Authors :</h3> | ||
${renderAuthors(getAuthors(ctx.node))} | ||
<div class="author-bio">${ctx.node.getAttribute('version')}</div> | ||
</div> | ||
</section> | ||
</body>`, | ||
page_break: () => `<div class="page-break"></div>` | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
# Generate | ||
|
||
## Pre-requisits | ||
|
||
`$ npm i yargs --save` | ||
|
||
## 1. Markdown to AsciiDoc | ||
|
||
`$ pandoc -s --columns=80 --atx-headers -t asciidoc -o out.adoc README.md` | ||
|
||
##2. | ||
##2. Asciidoc to PDF | ||
|
||
`$ ./bin/asciidoctorjs-pdf /home/scraly/git/src/github.com/scraly/terraform-cheat-sheet/out.adoc --template-require ../examples/cheat-sheet/redhat/template.js` | ||
`$ ./bin/asciidoctorjs-pdf terraform-cheat-sheet.adoc --template-require ../examples/cheat-sheet/template/template.js` |
Oops, something went wrong.