mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-12 21:52:42 +00:00
Work on the Table of contents snippet
This commit is contained in:
@@ -48,7 +48,7 @@ const getTOC = (pages) => {
|
||||
}
|
||||
|
||||
module.exports = function(brew){
|
||||
const pages = brew.split('\\page');
|
||||
|
||||
const TOC = getTOC(pages);
|
||||
const markdown = _.reduce(TOC, (r, g1, idx1)=>{
|
||||
r.push(`- **[${idx1 + 1} ${g1.title}](#p${g1.page})**`)
|
||||
|
||||
@@ -6,7 +6,6 @@ const cx = require('classnames');
|
||||
const SnippetGroup = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
brew : '',
|
||||
name : '',
|
||||
icon : 'fa-rocket',
|
||||
snippets : [],
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
///////////////////
|
||||
.spell{
|
||||
ul:first-of-type{
|
||||
@@ -16,7 +15,7 @@
|
||||
.monster{
|
||||
.breakAvoid();
|
||||
.pseudoBorder();
|
||||
padding : 10px 5px;
|
||||
padding : 10px 5px;
|
||||
table{
|
||||
color : @headerText;
|
||||
}
|
||||
@@ -86,7 +85,6 @@
|
||||
border-image-width : 47px;
|
||||
}
|
||||
}
|
||||
|
||||
.footnote{
|
||||
position : absolute;
|
||||
right : 80px;
|
||||
@@ -97,13 +95,46 @@
|
||||
color : @gold;
|
||||
text-align : right;
|
||||
}
|
||||
|
||||
|
||||
//*****************************
|
||||
// * TABLE OF CONTENTS
|
||||
// *****************************/
|
||||
.toc{
|
||||
.breakAvoid();
|
||||
h1{
|
||||
text-align : center;
|
||||
}
|
||||
li{
|
||||
margin-bottom : 3px;
|
||||
strong, em::after{
|
||||
font-family : BookInsanity;
|
||||
font-size : 13px;
|
||||
font-style : normal;
|
||||
font-weight : 500;
|
||||
color : black;
|
||||
}
|
||||
em{
|
||||
display : block;
|
||||
overflow : hidden;
|
||||
width : auto;
|
||||
font-style : normal;
|
||||
white-space : nowrap;
|
||||
&:after{
|
||||
content : " ..............................................................................................................";
|
||||
}
|
||||
}
|
||||
strong{
|
||||
float : right;
|
||||
margin-left : 4px;
|
||||
}
|
||||
h3{
|
||||
margin-top : 15px;
|
||||
em{ color : @crimson; }
|
||||
em::after{ display : none; }
|
||||
}
|
||||
h4{
|
||||
margin-top : 10px;
|
||||
em{ color : @crimson; }
|
||||
}
|
||||
}
|
||||
a{
|
||||
color : black;
|
||||
text-decoration : none;
|
||||
@@ -115,17 +146,7 @@
|
||||
padding-left : 0;
|
||||
list-style-type : none;
|
||||
}
|
||||
&>ul>li{
|
||||
margin-bottom : 10px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.wide{
|
||||
column-span : all;
|
||||
-webkit-column-span : all;
|
||||
@@ -133,25 +154,25 @@
|
||||
}
|
||||
.oneColumn{
|
||||
column-count : 1;
|
||||
column-gap : 1cm;
|
||||
// column-gap : 1cm;
|
||||
}
|
||||
.twoColumn{
|
||||
column-count : 2;
|
||||
column-gap : 1cm;
|
||||
//column-fill: auto;
|
||||
////column-gap : 1cm;
|
||||
}
|
||||
.threeColumn{
|
||||
column-count : 3;
|
||||
column-gap : 1cm;
|
||||
//column-gap : 1cm;
|
||||
}
|
||||
.fourColumn{
|
||||
column-count : 4;
|
||||
column-gap : 1cm;
|
||||
//column-gap : 1cm;
|
||||
}
|
||||
.columnSplit{
|
||||
visibility : hidden;
|
||||
-webkit-column-break-after : always;
|
||||
break-after : always;
|
||||
-moz-column-break-after : always;
|
||||
-webkit-column-break-bfore : always;
|
||||
break-before : column;
|
||||
}
|
||||
.brushed{
|
||||
border-image-outset : 25px 17px;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@crimson : #58180D;
|
||||
@red : #9c2b1b;
|
||||
@gold : #c9ad6a; //brown?
|
||||
@green : #e0e5c1;
|
||||
|
||||
@@ -3,9 +3,10 @@ const _ = require('lodash');
|
||||
module.exports = _.merge(
|
||||
require('./spell.snippet.js'),
|
||||
require('./table.snippet.js'),
|
||||
require('./classTable.snippet.js'),
|
||||
require('./class.snippet.js'),
|
||||
require('./note.snippet.js'),
|
||||
require('./monster.snippet.js')
|
||||
require('./monster.snippet.js'),
|
||||
require('./toc.snippet.js')
|
||||
|
||||
|
||||
//wide
|
||||
|
||||
112
shared/homebrewery/snippets/brew/toc.snippet.js
Normal file
112
shared/homebrewery/snippets/brew/toc.snippet.js
Normal file
@@ -0,0 +1,112 @@
|
||||
const _ = require('lodash');
|
||||
const Store = require('homebrewery/brew.store.js');
|
||||
|
||||
const getTOC = (text) => {
|
||||
const pages = text.split('\\page');
|
||||
const add1 = (title, page)=>{
|
||||
res.push({
|
||||
title : title,
|
||||
page : page + 1,
|
||||
children : []
|
||||
});
|
||||
}
|
||||
const add2 = (title, page)=>{
|
||||
if(!_.last(res)) add1('', page);
|
||||
_.last(res).children.push({
|
||||
title : title,
|
||||
page : page + 1,
|
||||
children : []
|
||||
});
|
||||
}
|
||||
const add3 = (title, page)=>{
|
||||
if(!_.last(res)) add1('', page);
|
||||
if(!_.last(_.last(res).children)) add2('', page);
|
||||
_.last(_.last(res).children).children.push({
|
||||
title : title,
|
||||
page : page + 1,
|
||||
children : []
|
||||
});
|
||||
}
|
||||
|
||||
let res = [];
|
||||
_.each(pages, (page, pageNum)=>{
|
||||
const lines = page.split('\n');
|
||||
_.each(lines, (line) => {
|
||||
if(_.startsWith(line, '# ')){
|
||||
const title = line.replace('# ', '');
|
||||
add1(title, pageNum)
|
||||
}
|
||||
if(_.startsWith(line, '## ')){
|
||||
const title = line.replace('## ', '');
|
||||
add2(title, pageNum);
|
||||
}
|
||||
if(_.startsWith(line, '### ')){
|
||||
const title = line.replace('### ', '');
|
||||
add3(title, pageNum);
|
||||
}
|
||||
})
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
//TODO: TOC not perfect yet
|
||||
|
||||
toc : (text)=>{
|
||||
text = text || Store.getBrewCode();
|
||||
|
||||
console.log(getTOC(text));
|
||||
|
||||
const TOC = getTOC(text)
|
||||
|
||||
const markdown = _.reduce(TOC, (r, g1, idx1)=>{
|
||||
r.push(`- ### [**${g1.page}** *${g1.title}*](#p${g1.page})`)
|
||||
if(g1.children.length){
|
||||
_.each(g1.children, (g2, idx2) => {
|
||||
r.push(` - #### [**${g2.page}** *${g2.title}*](#p${g2.page})`)
|
||||
if(g2.children.length){
|
||||
_.each(g2.children, (g3, idx3) => {
|
||||
r.push(` - [**${g3.page}** *${g3.title}*](#p${g3.page})`)
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return r;
|
||||
}, []).join('\n');
|
||||
|
||||
|
||||
|
||||
return `{{toc
|
||||
# Contents
|
||||
|
||||
${markdown}
|
||||
|
||||
}}`;
|
||||
/*
|
||||
|
||||
- ### [**4** *Preface*](#p3)
|
||||
- ### [**5** *Introduction*](#p3)
|
||||
- [**5** *Worlds of Adventure*](#p5)
|
||||
- [**6** *Using This Book*](#p5)
|
||||
- [**6** *How to Play*](#p5)
|
||||
- [**7** *Adventures*](#p5)
|
||||
|
||||
- ### [**5** *Introduction*](#p3)
|
||||
- #### [**5** *Worlds of Adventure*](#p5)
|
||||
- [**6** *Using This Book*](#p5)
|
||||
- [**6** *How to Play*](#p5)
|
||||
- #### [**7** *Adventures*](#p5)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}}
|
||||
|
||||
|
||||
`;*/
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
|
||||
# Images
|
||||
|
||||
Image basics
|
||||
- background images
|
||||
- Adding brushes
|
||||
|
||||
|
||||
How to make spacers
|
||||
@@ -22,6 +24,18 @@ How to make spacers
|
||||
#p2:before{ counter-reset: phb-page-numbers 30; }
|
||||
|
||||
|
||||
- blockquotes, cite
|
||||
|
||||
styling images
|
||||
|
||||
|
||||
# Print
|
||||
- Saving ink
|
||||
- Changing page size
|
||||
- Printing to PDF
|
||||
|
||||
|
||||
|
||||
## Changing backgrounds
|
||||
{{wide
|
||||
In style
|
||||
@@ -33,3 +47,61 @@ In style
|
||||
```
|
||||
}}
|
||||
|
||||
## Changes in v3
|
||||
|
||||
``` ``` -> \column
|
||||
|
||||
|
||||
\page
|
||||
|
||||
## Columns
|
||||
{{wide,twoColumn
|
||||
This is how columns work sdfsdfsdf
|
||||
```
|
||||
{{twoColumn
|
||||
|
||||
| d4 | Manicurist Level | Equipment |
|
||||
|:---:|:---:|:---|
|
||||
| 1 | 1st | The four fragments of the Disk of Madness |
|
||||
| 2 | 3rd | Broch of Air Blasts |
|
||||
| 3 | 5th | The four fragments of the Disk of Madness |
|
||||
| 4 | 7th | 3rd born child |
|
||||
|
||||
|
||||
| d4 | Manicurist Level | Equipment |
|
||||
|:---:|:---:|:---|
|
||||
| 1 | 1st | The four fragments of the Disk of Madness |
|
||||
| 2 | 3rd | Broch of Air Blasts |
|
||||
| 3 | 5th | The four fragments of the Disk of Madness |
|
||||
| 4 | 7th | 3rd born child |
|
||||
|
||||
}}
|
||||
|
||||
```
|
||||
|
||||
\column
|
||||
|
||||
|
||||
{{twoColumn
|
||||
|
||||
| d4 | Manicurist Level | Equipment |
|
||||
|:---:|:---:|:---|
|
||||
| 1 | 1st | The four fragments of the Disk of Madness |
|
||||
| 2 | 3rd | Broch of Air Blasts |
|
||||
| 3 | 5th | The four fragments of the Disk of Madness |
|
||||
| 4 | 7th | 3rd born child |
|
||||
|
||||
|
||||
| d4 | Manicurist Level | Equipment |
|
||||
|:---:|:---:|:---|
|
||||
| 1 | 1st | The four fragments of the Disk of Madness |
|
||||
| 2 | 3rd | Broch of Air Blasts |
|
||||
| 3 | 5th | The four fragments of the Disk of Madness |
|
||||
| 4 | 7th | 3rd born child |
|
||||
|
||||
}}
|
||||
|
||||
}}
|
||||
|
||||
this is after
|
||||
|
||||
|
||||
@@ -34,18 +34,13 @@ This tool will **always** be free, never have ads, and I will never offer any "p
|
||||
|
||||
}}
|
||||
|
||||
> This is a cool blockquote fdgfgsfg sfd sdfsdfsdfsdfsdfsdf sdfsdfsdfssdfsdffgsdfgsdfg
|
||||
> You know?
|
||||
>
|
||||
> One with quotes and what not
|
||||
> yeah yeah yeah
|
||||
> {{cite -- Very cool person }}
|
||||
|
||||
>##### PDF Exporting
|
||||
> PDF Printing works best in Chrome. If you are having quality/consistency issues, try using Chrome to print instead.
|
||||
>
|
||||
> After clicking the "Print" item in the navbar a new page will open and a print dialog will pop-up.
|
||||
> * Set the **Destination** to "Save as PDF"
|
||||
> * Set **Paper Size** to "Letter"
|
||||
> * If you are printing on A4 paper, make sure to have the "A4 page size snippet" in your brew
|
||||
> * In **Options** make sure "Background Images" is selected.
|
||||
> * Hit print and enjoy! You're done!
|
||||
>
|
||||
> If you want to save ink or have a monochrome printer, add the **Ink Friendly** snippet to your brew before you print
|
||||
|
||||
{{note
|
||||
##### PDF Exporting
|
||||
@@ -64,7 +59,7 @@ This tool will **always** be free, never have ads, and I will never offer any "p
|
||||
}}
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
```
|
||||
cool stuff
|
||||
@@ -91,12 +86,9 @@ If you are looking for more 5e Homebrew resources check out [r/UnearthedArcana](
|
||||
|
||||
|
||||
|
||||
<img src='http://i.imgur.com/hMna6G0.png' style='position:absolute;bottom:50px;right:30px;width:280px' />
|
||||
|
||||
<div class='pageNumber'>1</div>
|
||||
<div class='footnote'>PART 1 | FANCINESS</div>
|
||||
|
||||
|
||||
{{footnote PART 1 | FANCINESS }}
|
||||
|
||||
|
||||
\page
|
||||
|
||||
Reference in New Issue
Block a user