Closed michealbenedict closed 10 years ago
On this point:
May limit flexibility in terms of how the book can be generated. For example, How can I generate a rich HTML site with custom design?
Pandoc has a css and template flag.
IMO, I think toc.md
should be a JSON file, which makes preprocessing so much easier by slimming up gulpfile.js
(i.e. no need for all that parsing).
If you need to, you can easily generate the markdown from the JSON as needed.
May limit flexibility in terms of how the book can be generated. For example, How can I generate a rich HTML site with custom design?
gulp-markdown-pdf supports custom CSS: https://github.com/alanshaw/markdown-pdf#optionscsspath
IMO, I think toc.md should be a JSON file, which makes preprocessing so much easier by slimming up gulpfile.js (i.e. no need for all that parsing).
https://github.com/tooling/book-of-modern-frontend-tooling/pull/31#discussion_r9368917
Summarizing the discussion around pandoc and non-pandoc solution (npm modules) to help come to a consensus.
AFAIK, the formats we are looking to export this book are
@sindresorhus is concerned regarding speed and ease of installation My qualm with pandoc is the requirement of TeXLive/MacTex to help generate PDF. Apart from that, pandoc is a very well supported tool which works in a predictable manner across all three platforms (win, osx and linux).
I am particularly concerned regarding the support when opting to use npm modules. HTML (node-markdown) - project has a large community and is supported well PDF (markdown-pdf) - seems to be updated frequently I was unable to find well established projects to help export to EPUB, MOBI formats, any recommendations?
I am leaning a bit towards pandoc.
IMO, I think toc.md should be a JSON file, which makes preprocessing so much easier by slimming > up gulpfile.js (i.e. no need for all that parsing).
If you need to, you can easily generate the markdown from the JSON as needed.
@Dashed Do you have any thoughts around moving to semantic file naming as suggested in #21 and based off @sindresorhus https://github.com/tooling/book-of-modern-frontend-tooling/pull/31#discussion_r9368917? I'll soon be submitting a patch for this.
@rowoot i would prefer both. Pandoc for epub/mobi and gulp-markdown-pdf/gulp-markdown for pdf/html. That way we can skip the tex dependency, while still being able to produce all wanted formats.
@rowoot I think semantic file naming may be the way to go -- though I don't think it may matter when you consider something like the following for JSON:
[
{
"name": "Introduction",
"file": "path/to/file"
},
{
"name": "Build Systems",
"toc": [
{
"name": "Modern tools vs shell scripts",
"file": "build-systems/modern-tools-vs-shell-scripts.md"
}
]
}
]
If it's possible to have metadata in the markdown files, then you can just outsource the name
property to the respective file. Then with this and the semantic file naming, you wouldn't need the toc.json
anymore since you can just recursively traverse the directory tree, and inspect the metadata of each file.
So, something like https://gist.github.com/Dashed/8792825 would allow custom frontmatter in YAML for markdown files. All it does is extract frontmatter. You'll need another transform stream to parse them when building the toc.
I tried both the approaches, and here is my feedback.
After re-evaluating, I am leaning towards the TOC based approach because of its simplicity (from the perspective of a user who is contributing to the book and the folks who would review the PR). Thoughts?
Just curious, what does your JSON object look like for the TOC based approach?
Looks like the JSON file can get gnarly really fast. What if you store it in YAML format? Then convert to JSON when importing it. I think either JSON or YAML would still be verbose.
Looking at the alternative solutions, it looks like, in my opinion, that the markdown format (as a list) looks to be the way to go -- in terms of readability and maintainability. At this point, it would be consideration between of having custom markdown parser and the verbosity that the JSON approach requires.
I feel that having a table-of-contents metadata file should somehow be unnecessary -- but it wouldn't be a big deal if it's easy to maintain.
What if you store it in YAML format?
Readability would still not match the markdown approach.
At this point, it would be consideration between of having custom markdown parser and the verbosity that the JSON approach requires.
My focus is to make the process of contributing content to the book super simple. Thus I am leaning towards using markdown (over JSON) for the TOC approach even though there is some minor preprocessing (parse the markdown file) using gulp.
I feel that having a table-of-contents metadata file should somehow be unnecessary -- but it wouldn't be a big deal if it's easy to maintain.
Along with being a metadata file, It also helps in structuring the chapters/topics when exporting to different formats (no need for semantic naming).
My vote's on the markdown approach of TOC as is.
Changelog:
Usage:
$ gulp
[gulp] Running 'default'...
[gulp] Available Tasks:
[gulp] generate:html
[gulp] generate:pdf
[gulp] generate:epub
[gulp] Finished 'default' in 1.5 ms
(ping) .. does this look good to merge?
I noticed there is no task for individual HTML pages. I only see a concatenated, conglomerate version.
I did think about it, but descoped it at the moment till I can find out better mechanisms (along with pros and cons) of exporting it as a site.
For now, removing the concat()
gulp task can export it as individual HTML pages.
Does the markdown-to-html plugin support templates?
This looks good to merge but will need a little rebase work. Once we're all green on this side I'd be happy for us to land this.
@Dashed What do you mean by templates? The gulp markdown task uses https://github.com/chjj/marked library if this helps.
Changelog:
A draft PDF version of the book (currently not styled), https://dl.dropboxusercontent.com/u/32194349/book.pdf
Thanks for all your work on this @rowoot. Landed!
Thanks @addyosmani @sindresorhus and @Dashed for all the feedback! Just FYI, this PR addresses #21 and #8 (feel free to close the issues or let me know if there is something missing).
Addresses Issue #8
[Dependencies: Pandoc and TeXLive|MacTex] Quick heads up: I used gulp instead of grunt to play with it. I am willing to change back to grunt if required.
This PR adds a primitive build system to generate the book in pdf and html formats. Thanks to the use pandoc, this book can be exported to various formats with the addition of simple gulp tasks. I have also listed the requirements, constraints I assumed for my proposed solution. Refer to README.md for instructions on how to use the gulp tasks to build the book. Happy to iterate based on feedback
Requirements
Constraints:
Proposed solution:
This could have been a simple JSON file as well since the main purpose is to define how the content should be exported (as pdf,html or any other file format), but I chose markdown to be consistent with the content. I also felt having a toc.md would be flexibile to generate a (well linked) toc portion of the book easily.
I used pandoc since I felt that it addressed the need to export to various file types as required.
Pros
Cons