Compare commits

..

1310 Commits

Author SHA1 Message Date
Samy Pesse a37ee3457a Bump version to 2.6.6 2015-12-16 21:02:49 +01:00
Samy Pesse 6969bb9a5c Fix include of css in pdf header/footer 2015-12-16 20:55:06 +01:00
Samy Pessé 4567041456 Bump version to 2.6.5 2015-12-11 14:48:13 +01:00
Samy Pessé 49f09e46da Fix support for local styles 2015-12-11 14:40:20 +01:00
Samy Pessé becd027563 Check style existence on output folder instead of source 2015-12-11 14:31:08 +01:00
Samy Pessé 6eb1605be6 Fix #1041 : fix glossary terms being replaced in script (ex: math) 2015-12-08 15:27:11 +01:00
Samy Pessé 5c16aec096 Use gitbook-markdown-css@1.0.1 2015-12-04 15:43:51 +01:00
Samy Pessé 835e2dc1fb Bump version to 2.6.4 2015-12-02 13:29:04 +01:00
Samy Pessé e2378ab29a Update gitbook-parsers@0.8.9 2015-12-02 13:25:13 +01:00
Samy Pesse 0f1d7eb391 Bump version to 2.6.3 2015-12-02 10:12:49 +01:00
Samy Pesse dd358b8b95 Update gitbook-parsers@0.8.8 2015-12-02 10:11:06 +01:00
Samy Pessé 21cf5fcaf4 Bump version to 2.6.2 2015-11-25 11:56:29 +01:00
Samy Pessé 8c7509759b Update nunjucks@2.2.0 2015-11-25 11:54:19 +01:00
Samy Pessé dc9ac0d0ff Compile js 2015-11-25 11:52:50 +01:00
Samy Pessé 93b401ca9f Add trailing slash to gitbook.state.root, fix value of gitbook.state.bookRoot 2015-11-25 11:49:55 +01:00
Samy Pessé b137d8270a Bump version to 2.6.1 2015-11-25 11:02:15 +01:00
Samy Pessé 6db7757451 Fix gitbook.state.innerLanguage: use camel case 2015-11-25 11:01:17 +01:00
Samy Pessé 43fd42b757 Bump version to 2.6.0 2015-11-25 10:54:09 +01:00
Samy Pessé 5d1c4d2b9f Fix #926: use zh-hans instead of zh-cn and ja instead of jp 2015-11-25 10:52:36 +01:00
Samy Pessé 425acd8bf6 Follow github style: change color of h6 headings 2015-11-25 10:42:36 +01:00
Samy Pessé 414160e0df Merge pull request #1027 from GitbookIO/revert-1020-remove-font-smooth
Revert "Fix small font rendering issue on Macs"
2015-11-25 10:32:28 +01:00
Samy Pessé 117c6aefe8 Revert "Fix small font rendering issue on Macs" 2015-11-25 10:32:17 +01:00
Samy Pessé 13d584d39a Merge pull request #1020 from dylang/remove-font-smooth
Fix small font rendering issue on Macs
2015-11-25 10:28:23 +01:00
Samy Pessé 9bc89c24f5 Fix #1023: close sidebar after clicking a link on mobile 2015-11-25 10:25:58 +01:00
Samy Pessé 5a8c4d5a4e Cleanup lib/generators/json.js 2015-11-25 10:14:34 +01:00
Samy Pessé 98da83a552 Fix urijs dependency on linux 2015-11-25 10:08:24 +01:00
Samy Pessé 5344a30a3b Generate css 2015-11-25 10:05:16 +01:00
Samy Pessé d5d6b3673e Add bookRoot to gitbook.state 2015-11-25 10:05:05 +01:00
Samy Pessé d2a2fe88d1 Update urijs@1.17.0 and tiny-lr 2015-11-25 10:04:44 +01:00
Samy Pesse ced44c86ce Fix #1022: fix bottom margin for lists 2015-11-24 23:38:26 +01:00
Samy Pessé ee402ad444 Merge pull request #1018 from atilacamurca/patch-1
Update README.md
2015-11-19 12:24:42 +01:00
Dylan Greene 3d2155eb66 Make fonts nicer on Macs
Removed the `antialias` setting which tells Chrome to not use native font rendering and instead use something from the late 2010's that isn't subpixel-friendly and looks very blocky. This used to be required when OS X browsers didn't antialias by default because it made fonts look bolder than on Windows. This has since been fixed and we are advised to not use `-webkit-font-smooth`.

https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth
2015-11-17 16:15:33 -05:00
Samy Pessé bd24b03548 Add @buren to AUTHORS 2015-11-16 22:04:41 +01:00
Samy Pessé 5cb55a0f37 Merge pull request #1019 from buren/sv-locale
Add Swedish translation
2015-11-16 22:02:49 +01:00
Jacob Burenstam 163242f80f Add Swedish translation 2015-11-16 22:00:16 +01:00
Átila Camurça Alves 266bfcb8bf Update README.md
There is an extra space in the command line example that enable debug mode.
2015-11-16 16:45:33 -03:00
Samy Pessé d82fa02669 Update plugin-search@1.1.0 2015-11-16 13:09:05 +01:00
Samy Pessé 3a5207a0d2 Merge pull request #1016 from GitbookIO/fix/999
Fix #999: detection of structure should be case incensitive
2015-11-16 10:39:29 +01:00
Samy Pessé e38f3bb884 Improve book.findFile to be case incensitive 2015-11-16 10:31:24 +01:00
Samy Pessé 751cdd9b3b Add test for #999 2015-11-16 10:30:10 +01:00
Samy Pessé 8df6bdca89 Update node version for travis and appveyor tests 2015-11-16 10:18:52 +01:00
Samy Pessé f9df7545ad Merge pull request #1014 from GitbookIO/fix/1013
Fix #1013: prioritize structure defined in book.json
2015-11-16 10:16:52 +01:00
Samy Pessé 9b7a90afef Test first extension of structure itself in book.findFile 2015-11-16 10:06:31 +01:00
Samy Pessé 2ae83b3247 Add failing test for #1013 2015-11-16 09:55:45 +01:00
Samy Pessé 5d907f234e Merge pull request #1005 from mjanda/master
Czech translation
2015-11-07 21:56:28 +01:00
Marek Janda 3a005c4f13 Czech translation 2015-11-07 21:51:27 +01:00
Marek Janda 6c2f50470a Czech translation 2015-11-07 21:00:45 +01:00
Samy Pessé d233783942 Fix bottom margin of blockquote 2015-11-05 11:33:21 +01:00
Samy Pessé 3d9e4c80a2 Bump version to 2.5.2 2015-11-03 09:32:35 +01:00
Samy Pessé a7f49015c1 Fix custom styles for ebook 2015-11-03 09:25:51 +01:00
Samy Pessé 68ed2631dc Correctly show space between toolbar icon and text in buttons 2015-11-02 17:16:43 +01:00
Samy Pessé 2814fea67e Trigger "start" before "page.change" 2015-11-02 16:57:08 +01:00
Samy Pessé 3388be9db6 Update app.js 2015-10-27 23:11:55 +01:00
Samy Pessé 9b89319820 Bump version to 2.5.1 2015-10-27 23:11:31 +01:00
Samy Pessé ad34089df5 Merge changelog for 2.5.0 2015-10-27 23:10:29 +01:00
Samy Pessé 7a4c6bc326 Fix calcul of root in gitbook.state when serving index.html as / 2015-10-27 18:44:04 +01:00
Samy Pessé 6ab386ae35 Bump version to 2.5.0 2015-10-27 13:25:52 +01:00
Samy Pessé 0abbfde912 Add chapterTitle to app build 2015-10-27 12:19:54 +01:00
Samy Pessé 0521defb63 Add 'chapterTitle' to gitbook.state api 2015-10-27 12:18:04 +01:00
Samy Pessé ea4d96610f Compatibility for require of plugins 2015-10-24 21:36:17 +02:00
Samy Pessé 4bc56564b4 Comment gitbook.state api 2015-10-22 16:12:21 +02:00
Samy Pessé 013f7f09da Add gitbook.state.filepath
Fix gitbook.state.root
2015-10-22 16:11:05 +02:00
Samy Pessé f082de1f92 Bump version to 2.5.0-beta.7 2015-10-22 13:52:19 +02:00
Samy Pessé ad39dc8c0c Update app.js 2015-10-22 13:50:05 +02:00
Samy Pessé 481a76319f Provide gitbook.state.root to plugins 2015-10-22 13:49:28 +02:00
Samy Pessé 27a43d5aea Merge pull request #986 from GitbookIO/fix/heading_ids
Normalize ID for headings
2015-10-21 18:05:40 +02:00
Samy Pessé df1d5a0680 Correctly generate id if none found 2015-10-21 17:58:06 +02:00
Samy Pessé 722109faf0 Update gitbook-parsers@0.8.7 2015-10-21 16:22:47 +02:00
Samy Pessé d4dca7736a Update gitbook-parsers@0.8.6 2015-10-21 16:15:56 +02:00
Samy Pessé 4e90becd52 Use Arial as default font 2015-10-21 15:54:45 +02:00
Samy Pessé 26890e94eb Bump version to 2.5.0-beta.6 2015-10-20 18:20:44 +02:00
Samy Pessé 55c83f9a59 Use helvetica by default for pdf 2015-10-20 18:09:51 +02:00
Samy Pessé b837d82878 Fix default style for pdf footer and header 2015-10-20 18:02:23 +02:00
Samy Pessé cbdcdb1e0f Fix #974: correctly handle query in image urls 2015-10-20 17:22:01 +02:00
Samy Pessé 4fea85289e Merge pull request #983 from GitbookIO/fix/982
Fix #982: correctly handle templating in imported content
2015-10-20 17:09:15 +02:00
Samy Pessé ba5f9132c9 Fix #982: fix shortcuts for included templates 2015-10-20 17:08:44 +02:00
Samy Pessé 991681daa2 Add failing test for #982 2015-10-20 16:38:48 +02:00
Samy Pessé 2faf53e16b Bump version to 2.5.0-beta.5 2015-10-16 13:48:27 +02:00
Samy Pessé 5430ed99de Update gitbook-parsers@0.8.5 2015-10-16 13:47:09 +02:00
Samy Pessé fef4dfd05e Fix position of sidebar toggle button 2015-10-14 13:35:03 +02:00
Samy Pessé 05943db3b5 Bump version to 2.5.0-beta.4 2015-10-14 13:16:49 +02:00
Samy Pessé 682fabd1ef Fix position of glossary icon relative to sidebar toggler 2015-10-14 13:15:36 +02:00
Samy Pessé ee8ccc6d7e Fix legacy properties book.options.input, ... 2015-10-14 12:31:37 +02:00
Samy Pessé 8ee0bcac2a Bump version to 2.5.0-beta.3 2015-10-14 11:54:58 +02:00
Samy Pessé 0c4ad74788 Fix resolve of plugins for prereleases 2015-10-14 11:54:12 +02:00
Samy Pessé 7d944e4f1f Fix instruction for local developement 2015-10-14 11:48:27 +02:00
Samy Pessé 67b2394c16 Bump version to 2.5.0-beta.2 2015-10-14 11:39:23 +02:00
Samy Pessé 269d08a35f Correctly handle pre-version for plugins checks 2015-10-13 15:50:54 +02:00
Samy Pessé f626e83e48 Bump version to 2.5.0-beta.1 2015-10-13 15:21:20 +02:00
Samy Pessé 8ba18cd587 Merge pull request #979 from GitbookIO/feature/plugins_config
Improvements for plugin configurations
2015-10-13 15:14:26 +02:00
Samy Pessé 54c12fea89 Set default config for all plugins 2015-10-13 15:05:46 +02:00
Samy Pessé afb5ce71ce Update gitbook-plugin-sharing@1.0.1 2015-10-13 14:56:59 +02:00
Samy Pessé 6fef6acf10 Correctly apply defaults config to pluginsConfig 2015-10-13 14:55:39 +02:00
Samy Pessé a27411401b Update gitbook-plugin-fontsettings@1.0.2 2015-10-13 14:48:09 +02:00
Samy Pessé 3718fc319b Fix error in accessing plugins config 2015-10-13 14:47:33 +02:00
Samy Pessé c6c9463f8c Update gitbook-plugin-search@1.0.2 2015-10-13 14:38:54 +02:00
Samy Pessé b410685318 Update gitbook-plugin-search@1.0.1 2015-10-13 14:34:29 +02:00
Samy Pessé b742b29259 Add tests for plugins config validation 2015-10-13 14:31:11 +02:00
Samy Pessé df5d27ab61 Use jsonschema to valid and default plugins config 2015-10-13 13:56:46 +02:00
Samy Pessé 2870155c0b Fix js error 2015-10-12 10:45:13 +02:00
Samy Pessé 9ba1075f48 Add hook "config" to transform configuration before generation 2015-10-12 10:43:14 +02:00
Samy Pessé 4ae5b2e050 Merge pull request #959 from GitbookIO/improvements/ebooks
Improvements for ebooks
2015-10-08 20:58:57 +02:00
Samy Pessé 4369bd8f5e Fix copy of assets and js path in gulpfile 2015-10-06 14:23:10 +02:00
Samy Pessé 321b24a7b9 Don't copy assets for ebook to website bundle 2015-10-06 14:21:02 +02:00
Samy Pessé 22e0c1fb54 Fix css being used for pdf footer and header 2015-10-06 13:35:04 +02:00
Samy Pessé ba65e3c020 Adapt tests 2015-10-06 13:26:32 +02:00
Samy Pessé c19ab952e3 Only add page count on pdf/epub 2015-10-06 13:20:20 +02:00
Samy Pessé ecc29087b5 Fix summary page counter for epub low resolution 2015-10-06 13:10:51 +02:00
Samy Pessé 87e056de64 Change markdown -> markup in less mixins 2015-10-06 13:05:32 +02:00
Samy Pessé 761200529f Adapt glossary and summary for pdf/epub to new markup style 2015-10-06 13:03:52 +02:00
Samy Pessé 770351916e Cleaner markup css 2015-10-06 12:45:25 +02:00
Samy Pessé 4b7d957b47 Use black links in mobi files 2015-10-06 10:38:09 +02:00
Samy Pessé a1c03c18a5 Improve support of glossary page in pdf 2015-10-06 10:00:49 +02:00
Samy Pesse 5d376b054f Handle correctly rtl for toc in ebooks 2015-10-06 09:47:41 +02:00
Samy Pesse 277d13c2bb Center title for table of content 2015-10-06 09:47:25 +02:00
Samy Pesse 4a9389d80a Improve display of table of contents for ebooks 2015-10-06 09:47:15 +02:00
Samy Pesse 33593c13ae Inline css for footer/header templates 2015-10-06 09:47:04 +02:00
Samy Pesse eef82c18c2 Remove bottom border on h1 and h2 2015-10-06 09:45:31 +02:00
Samy Pessé 7363580095 Fix glossary page using a "section" instead of a "div" 2015-10-06 09:45:22 +02:00
Samy Pessé 23a46b0597 Remove margin on first header of a page (ebook)
Avoid breaking in code blocks
2015-10-06 09:45:06 +02:00
Samy Pessé 51c79f294c Add css to footer/header for pdf 2015-10-06 09:44:54 +02:00
Samy Pessé ce1e0e1873 Merge pull request #964 from GitbookIO/features/plugin_api
Better APIs for Plugins
2015-10-06 09:42:49 +02:00
Samy Pessé c2775b3b63 Export jQuery for plugins compatibility 2015-10-06 09:37:01 +02:00
Samy Pessé bcb224d1cb Add more node.js versions to travis-ci 2015-10-05 23:06:46 +02:00
Samy Pessé 8bc5f22866 Add search plugin to dependencies 2015-10-05 17:22:47 +02:00
Samy Pessé c3f2ef02c4 Adapt tests for new default plugins 2015-10-05 17:16:37 +02:00
Samy Pessé 08e2c90d9d Don't fail when can't write to localstorage 2015-10-05 17:11:55 +02:00
Samy Pessé d2bb2ba454 Remove style for search 2015-10-05 17:07:25 +02:00
Samy Pessé ba912318cd Tweak some details for browserify compatibility 2015-10-05 16:49:37 +02:00
Samy Pessé 3d1f057373 Switch to gulp/browserify 2015-10-05 16:47:19 +02:00
Samy Pessé 0679807517 Define specific action for toggling summary 2015-10-05 16:02:03 +02:00
Samy Pessé 7f0e4803e2 Start removing search and lunr from core 2015-10-05 15:55:39 +02:00
Samy Pessé fa76029a17 Adapt tests for new default plugins 2015-10-05 14:24:55 +02:00
Samy Pessé 376c68957f Remove sharing 2015-10-05 13:53:19 +02:00
Samy Pessé 222ec8d4b9 Correctly reset buttons when page changed 2015-10-05 12:13:54 +02:00
Samy Pessé 90715c1944 Remove fontsettings from core and add plugin as default 2015-10-05 12:07:19 +02:00
Samy Pessé 801e1b6059 Add api to extend toolbar 2015-10-05 12:07:02 +02:00
Samy Pessé 14bb659b75 Update lodash for client side code 2015-10-05 10:43:21 +02:00
Samy Pessé eab3c50288 Add sharing plugin as default 2015-10-05 10:32:43 +02:00
Samy Pessé 74396e7240 Add method book.formatString 2015-10-05 10:07:04 +02:00
Samy Pessé 6c2539e886 Move Book.init in another file 2015-10-05 09:54:40 +02:00
Samy Pessé aba25d8521 Add eslint instead of jshint 2015-10-05 09:54:28 +02:00
Samy Pessé f0c97756de Bump version to 2.4.3 2015-10-01 14:07:32 +02:00
Samy Pessé f14c57d4c2 Merge pull request #955 from mstade/patch-1
Change nunjucks dependency to v2.1.0
2015-10-01 12:03:21 +02:00
Marcus Stade b6f60cc8ad Change nunjucks dependency to v2.1.0
Looks like mozilla/nunjucks#504 was merged and released in v2.1.0, so this changes `package.json` to no longer depend on a specific commit. Incidentally, this also solves a problem where corporate firewalls blocks npm from pulling in straight from github repos.
2015-10-01 12:01:52 +02:00
Samy Pessé 170516d343 Add ukranian translation 2015-09-28 21:01:28 +02:00
Samy Pessé c931e91bef Fix #952: add configuration for index maximum size 2015-09-28 20:54:45 +02:00
Samy Pessé db9151ae36 Update gitbook-parsers@0.8.3 2015-09-28 20:40:02 +02:00
Samy Pessé f2d86b6d69 Add slack button in readme 2015-09-23 12:19:04 +02:00
Samy Pessé 534cdd091b Add link to slack community channel 2015-09-23 12:16:22 +02:00
Samy Pessé fdf4a48638 Bump version to 2.4.2 2015-09-22 23:30:42 +02:00
Samy Pessé 58a3c5634e Improve installation of plugins to not install default ones 2015-09-22 23:25:15 +02:00
Samy Pessé f0ddb6e89f Merge branch 'fix/inline_code_html' 2015-09-22 22:46:19 +02:00
Samy Pessé 2b408db7cb Update gitbook-plugin-highlight@1.0.3 2015-09-22 22:45:55 +02:00
Samy Pessé 4e4bd23e2b Handle html param from code block output 2015-09-22 22:41:13 +02:00
Samy Pessé 62d0eb606e Add test for inline code block with html tags 2015-09-22 22:36:35 +02:00
Samy Pessé 0e9beeae14 Fix #941: limit size of lunr index 2015-09-22 12:36:18 +02:00
Samy Pessé 5e4dbdee24 Disable auto code highlighting (language should be specified) 2015-09-21 16:19:42 +02:00
Samy Pessé 9435dae6cd Fix #939: don't check gitbook version for sub-books (checked for parent) 2015-09-21 09:41:29 +02:00
Samy Pessé 813210bf47 Throw correct error in configuration 2015-09-20 23:27:39 +02:00
Samy Pessé c372dfc544 Bump version to 2.4.1 2015-09-19 00:32:43 +02:00
Samy Pessé ac77200683 Fix disabling a default plugin 2015-09-19 00:31:32 +02:00
Samy Pessé f5afbc90a4 Add more tests for blocks args/kwargs 2015-09-17 11:21:55 +02:00
Samy Pessé b24760c819 Bump version to 2.4.0 2015-09-15 14:32:11 +02:00
Samy Pessé 6732957e42 Merge pull request #930 from GitbookIO/jshint
Add config for jshint and fix lint errors
2015-09-15 14:21:27 +02:00
Samy Pessé 1fd0006859 Lint all tests 2015-09-15 14:20:32 +02:00
Samy Pessé 5a205346e3 Jshint all files 2015-09-15 13:57:21 +02:00
Samy Pessé e193004659 Fix passing context to block functions
Add test for it
2015-09-15 13:36:02 +02:00
Samy Pessé fe3a9c33d0 Improve code style for book.js and index.js 2015-09-15 13:16:26 +02:00
Samy Pessé d83116b88f Add jshint configuration 2015-09-15 13:16:06 +02:00
Samy Pessé 5f56098ae7 Fix stupid error that passed tests because "context" was global 2015-09-15 12:38:13 +02:00
Samy Pessé 0f935f4372 Merge pull request #806 from aschempp/aria-roles
Aria roles for accessibility
2015-09-15 12:29:12 +02:00
Samy Pessé df5c5a8c01 Merge pull request #919 from gaearon/fix-cmd-click
Don't react when user wants to open a link in a new tab
2015-09-15 12:28:32 +02:00
Samy Pessé 57a0c3bad8 Merge pull request #929 from GitbookIO/feature/improve_resolve
Improve paths resolving for conrefs
2015-09-15 12:27:07 +02:00
Samy Pessé 2a52326a45 Improve conrefs to handle all absolute file paths correctly
Add test for it
2015-09-15 12:22:54 +02:00
Samy Pessé 87e4ee1eeb Handle absolute file correctly for conrefs
Add test for absolute file for conrefs
2015-09-15 11:48:18 +02:00
Samy Pessé 45833eea9a Add test for navigation
Update mocha and should
2015-09-15 11:31:50 +02:00
Samy Pessé baf10e9b15 Improve book.resolve to ensure file is in the book
Adapt tests to plugin-highlight
2015-09-15 11:09:08 +02:00
Samy Pessé 463a947df1 Change text for editor 2015-09-15 09:47:34 +02:00
Samy Pessé cceebb4fd9 Merge branch 'improve/template-blocks' 2015-09-15 09:37:43 +02:00
Samy Pessé afd5465a61 Merge pull request #928 from GitbookIO/feature/highlight_block
Code highlighting extended by plugins
2015-09-14 18:26:26 +02:00
Samy Pesse fe604733de Change name of highlight test plugin 2015-09-14 12:05:51 +02:00
Samy Pesse da22f9f39f Update css without highlight.js
Add highlight as default plugin to be loaded
2015-09-14 11:57:54 +02:00
Samy Pesse 284ebbf75d Add highlight as default plugin 2015-09-14 11:47:56 +02:00
Samy Pesse 2c08ccad87 Pass language as kwargs to code block
Improve tests for extending code highlighting
2015-09-14 11:41:01 +02:00
Samy Pesse fa4e234bab Add base test for extending code highlighting 2015-09-14 11:28:14 +02:00
Samy Pesse 35c4179ca1 Use block code for highlight pre/code
Cleanup correctly predefined blocks
2015-09-14 11:21:16 +02:00
Dan Abramov c14ba7ce34 Don't react when user wants to open a link in a new tab
Fixes #846
2015-09-12 21:31:40 +03:00
Samy Pesse 601ce3add3 Add default blocks (html and code) 2015-09-12 19:25:01 +02:00
Samy Pesse 08ff39fd0b Remove highlight.js dependency 2015-09-12 19:23:07 +02:00
Samy Pesse 82a6ee3875 Add test for replacing highlighting 2015-09-12 18:21:35 +02:00
Samy Pessé 3bf592f870 Bump version to 2.3.3 2015-09-10 11:26:15 +02:00
Samy Pessé 241e205717 Merge pull request #912 from GitbookIO/fix/538
Fix 538: duplicate entries without paths are ignored
2015-09-10 09:59:45 +02:00
Samy Pessé fb2720ea8d Update gitbook-parsers@0.8.2 2015-09-10 09:57:04 +02:00
Samy Pessé 14853befda Add test for init with deep summary 2015-09-10 09:56:18 +02:00
Samy Pessé e7f2803d11 Bump version to 2.3.2 2015-09-09 09:30:53 +02:00
Samy Pessé 320015dd8f Fix #910: fix stupid error with semver api 2015-09-09 09:27:08 +02:00
Samy Pessé 471c124a98 Merge pull request #908 from GitbookIO/fix/asciidoc_blocks
Fix blocks in asciidoc
2015-09-09 00:01:43 +02:00
Samy Pesse aa44a109c6 Use position indicator that doesn't conflict with asciidoc 2015-09-08 23:57:40 +02:00
Samy Pesse 41e5ca8422 Add test for blocks without parsing 2015-09-08 23:55:30 +02:00
Samy Pessé 53af8b2bb6 Bump version to 2.3.1 2015-09-08 16:33:22 +02:00
Samy Pessé bd885b135f Merge pull request #904 from kuaipao/fix-mobi-font-color
use black font on mobi
2015-09-08 09:16:43 +02:00
kuaipao 62a6dde81a use black font on mobi 2015-09-08 04:02:48 +08:00
Samy Pesse 14b72b344f Log modified file in watcher 2015-09-06 21:13:18 +02:00
Samy Pesse ac03668063 Update chokidar@1.0.5 2015-09-06 21:11:49 +02:00
Samy Pesse 2512e176c9 Fix #893: korean iso code is "ko" not "kr" 2015-09-06 21:01:39 +02:00
Samy Pesse b613393866 Update highlight.js@8.8.0 2015-09-06 19:04:09 +02:00
Samy Pessé 607a6e95de Update gitbook-parsers@0.8.1 2015-09-05 19:00:42 +02:00
Samy Pessé 871f574ff7 Fix #761: fix syntax highlighting for asciidoc 2015-09-05 17:28:01 +02:00
Samy Pessé 377e470b15 Add warning for file outside spine 2015-09-04 19:12:27 +02:00
Samy Pessé e0a3f0cea5 Add warning for too strict gitbook version 2015-09-04 18:58:16 +02:00
Samy Pessé 66727b2736 Update gitbook-parsers@0.8.0 2015-09-04 18:33:45 +02:00
Samy Pessé 8215ad977f Merge pull request #898 from deminoth/master
Korean translation fixed
2015-09-04 08:36:19 +02:00
SangYeob Bono Yu a611dffbdf Add my name 2015-09-04 10:29:59 +09:00
SangYeob Bono Yu 39f378d8cf Korean translation fixed 2015-09-04 10:22:24 +09:00
Samy Pessé f00da58153 Update appveyor button 2015-09-01 17:52:27 +02:00
Samy Pessé 09b038b16d Bump version to 2.3.0 2015-09-01 17:44:53 +02:00
Samy Pessé cf601d97ad Improve error handling for failed image download 2015-09-01 17:38:33 +02:00
Samy Pessé 80edad53d4 Update nunjucks to fix raw and loader 2015-09-01 17:25:43 +02:00
Samy Pessé a972b32769 Update nunjucks@2.0.0 2015-08-28 08:45:28 +02:00
Samy Pessé efcaae3e60 Add author for hebrew 2015-08-27 19:07:31 +02:00
Samy Pessé e0ee591638 Merge pull request #877 from a-moses/hebrew
hebrew support theme
2015-08-27 19:06:26 +02:00
Samy Pessé 310a6d909f Add method 'get' to config object (helper for plugins) 2015-08-27 15:26:12 +02:00
Samy Pessé cefd8fc50f Don't fail if hook returns nothing for "page" and "page:before" 2015-08-27 15:04:28 +02:00
Samy Pessé a4422593f2 Add back page:before and page as non-deprecated 2015-08-26 11:16:02 +02:00
Samy Pessé e2c5d22756 Merge pull request #844 from xcv58/master
Fix #843 ignore _book in watch.js
2015-08-26 11:05:43 +02:00
Samy Pessé 84385d9dc3 Merge pull request #881 from mortonfox/patch-1
Fix Plugins link.
2015-08-26 11:01:28 +02:00
Morton Fox 6cfa4c8ab7 Fix Plugins link. 2015-08-25 23:35:15 -04:00
a-moses c76ccc53e1 Update he.json 2015-08-23 09:59:14 +03:00
a-moses d48eafb1a2 hebrew support theme
full Hebrew support for GITBOOK (with rtl )

* Sans and Serif may still in original name fonts
2015-08-23 09:53:25 +03:00
Aaron O'Mullan 302d9b4b91 Merge pull request #849 from GitbookIO/improve/remove-webfonts
Use system fonts instead of webfonts
2015-08-13 19:19:35 +02:00
Samy Pessé a091a7f68b Update gitbook-parsers@0.7.7 2015-08-09 15:45:04 +02:00
Aaron O'Mullan 53621f6de3 Use system fonts instead of webfonts 2015-08-08 17:35:05 +02:00
Samy Pessé 288b965db3 Merge pull request #847 from GitbookIO/fix/flicker
Improve header merge on page change
2015-08-07 16:55:42 +02:00
Aaron O'Mullan 578c9dcfc6 Improve header merge on page change
Prevents flickering (style reset)

Fixes #782, #838, #840
2015-08-07 16:46:23 +02:00
xcv58 64de17b248 ignore _book in watch.js 2015-08-04 00:50:31 -04:00
Aaron O'Mullan d699dff872 Use Book.resolve when possible
For added consistency
2015-07-31 15:08:56 +02:00
Samy Pesse 501843d624 Bump version to 2.2.0 2015-07-28 15:28:38 -07:00
Samy Pesse 508ce4283e Fix #819: codes must always be ltr 2015-07-28 15:25:12 -07:00
Samy Pessé 4aa8e66549 Merge pull request #813 from MrMaksimize/pdf-options
Allowing for custom chapter-mark and page-break in PDF.
2015-07-01 18:00:31 -04:00
Maksim Pecherskiy 917a6f70d8 Allowing for custom chapter-mark and page-break in PDF. 2015-06-30 19:48:51 -07:00
Samy Pesse 2f5e53da55 Update highlight.js@8.6.0 2015-06-29 10:02:35 -04:00
Samy Pesse c3cdefc90a Simpler template for summary 2015-06-29 09:58:23 -04:00
Samy Pesse 9c580e4989 Fix #802: make book.json accessible as "config." in templating 2015-06-19 16:28:46 +02:00
Andreas Schempp dbc75f7352 Add role and html5 markup for the main navigation 2015-06-18 20:29:11 +02:00
Andreas Schempp db841a8578 Added basic ARIA roles for screenreaders 2015-06-18 20:23:12 +02:00
Samy Pessé 50c902c4e4 Merge pull request #805 from GitbookIO/fix/804
Fix #804
2015-06-18 11:16:32 +02:00
Samy Pesse 84b6e0bde6 Add test for kwargs 2015-06-18 11:15:44 +02:00
Samy Pesse abc29c3fba Fix #804: correctly extract kwargs from blocks 2015-06-18 11:11:47 +02:00
Samy Pesse 8356c534f5 Add failing tests for block's arguments 2015-06-18 11:09:02 +02:00
Samy Pessé 78ff2687b4 Merge pull request #797 from nghong/vi-locale
Adding Vietnamese locale support
2015-06-13 11:15:00 +02:00
Hong Nguyen 9b6586fb36 Add translator name to AUTHORS.md 2015-06-13 16:13:34 +07:00
Hong Nguyen ea133219d0 Minor fix 2015-06-13 16:08:21 +07:00
Hong Nguyen c9b5d81a3c Add Vietnamese locale support 2015-06-13 15:42:49 +07:00
Samy Pessé d895c63211 Bump version to 2.1.0 2015-06-02 14:52:11 +02:00
Samy Pessé 8c86da67ca Update gitbook-parsers@0.7.6 2015-06-02 14:47:21 +02:00
Samy Pessé a9a230dfc3 Merge pull request #781 from GitbookIO/fix/775
Fix #775: add optional print.css style
2015-06-02 11:00:22 +02:00
Samy Pessé 6d53e52771 Handle empty string for styles configuration 2015-06-02 11:00:15 +02:00
Samy Pessé 52e10b7cfe Remove default print.css when styles/print.css is present 2015-06-02 10:23:31 +02:00
Samy Pessé addac85696 Add test for custom print style 2015-06-02 10:18:44 +02:00
Samy Pessé 13fb949d68 Merge pull request #774 from wilhelmmatilainen/patch-1
Styling should go to <head>, not to <body>
2015-05-30 18:11:15 +02:00
Wilhelm f1b593cfbd Styling should go to <head>, not to <body>
https://developers.google.com/speed/pagespeed/module/filter-css-to-head
2015-05-29 15:42:40 +03:00
Samy Pesse f998e2dec9 Bump version to 2.0.4 2015-05-28 18:07:20 +02:00
Samy Pesse 2c0bd53a91 Fix i18n used in multilingual book 2015-05-28 17:06:09 +02:00
Samy Pesse 6dd7f6162f Add title to languages chooser
Related to #757
2015-05-28 16:14:03 +02:00
Samy Pesse 475b0bb2b3 Adapt to nunjucks 1.3.x 2015-05-28 15:59:14 +02:00
Samy Pesse e6343935e3 Update nunjucks to fix raw tags 2015-05-28 15:50:46 +02:00
Samy Pessé 946883fd4c Merge pull request #772 from GitbookIO/feature/glossary_order
Fix #768: sort glossary, start with longest matchs
2015-05-28 15:21:03 +02:00
Samy Pessé b1b7e3148b Merge pull request #743 from chudaol/master
Added vk sharing button.
2015-05-28 14:54:03 +02:00
Samy Pesse 32203f6438 Sort glossary before applying it on pages 2015-05-28 14:49:53 +02:00
Samy Pesse f2d3c5d2ed Add test for #768 2015-05-28 14:38:21 +02:00
Samy Pessé 7e2f0ed4bc Merge pull request #758 from aschempp/hotfix/x-ua-compatible
Fix the X-UA-Compatible meta tag
2015-05-28 14:18:19 +02:00
Samy Pessé a877acf905 Merge pull request #759 from aschempp/hotfix/stylesheets
Move style sheets to the <head> section
2015-05-28 14:17:39 +02:00
Samy Pesse ac756ddf7e Bump version to 2.0.3 2015-05-27 21:11:58 +02:00
Samy Pesse 36e2236e6b Fix #765: in init handle correctly empty entries
Add tests for it, fix #769
2015-05-27 21:05:36 +02:00
Samy Pesse 72df665520 Update gitbook-parsers@0.7.5 2015-05-27 19:11:50 +02:00
Samy Pessé 07785528a5 Merge pull request #767 from wilhelmmatilainen/patch-1
Don't create panic by telling about false overwrite
2015-05-27 13:17:05 +02:00
Wilhelm bb579dd581 Don't create panic by telling about false overwrite 2015-05-27 14:13:02 +03:00
Samy Pessé a7d3064340 Change license to valid SPDX code 2015-05-26 16:10:11 +02:00
Andreas Schempp 1a60778248 Move style sheets to the <head> section
see https://github.com/GitbookIO/gitbook/issues/756
2015-05-23 09:14:26 +02:00
Andreas Schempp cda4bb5bda Fix the X-UA-Compatible meta tag
see https://github.com/GitbookIO/gitbook/issues/755
2015-05-23 09:06:58 +02:00
Olga Filipova 7543781046 Added vk sharing button. 2015-05-12 22:30:09 +02:00
Samy Pessé 82f3ffad06 Merge pull request #730 from creynders/patch-1
Fix typo in warning in `lib/plugin`
2015-05-04 14:47:56 +02:00
creynders dc4d2a1731 Fix typo in warning in lib/plugin 2015-05-04 13:16:47 +02:00
Samy Pessé 2523925915 Bump version to 2.0.2 2015-05-02 12:39:05 +02:00
Samy Pesse d5bbd8475c Fix #721: use links.join instead of path.join for links in page 2015-04-23 12:58:24 -05:00
Samy Pesse 54d195268a Add test relative links (related to #721) 2015-04-23 12:05:04 -05:00
Samy Pesse a0deb9509f Merge branch 'awrelll-master' 2015-04-20 07:53:16 -05:00
Samy Pesse b0b1433594 Fix authors list merge 2015-04-20 07:52:12 -05:00
Samy Pessé 17a2c0a37c Merge pull request #706 from savikko/patch-1
Added Finnish author
2015-04-14 18:56:31 -05:00
Samy Pessé fd68ea1cc2 Merge pull request #705 from savikko/master
Added Finnish
2015-04-14 18:56:21 -05:00
Tommi Savikko 784874c776 Added Finnish author 2015-04-14 22:39:23 +03:00
Thomas Clayton f45c6d3466 Added Finnish 2015-04-14 21:50:46 +03:00
Samy Pessé 98af70902f Merge pull request #701 from anthonyfok/patch-1
Fix typo in lib/book.js: lanuages → languages
2015-04-10 20:50:35 -05:00
Anthony Fok 41a67b5c4c Fix typo in lib/book.js: lanuages → languages 2015-04-10 07:41:12 -06:00
Samy Pessé 83ee903af4 Merge pull request #700 from paulmillr/master
Switch from gaze to chokidar.
2015-04-10 10:39:13 +02:00
Samy Pessé e591b0e485 Merge pull request #696 from sindresorhus/escaperegex-module
use the `escape-string-regexp` module
2015-04-10 10:37:53 +02:00
Paul Miller bcc9a34742 Switch from gaze to chokidar. 2015-04-10 06:09:04 +03:00
Sindre Sorhus 6b56c7de7f use the escape-string-regexp module
no point in hardcoding this.

https://github.com/sindresorhus/escape-string-regexp
2015-04-08 18:24:26 +07:00
Iancu Aurel 7b42719699 korean and japanese added 2015-04-07 17:34:40 +03:00
awrelll 64b8343f67 korean support added 2015-04-07 17:32:33 +03:00
awrelll fcc5089fa6 japan support added 2015-04-07 17:26:45 +03:00
Samy Pessé 334f782aa8 Merge pull request #693 from awrelll/patch-1
Romanian author added
2015-04-07 16:21:56 +02:00
Samy Pessé 1776f2bf77 Merge pull request #691 from awrelll/master
support for romanian language
2015-04-07 16:21:34 +02:00
Iancu Aurel e259412f79 Romanian author added 2015-04-07 17:21:05 +03:00
awrelll 999a02f110 support for romanian language 2015-04-07 17:12:41 +03:00
Samy Pessé 604d0fba65 Update nunjucks@1.3.0 2015-04-03 22:31:55 +02:00
Samy Pessé 0e8f7b870b Bump version to 2.0.1 2015-04-02 19:41:14 +02:00
Samy Pessé 1eebc9a46e Normalize structure parsing error 2015-04-02 19:21:39 +02:00
Samy Pessé 0a94c80c44 Normalize template errors 2015-04-02 18:59:56 +02:00
Samy Pessé c70bb2fbd8 Update gitbook-parsers@0.7.4 2015-04-02 18:31:49 +02:00
Samy Pessé 12c06b384f Don't fail if config doesn't exists 2015-04-02 09:43:48 +02:00
Samy Pessé 82a58e7ac3 Invalidate configuration cache when reloading 2015-04-02 09:38:57 +02:00
Samy Pessé dcb56ef433 Merge pull request #683 from GitbookIO/fix/i18n
Fix i18n in json format
2015-04-01 22:23:23 +02:00
Samy Pessé 8da91de514 Don't update translations 2015-04-01 22:21:13 +02:00
Samy Pessé 4b20685562 Use i18n node module for template translation 2015-04-01 22:17:12 +02:00
Samy Pessé fff7c5cc3a Add back support for options.originalInput
Related to rtCamp/gitbook-plugin-edit-link#2
2015-03-30 16:50:26 +02:00
Samy Pessé 3065742b73 Separate book.contentLink and book.contentPath 2015-03-28 15:54:34 +01:00
Samy Pessé ffd69ad1f2 Add test for summary paths
Related to #674
2015-03-28 15:28:28 +01:00
Samy Pessé 9004011479 Merge pull request #673 from lszeremeta/master
Polish (pl) added in theme/i18n
2015-03-28 14:54:50 +01:00
Łukasz Szeremeta 1046bb4133 Add @lszeremeta to translators 2015-03-28 14:48:16 +01:00
Łukasz Szeremeta 5578505213 Polish (pl) added in theme/i18n 2015-03-27 22:03:28 +01:00
Samy Pessé a61f56662a Bump version to 2.0.0 2015-03-25 10:43:58 +01:00
Samy Pessé f42e48be03 Fix scroll reset on small resolutions (mobile & tablet) 2015-03-24 23:59:03 +01:00
Samy Pessé f640e101ba Fix scroling position when preparing page 2015-03-24 23:52:41 +01:00
Samy Pessé b7da276ae0 Fix title for introduction (with i18n) 2015-03-24 23:49:12 +01:00
Samy Pessé bf7c0989f5 Update gitbook-parsers@0.7.2 2015-03-24 23:35:17 +01:00
Samy Pessé 65fdbe7f55 Simplify examples of commands 2015-03-24 23:19:00 +01:00
Samy Pessé c9af209a93 Merge pull request #667 from GitbookIO/better-testing
Better Unit Tests
2015-03-24 23:14:17 +01:00
Samy Pessé 48ab44a776 Add tests for conrefs 2015-03-24 18:22:44 +01:00
Samy Pessé b2e684af8f Add test for templating context 2015-03-24 17:34:47 +01:00
Samy Pessé b38a2c11a4 Add tests for plugins 2015-03-24 17:31:15 +01:00
Samy Pessé c31acef47a Add tests for images in ebook 2015-03-24 16:26:19 +01:00
Samy Pessé e9a573e18a Add test for default description from readme 2015-03-24 14:57:29 +01:00
Samy Pessé c07ddc77f7 Add tests for links 2015-03-24 14:52:24 +01:00
Samy Pessé 303fc992d4 Add test for git url parsing 2015-03-24 14:44:07 +01:00
Samy Pessé 4b7797f61b Add basic tests for multilingual books 2015-03-24 14:16:03 +01:00
Samy Pessé f775d41933 Add base tests for ebook generation 2015-03-24 13:52:29 +01:00
Samy Pessé 7722e7bdfa Update gitbook-parsers@0.7.1 2015-03-24 13:33:56 +01:00
Samy Pessé 346c05f0de Add tests for configuration parsing 2015-03-24 13:24:20 +01:00
Samy Pessé 73c69923b3 Add test for summary parsing
Update gitbook-parsers
2015-03-24 13:11:29 +01:00
Samy Pessé afbca4bdf5 Improve tests for glossary 2015-03-24 11:54:03 +01:00
Samy Pessé b61371942b Add test for glossary replacements 2015-03-24 11:27:37 +01:00
Samy Pessé 61c07e8876 Add test for glossary parsing 2015-03-24 10:24:49 +01:00
Samy Pessé d317741144 Add basic test for multilingual book 2015-03-24 09:36:51 +01:00
Samy Pessé 275739a778 Add basic test for website generation 2015-03-24 08:49:39 +01:00
Samy Pessé cb3a43ed8a Add string representation for books 2015-03-24 08:49:22 +01:00
Samy Pessé ec8d1d8fc9 Improve test for json format 2015-03-23 23:48:46 +01:00
Samy Pessé 868a3186dd Add assertion to test that a file exists 2015-03-23 23:32:07 +01:00
Samy Pessé 17b546181c Fix cleanup after tests 2015-03-23 23:23:25 +01:00
Samy Pessé 2d1aa15af8 New cleaner helper for testing 2015-03-23 23:18:15 +01:00
Samy Pessé 63ee94ff89 Ignore codeblocks when replacing glossary terms 2015-03-23 11:00:50 +01:00
Samy Pessé 7d9dc08a38 Highlight codeblocks in gitbook instead than the parsers 2015-03-23 10:31:48 +01:00
Samy Pessé a836bdedb4 Bump version to 2.0.0-beta.5 2015-03-17 11:23:35 +01:00
Samy Pessé 15ebae8cb1 Fix #641: fix progress order in json format 2015-03-17 11:22:56 +01:00
Samy Pessé 315556310f Bump version to 2.0.0-beta.4 2015-03-17 10:48:25 +01:00
Samy Pessé 9c0b26304b Merge branch master 2015-03-17 10:46:17 +01:00
Samy Pessé acdaea9f6c Fix #649: add option "author" in book.json to set meta author in html 2015-03-17 10:38:56 +01:00
Samy Pessé e481deb5bb Merge pull request #650 from wcandillon/patch-2
Update default generator
2015-03-14 16:00:09 -07:00
William Candillon 6d3ac6074c 💄 Update default generator 2015-03-14 15:45:15 -07:00
Samy Pessé 5e611bde48 Merge pull request #648 from wcandillon/patch-1
Bump to lodash 3.5.0
2015-03-14 15:25:39 -07:00
Samy Pessé 9448562156 Add editorconfig and normalize indent 2015-03-14 23:23:28 +01:00
William Candillon e7e8fe4d08 ⬆️ Bump to lodash 3.5.0 2015-03-14 11:35:28 -07:00
Samy Pessé 8320484b88 Fix #647: Fix links normalization (content and hash) 2015-03-13 23:59:37 +01:00
Samy Pessé 0e243e6f23 Bump version to 2.0.0-beta.3 2015-03-12 21:23:25 +01:00
Samy Pessé 5cd25b0d21 Update gitbook-parsers@0.5.4 2015-03-12 21:20:51 +01:00
Samy Pessé 3218ee7455 Fix tests to adapt to changes in parsers 2015-03-11 22:05:58 +01:00
Samy Pessé 0552007b8a Bump version to 2.0.0-beta.2 2015-03-11 22:03:54 +01:00
Samy Pessé 50bc89d9d9 Fix define of introduction from summary 2015-03-11 22:02:46 +01:00
Samy Pessé 743a88f53a Fix typo in bin message 2015-03-11 11:40:56 +01:00
Samy Pessé ee92c6dd99 Add changelog for 2.0.0-beta.1 2015-03-11 11:23:48 +01:00
Samy Pessé b6c54c17d1 Bump version to 2.0.0-beta.1 2015-03-11 11:17:56 +01:00
Samy Pessé 992ef1ab74 Use latest commit from nunjucks windows fix branch 2015-03-11 11:17:43 +01:00
Samy Pessé 960848ba34 Ensure inline svgs have xml header 2015-03-11 09:38:18 +01:00
Samy Pessé d9aca7a9df Fix #639: update nunjucks to support windows 2015-03-11 00:57:07 +01:00
Samy Pessé 05a0de2d86 Remove require of old dependency "shell-escape" 2015-03-11 00:50:48 +01:00
Samy Pessé 19e4f498cf Fix inline svg extraction on windows 2015-03-10 16:45:22 -07:00
Samy Pessé 3055139297 Fix run of svgexport on windows 2015-03-10 16:31:43 -07:00
Samy Pessé 3d6b099dea Fix links normalization on windows 2015-03-10 22:44:54 +01:00
Samy Pessé dd970e33b8 Remove --no-exit option from mocha tests runner 2015-03-10 21:31:43 +01:00
Samy Pessé 59ba479465 Test option --no-exit for mocha tests 2015-03-10 16:14:04 +01:00
Samy Pessé 54c9ecf3c2 Use mocha from node_modules/.bin 2015-03-10 15:44:39 +01:00
Samy Pessé 8308ae69a2 Remove command export from "npm test" 2015-03-10 15:01:51 +01:00
Samy Pessé bd6c3287ed Add badge for windows testing 2015-03-10 14:58:23 +01:00
Samy Pessé 24fc36deb1 Add appveyor.yml for windows testing
Related to #639
2015-03-10 14:52:09 +01:00
Samy Pessé 2f44b61cec Merge pull request #638 from wapmorgan/patch-1
Update README.md
2015-03-09 21:13:29 +01:00
wapmorgan 45ee503db1 Update README.md
Fix link
2015-03-10 00:12:53 +04:00
Samy Pessé dc826da99b Update README.md 2015-03-09 10:58:11 +01:00
Samy Pessé 3ea659d582 Improve readme presentation 2015-03-09 10:57:23 +01:00
Samy Pessé 34fc2831e0 Merge branch 'version/2.0' 2015-03-09 10:43:12 +01:00
Samy Pessé 1bf68a5aa0 Merge branch 'master' into version/2.0
Conflicts:
	README.md
2015-03-09 10:42:42 +01:00
Samy Pessé d72c397f23 Update gitbook-parsers@0.5.2 2015-03-08 23:09:50 +01:00
Samy Pessé 2c69525148 Add GitBook as book producer in ebook-convert 2015-03-08 22:53:18 +01:00
Samy Pessé ee3a0ba801 Fix #633: update markdown parser to fix codeblocks
Sort glossary and fix #634
2015-03-08 22:53:18 +01:00
Samy Pessé 7a4179a2a2 Merge pull request #631 from MHM5000/version/2.0
[i18n] - fa: Persian/Farsi
2015-03-07 18:48:05 +01:00
Mohammad Hossein Mojtahedi 1d0083c5f4 added @mhm5000 in translators 2015-03-07 18:22:40 +03:30
Mohammad Hossein Mojtahedi 33a6111a30 [i18n] - fa: Persian/Farsi 2015-03-07 16:48:44 +03:30
Samy Pessé a5d7a87e31 Enable rtl in ebooks 2015-03-06 22:45:53 +01:00
Samy Pessé c7f7c5b5ab Base translation for Arabic (with rtl support) 2015-03-06 22:32:45 +01:00
Samy Pessé 55a7b99b4d Fix #227: Add base rtl support for website 2015-03-06 22:32:25 +01:00
Samy Pessé 8bfba604b3 Update gitbook-parsers@0.5.0 and include page.prepare
Fix #625: escape code blocks in markdown
2015-03-06 16:54:46 +01:00
Samy Pessé 2a5fa1c5fb Fix #629: add generator name in template context 2015-03-06 14:34:55 +01:00
Samy Pessé a3e95feb26 Add instructions to use version from git 2015-03-06 13:58:23 +01:00
Samy Pessé 145b00f590 Fix #628: preserve pure anchor links and hash in relative links 2015-03-06 10:25:06 +01:00
Samy Pessé 5f2785f0a8 Escape svgexport args
Fixes shakiba/svgexport#5 and #624
2015-03-05 10:06:45 +01:00
Samy Pessé 412529c548 Merge pull request #621 from nasirkhan/version/2.0
Bengali (bn) added in theme/i18n
2015-02-27 17:48:07 +01:00
nasirkhan 547ec6ade8 bn language added 2015-02-27 22:29:10 +06:00
nasirkhan eac513cfa3 Merge remote-tracking branch 'upstream/version/2.0' into version/2.0 2015-02-27 22:16:11 +06:00
Aaron O'Mullan 5ec8a1f18c Add en.json
Fixes #620
2015-02-27 16:02:31 +01:00
Samy Pessé c923a7e01a Fix transformation of README.md links in index.html 2015-02-26 01:14:27 +01:00
Samy Pessé 366e6ed105 Bump version to 2.0.0-alpha.9 2015-02-24 13:57:20 +01:00
Samy Pessé 52078eb666 Use latest nunjucks from mozilla/nunjucks 2015-02-24 13:54:08 +01:00
Samy Pessé d9ddbff443 Fix links in sidebar 2015-02-24 13:51:10 +01:00
Samy Pessé 01b160f9a1 Fix normalization of html link (README to index) 2015-02-21 13:40:38 +01:00
Samy Pessé 23fcb817a4 Fix html snippets escaping 2015-02-20 20:52:07 +01:00
Samy Pessé f531a3f984 Update nunjucks-autoescape 2015-02-20 12:24:33 +01:00
Samy Pessé c777023e9f Add introduction to changelog 2015-02-17 14:18:49 +01:00
Samy Pessé 62c99759c1 Bump version to 2.0.0-alpha.8 2015-02-14 16:43:19 +01:00
Samy Pessé 6951c21d19 Update gitbook-parsers@0.4.1 2015-02-14 16:26:16 +01:00
Samy Pessé 3a8289483e Improve language detection from book.json 2015-02-14 15:34:19 +01:00
Samy Pessé 4079de9587 Fix #608: fix chapter name for glossary 2015-02-14 15:29:41 +01:00
Samy Pessé b86d171082 Escape description in title attr of glossary link
Related to #609
2015-02-14 11:53:30 +01:00
Samy Pessé 959b272e65 Fix #609: don't escape html in glossary 2015-02-14 11:52:33 +01:00
Samy Pessé 684440e2d1 Fix generation of multilingual book as ebook 2015-02-14 11:49:42 +01:00
Samy Pessé 4740cd3b06 Merge pull request #605 from GitbookIO/update/lodash
Update lodash to 3.x.x
2015-02-13 08:18:45 +01:00
Samy Pessé b3131d99d2 Update lodash@3.2.0 2015-02-13 08:16:28 +01:00
Samy Pessé b0fd2a67ea Fix test with post in blocks 2015-02-13 08:09:28 +01:00
Samy Pessé 7c83869869 Limit concurrent blocks processed 2015-02-13 00:04:27 +01:00
Samy Pessé 57d5c23eaf Accept post function from block to post process content 2015-02-12 23:36:22 +01:00
Samy Pessé 8d92b74e61 Fix page normalization with empty links or images 2015-02-12 18:43:06 +01:00
Samy Pessé 4e2cda99cc Complete changelog for 2.0.0-alpha.7 2015-02-12 16:40:50 +01:00
Samy Pessé dd250e0339 Bump version to 2.0.0-alpha.7 2015-02-12 16:30:55 +01:00
Samy Pessé 741b158631 Fix #596: fix display of glossary in ebook format 2015-02-12 16:27:52 +01:00
Samy Pessé 843889303e Improve pdf by adding default header and footer 2015-02-12 12:47:08 +01:00
Samy Pessé 4ad2b040b4 Always generate README.json with langs index
remove method langsIndex form generators (moved to finish)
2015-02-12 12:18:52 +01:00
Samy Pessé f5916b5c59 Remove log from test 2015-02-12 11:44:44 +01:00
Samy Pessé d9da4e9a08 Fix GitbookIO/plugin-youtube#2: hash remote image for local path 2015-02-12 11:40:17 +01:00
Samy Pessé 1d0f6370ad Fix default language to english 2015-02-12 08:19:38 +01:00
Samy Pessé 12a7a4c4cf Fix test for lodash 3.1.0 (from git) 2015-02-11 17:53:46 +01:00
Samy Pessé e4127d961e Update to gitbook-parsers@0.4.0 2015-02-09 18:10:46 +01:00
Samy Pessé 8e97655040 Complete zh translations 2015-02-09 11:38:12 +01:00
Samy Pessé 9b61b87873 Add Serif and Sans to all translations 2015-02-09 11:14:47 +01:00
Samy Pessé 4a99e37b2f Fix spaces in zh-tw translation 2015-02-09 11:12:07 +01:00
Samy Pessé 752b5e9b7c Merge pull request #602 from howiehu/version/2.0
add zh-tw (Traditional Chinese) i18n file
2015-02-09 11:09:04 +01:00
Samy Pessé b318f2fe94 Improve i18n to support locale normalization 2015-02-09 11:08:46 +01:00
Hao Hu 01c46030b6 Add @howiehu to authors and normalize zh-tw translation 2015-02-09 17:59:54 +08:00
Hao Hu 9803b05d8a add zh-tw (Traditional Chinese) i18n file 2015-02-09 17:56:25 +08:00
Samy Pessé 1337858fe6 Add @howiehu to authors and normalize zh translation 2015-02-09 10:16:37 +01:00
Aaron O'Mullan 925b9e88ad Merge pull request #601 from howiehu/version/2.0
Add Simplifiled Chinese (zh-cn) i18n file.
2015-02-09 09:58:36 +01:00
Hao Hu 7305011a8b add zh-cn (Simplifiled Chinese) i18n file 2015-02-09 16:53:30 +08:00
Samy Pessé 489f23f74e Fix #595: calcul link to glossary as an absolute path 2015-02-07 20:39:15 +01:00
Samy Pessé 370799ac55 Add test for #595: glossary links in subpages 2015-02-07 20:35:24 +01:00
Samy Pessé 4a9adb9440 Bump version to 2.0.0-alpha.6 2015-02-06 19:42:55 +01:00
Samy Pessé d8898b7a1f Add changelog for version 2.0.0-alpha.* 2015-02-06 15:54:40 +01:00
Samy Pessé bb7e081a37 Fix #588: Fix replacement of glossary terms by links 2015-02-06 15:28:53 +01:00
Samy Pessé c3ffa5e0ef Add test for glossary replacement #588 2015-02-06 15:07:01 +01:00
Samy Pessé 724bc2b59c Add capital to german translation of share links 2015-02-06 15:00:13 +01:00
Samy Pessé 178d2e2a48 Add @RyanOM as spanish translator 2015-02-06 14:35:23 +01:00
Samy Pessé 4d710c129c Merge pull request #590 from RyanOM/patch-2
Created es.json
2015-02-06 14:34:25 +01:00
RyanOM e4dbf62c0f Create es.json 2015-02-06 11:33:26 -02:00
Samy Pessé b0cd23fd34 Add @RyanOM as a translator 2015-02-06 14:32:20 +01:00
Samy Pessé af5764bc3b Merge pull request #589 from RyanOM/patch-1
Create pt.json
2015-02-06 14:29:31 +01:00
RyanOM 6309da1214 Create pt.json 2015-02-06 11:21:22 -02:00
Samy Pessé 38c9bfa357 Fix dom-serializer dependency 2015-02-05 21:10:17 +01:00
Samy Pessé f194cb513c Merge pull request #586 from ludovicofischer/version/2.0
Use tiny-lr instead of old unmaintained fork.
2015-02-05 20:50:02 +01:00
Ludovico Fischer 03ff892727 Use tiny-lr instead of old unmaintained fork. 2015-02-05 19:43:29 +01:00
Samy Pessé 8cc0f64f54 Handle SVG correctly in page normalization
Related to mathjax/MathJax-node#65
2015-02-05 17:36:44 +01:00
Samy Pessé 532e8b0388 Bump version to 2.0.0-alpha.5 2015-02-05 13:56:52 +01:00
Samy Pessé 35b3d50012 Add "finish:before" to the list of valid hooks 2015-02-05 13:56:43 +01:00
Samy Pessé 72ff9996ce Update fs-extra to fix fs.copy issue 2015-02-05 13:51:53 +01:00
Samy Pessé 0759c4dd78 Bump version to 2.0.0-alpha.4 2015-02-04 20:49:09 +01:00
Samy Pessé 82a1a151e4 Correctly copy cover for sub books 2015-02-04 20:29:49 +01:00
Samy Pessé ff6e8387fb Bump version to 2.0.0-alpha.3 2015-02-04 18:31:26 +01:00
Samy Pessé f71601e8d3 Fix generation of multilingual books as ebook 2015-02-04 18:31:07 +01:00
Samy Pessé 234a37726f Improve logs for images and ebook copy 2015-02-04 16:54:02 +01:00
Samy Pessé 65a7979874 Load plugins from the book in priority 2015-02-04 15:25:40 +01:00
Samy Pessé 6a00bf0fc0 Remove plugin list 2015-02-04 11:54:52 +01:00
Samy Pessé 853f3d6482 Add translators on AUTHORS.md
@gbonanome, @kmelve, @AndreyAkinshin, @winniehell
2015-02-04 11:52:00 +01:00
Samy Pessé 27de7cd914 Merge pull request #582 from kmelve/version/2.0
Added Norwegian translation
2015-02-04 11:42:46 +01:00
Knut Melvær 2318cae1e6 Added Norwegian translation 2015-02-04 11:39:40 +01:00
Samy Pessé cb313c0fab Bump version to 2.0.0-alpha.2 2015-02-04 10:02:51 +01:00
Samy Pessé 4f25056017 Update gitbook-parsers@0.3.1 2015-02-03 14:34:20 +01:00
Samy Pessé 5baebb8754 Set "info" as default log level 2015-02-03 10:53:33 +01:00
Samy Pessé 1eea994e73 Fix init command 2015-02-03 10:52:39 +01:00
Samy Pessé 8a597ff3f1 Fix installation instruction 2015-02-03 10:40:22 +01:00
Samy Pessé 42fd7b12c0 Bump version to 2.0.0-alpha.1 2015-02-03 10:37:25 +01:00
Samy Pessé fd78a06b11 Add message in gitbook command line 2015-02-03 10:37:21 +01:00
Samy Pessé 80efc8e086 Accept alpha and beta version of plugins 2015-02-02 22:07:40 +01:00
Samy Pessé c0dcb886ef Improve install command to resolve best plugin version 2015-02-02 21:45:14 +01:00
Samy Pessé df39128894 Fix #575: update logo and use retina favicon 2015-02-02 17:17:54 +01:00
Samy Pessé 3ab5b57b4f Merge pull request #573 from gbonanome/version/2.0
Add italian translation
2015-01-31 09:38:24 +01:00
Giulio Bonanome 49174d1731 Add italian translation 2015-01-31 00:51:10 +01:00
Samy Pessé ed3b77b655 Don't use xmlMode to normalize html 2015-01-30 17:47:19 +01:00
Samy Pessé 55a1aee164 Fix validation of semi-loaded plugins 2015-01-30 17:31:47 +01:00
Samy Pessé d7caf6686e Fix namespacing of plugins resources 2015-01-30 16:53:42 +01:00
Samy Pessé 71dad602ec Merge pull request #572 from AndreyAkinshin/version/2.0
Add theme/i18n/ru.json
2015-01-30 15:42:02 +01:00
Andrey Akinshin 30d8719c4b Add theme/i18n/ru.json 2015-01-30 16:39:16 +02:00
Samy Pessé ad81d38d07 Fix support of iframe in html normalization 2015-01-30 14:29:34 +01:00
Samy Pessé 6740b1b99c Use spaces identation 2015-01-30 13:56:21 +01:00
Samy Pessé f5f2cccbf4 Add "generator" to plugins blocks and filters ctx 2015-01-30 13:16:27 +01:00
Samy Pessé f45a1faa63 Fix #515: Update parsers and add reStructuredText support 2015-01-30 12:51:57 +01:00
Samy Pessé 5a0dbe8cb7 Remove useless log 2015-01-30 11:42:18 +01:00
Samy Pessé 2eb45e4699 Fix #567: Fail hard if book.json is invalid 2015-01-30 11:37:35 +01:00
Samy Pessé f7039a174a Add warning message when gitbook version to use is not fixed 2015-01-30 11:33:31 +01:00
Samy Pessé 5690704444 Download external images in ebook format 2015-01-29 22:42:41 +01:00
Samy Pessé 8a8ffb6134 Fix #565: fix relative path to fonts 2015-01-29 21:22:20 +01:00
Samy Pessé 5b23dd8ffd Fix ebook commands 2015-01-29 18:41:51 +01:00
Samy Pessé 5fc0c6b507 Convert inline svg as png if needed 2015-01-29 18:16:23 +01:00
Samy Pessé c8e72092c7 Fix inline svg image in page 2015-01-29 16:21:36 +01:00
Samy Pessé 9172948c18 Remove used blocks from templates 2015-01-29 14:18:13 +01:00
Samy Pessé 2bec7c5e10 Add option to block to not parse output 2015-01-29 14:09:27 +01:00
Samy Pessé 907ce6dbcd Fix copy of plugins assets to output 2015-01-28 22:54:19 +01:00
Samy Pessé 898000a580 Fix resources loading in plugins 2015-01-28 19:39:41 +01:00
Samy Pessé f95beed58b Fix log option to command line commands 2015-01-28 19:18:01 +01:00
Samy Pessé 4baaa41ac9 Fix for good path resolution of svg image 2015-01-28 18:34:09 +01:00
Samy Pessé 1f7d349aed Fix conversion of svg when cache is empty 2015-01-28 18:27:27 +01:00
Samy Pessé c0d922560d Improve svg conversion and links normalization 2015-01-28 18:23:48 +01:00
Samy Pessé f5ded5e5e1 Fix absolute path calcul
Add tests for links module
2015-01-28 17:52:10 +01:00
Samy Pessé 56d1720aae Improve image conversion to png to avoid doublons 2015-01-28 16:36:17 +01:00
Samy Pessé 02d7102c68 Add svgexport to travis tests 2015-01-28 14:55:59 +01:00
Samy Pessé 592b32b036 Fix error message when svgexport is not installed 2015-01-28 14:54:29 +01:00
Samy Pessé 1213997341 Use svgexport instead of imagemagick 2015-01-28 14:53:27 +01:00
Samy Pessé 4e620f34ad Handle correctly path starting with "/" 2015-01-28 13:17:41 +01:00
Samy Pessé 534edaceac Handle absolute url for images conversion (svg -> png) 2015-01-28 12:46:15 +01:00
Samy Pessé ee13b4bf75 Improve error message when imagemagick is not installed 2015-01-28 12:22:26 +01:00
Samy Pessé 924006d508 Add test for svg conversion 2015-01-28 12:02:36 +01:00
Samy Pessé 350f34561a Show log from ebook-convert in realtime for debugging 2015-01-28 11:52:24 +01:00
Samy Pessé 324fbb2f69 Convert svg images to png in ebook 2015-01-28 11:43:44 +01:00
Samy Pessé 5539ab48a5 Fix init of livereload plugin on serve 2015-01-28 11:28:21 +01:00
Samy Pessé c25157fc40 Fix display of plugins count 2015-01-28 11:10:30 +01:00
Samy Pessé d1b2950993 Check parser used before applying template shortcuts 2015-01-27 22:34:48 +01:00
Samy Pessé d8995200e6 Add options "shortcuts" for blocks from plugins 2015-01-27 22:27:59 +01:00
Samy Pessé bc389ab4a1 Improve tests on blocks extensions 2015-01-27 21:47:14 +01:00
Samy Pessé cf12d09092 Complete parsing of blocks from plugin extensions 2015-01-27 21:39:41 +01:00
Samy Pessé 8e18adbe4c Parse correctly list of blocks and args 2015-01-27 21:21:01 +01:00
Samy Pessé f1b5e3de0c Add test for block defined with special end tag 2015-01-27 17:16:59 +01:00
Samy Pessé 0e0a23b794 Add blocks from plugins to template engine 2015-01-27 17:07:25 +01:00
Samy Pessé d9329295d6 Add test for extending template blocks 2015-01-27 16:04:49 +01:00
Samy Pessé 750fb862d4 Improve tests for plugins with filters 2015-01-27 15:58:28 +01:00
Samy Pessé 131c19dee6 Move plugin helper methods to a specific class 2015-01-27 15:22:42 +01:00
Samy Pessé 870ca4da0c Extend templates filters
Fully remove mathjax from plugins
2015-01-27 12:56:04 +01:00
Samy Pessé 54e1be1e77 Parse plugins in book instead of generator 2015-01-27 12:49:08 +01:00
Samy Pessé ce259eb4ec Remove mathjax plugin from default installed 2015-01-27 12:35:37 +01:00
Samy Pessé 7424395171 Fix invalid log call in website generator 2015-01-27 12:17:20 +01:00
Samy Pessé 6125df5834 Add back "page:before" hook 2015-01-27 11:15:16 +01:00
Samy Pessé 99cd3148ba Log output from ebook-convert when debug is enabled 2015-01-27 09:37:38 +01:00
Samy Pessé 1a1ace0ae1 Transform as absolute output path in configuration 2015-01-26 22:21:09 +01:00
Samy Pessé 22bae559db Fix #273: clean the output without removing .git and .svn 2015-01-26 22:19:17 +01:00
Samy Pessé 5cee07ee8c fs.list take option for files to ignores 2015-01-26 21:59:55 +01:00
Samy Pessé 4250f559b0 Extract filters from plugins 2015-01-26 21:42:30 +01:00
Samy Pessé 3293c39450 Add test for plugin resources 2015-01-26 16:08:39 +01:00
Samy Pessé 5b447d030b Add some tests for plugins validation 2015-01-26 15:51:33 +01:00
Samy Pessé f02680dc73 Transform page after hook "page" 2015-01-26 13:19:42 +01:00
Samy Pessé cee7643f00 Call hook "init" when preparing generator 2015-01-26 12:54:29 +01:00
Samy Pessé a53ec62e4a Fix logs for deprecated hooks 2015-01-26 12:42:01 +01:00
Samy Pessé 795da31af8 Add warning message about deprecated hooks 2015-01-26 12:05:50 +01:00
Samy Pessé f70c29fea5 Improve logs for plugins installation 2015-01-26 11:57:28 +01:00
Samy Pessé decd8dbdc5 Add infos in readme about variables and templating 2015-01-26 10:32:19 +01:00
Samy Pessé edc954f2ac Add chapter in readme about conrefs 2015-01-26 10:19:10 +01:00
Samy Pessé 93bc86a0fe Fix git url parsing for content references 2015-01-26 10:12:26 +01:00
Samy Pessé 75b217fc24 Support ssh urls in git parsing 2015-01-26 09:12:00 +01:00
Samy Pessé d6b44cc149 Add tests for parsing git url 2015-01-26 08:05:07 +01:00
Samy Pessé 0f0ec4cf3d Improve logger 2015-01-25 15:27:40 +01:00
Samy Pessé 06ab84abe3 Improve logger module 2015-01-25 14:55:37 +01:00
Samy Pessé bb5761e885 Change comment start and end in templates
(to avoid conflicts with maths)
2015-01-25 13:54:25 +01:00
Samy Pessé d60a9763cd Fix loading of plugins when book root is relative 2015-01-25 12:08:52 +01:00
Samy Pessé e366c05238 Add logs on plugins loading 2015-01-25 12:06:52 +01:00
Samy Pessé 690cdbe505 Improve output of book.log 2015-01-25 12:03:19 +01:00
Samy Pessé fd701fc37c Add color to output 2015-01-25 11:55:33 +01:00
Samy Pessé 4d38baf7a2 Add _book to list of files to ignore 2015-01-25 11:55:25 +01:00
Samy Pessé 7a999e01d5 Fix link in features list 2015-01-25 11:35:32 +01:00
Samy Pessé f3a5464306 Add AsciiDoc to readme 2015-01-25 11:32:54 +01:00
Samy Pessé 2c57a37afb Add command to init a book 2015-01-24 23:14:32 +01:00
Samy Pessé 244b0f8efc Add back readme 2015-01-24 21:34:18 +01:00
Samy Pessé b4dc31e82b Add command to generate all ebooks 2015-01-24 18:56:18 +01:00
Samy Pessé 1583ede3d7 Add Book.generateFile to output a pdf 2015-01-24 18:54:20 +01:00
Samy Pessé 572994a17e Add more tests for inclusion 2015-01-24 18:18:43 +01:00
Samy Pessé 796dd4c13a Add base loader to resolve git dependencies 2015-01-24 18:04:03 +01:00
Samy Pessé e02f29e763 Add test for local inclusion 2015-01-24 15:33:04 +01:00
Samy Pessé 6805b02c63 Improve german translation of "Introduction" 2015-01-24 12:53:06 +01:00
Samy Pessé 21949ccd04 Update gitbook-parsers@0.2.2 2015-01-24 12:38:36 +01:00
Samy Pessé 7b766f692b Return to version 0.5.1 of gaze 2015-01-24 12:34:01 +01:00
Samy Pessé c9aca86dcc Watch all fiels that can be parsed in serve 2015-01-24 12:29:04 +01:00
Samy Pessé 99d9d49610 Improve navigation with non existant entries
Use i18n for introduction title
2015-01-24 12:18:23 +01:00
Samy Pessé fd98746c2b Update gitbook-parsers and improve summary tests 2015-01-24 11:57:21 +01:00
Samy Pessé 2efd234824 Complete serve command 2015-01-24 11:23:53 +01:00
Samy Pessé 8be4304b5c Fix translation of White theme in german 2015-01-24 10:54:31 +01:00
Samy Pessé c984eba2bc Fix german translation 2015-01-23 23:21:56 +01:00
Samy Pessé 2bb2a2a330 Normalize language to support: "fr-FR" 2015-01-23 23:06:10 +01:00
Samy Pessé f12163534d Add german transalation
Based on PR by @winniehell
2015-01-23 22:51:23 +01:00
Samy Pessé e9d7c71911 Fix fr i18n texts 2015-01-23 22:46:07 +01:00
Samy Pessé 59b3b0fadd Translate ebook 2015-01-23 22:33:24 +01:00
Samy Pessé b426aba846 Add french translations for website 2015-01-23 22:29:40 +01:00
Samy Pessé 89885e17a5 Set translation to use in templates 2015-01-23 22:12:58 +01:00
Samy Pessé b66e9d2bed Load locales to translate layout 2015-01-23 22:05:11 +01:00
Samy Pessé d0f910d65f Fix language parsing test 2015-01-23 18:59:01 +01:00
Samy Pessé 8e41aca8a7 Fix #517: fix weibo sharing class in header 2015-01-23 18:53:48 +01:00
Samy Pessé 4fec7760a1 Fix error in book parsing 2015-01-23 18:50:10 +01:00
Samy Pessé e6cbea9c70 Change name config "lang" to "language" 2015-01-23 18:48:49 +01:00
Samy Pessé 7945f19285 Fix display of log type 2015-01-23 18:40:42 +01:00
Samy Pessé 5bd1269268 Accept argument "log" from commands 2015-01-23 18:39:07 +01:00
Samy Pessé 1fdd8a7611 Improve logs in book parser 2015-01-23 18:21:03 +01:00
Samy Pessé 112782d118 Add logs methods to Book object 2015-01-23 18:03:15 +01:00
Samy Pessé b88b4a0578 Add context configuration to Book object 2015-01-23 17:40:53 +01:00
Samy Pessé a964e19715 Fix paths indexed in search index 2015-01-23 16:17:04 +01:00
Samy Pessé c47166d700 Fix version in generator tag 2015-01-23 16:04:10 +01:00
Samy Pessé 77834f8166 Accept format argument to build command 2015-01-23 15:51:19 +01:00
Samy Pessé 0fc34e0a35 Use npm version of gitbook-parsers 2015-01-23 15:25:13 +01:00
Samy Pessé df16f3d90d Test ebook generation instead of pdf output 2015-01-23 14:10:45 +01:00
Samy Pessé ccd2f6ecdc Check that readme file is not ignored when parsing 2015-01-23 12:11:27 +01:00
Samy Pessé 19f1d31758 Add base for ebook generator 2015-01-23 00:16:46 +01:00
Samy Pessé ee2420cbcc Change name of generator "site" to "website" 2015-01-22 22:57:08 +01:00
Samy Pessé 322cf59a34 Use html link in search index 2015-01-22 22:46:35 +01:00
Samy Pessé 66841b1bb7 Remove glossary from theme js 2015-01-22 22:36:59 +01:00
Samy Pessé 74ea419c53 Write search index to output folder 2015-01-22 22:31:47 +01:00
Samy Pessé 0c8513801c Write glossary for website 2015-01-22 21:52:13 +01:00
Samy Pessé 90789aa5b9 Use container-based Travis CI stack
cc @winniehell
2015-01-22 21:21:27 +01:00
Samy Pessé 1d13624d3d Replace glossary terms by links to glossary 2015-01-22 19:45:14 +01:00
Samy Pessé 9e172549d1 Mark glossary terms in html parsed 2015-01-22 19:09:03 +01:00
Samy Pessé 0ba36c6f4e Use external gitbook parsers 2015-01-22 18:21:30 +01:00
Samy Pessé c47093e82a Add test for generation of multilingual book 2015-01-22 17:15:06 +01:00
Samy Pessé 57bdc102bc Fix tests of generations 2015-01-22 17:12:46 +01:00
Samy Pessé be651f0138 Separate test for geenration 2015-01-22 17:06:33 +01:00
Samy Pessé 974819bafb Remove parent extension for nunjucks 2015-01-22 17:03:51 +01:00
Samy Pessé f31a272b1f Add options "input" that equals root of the book 2015-01-21 23:04:55 +01:00
Samy Pessé a492c66321 Copy files from book to output
Add test for personalised styles
2015-01-21 23:03:09 +01:00
Samy Pessé 85930161f7 Normalize tests 2015-01-21 22:51:59 +01:00
Samy Pessé 4f9ece1ec1 Fix display of summary in website 2015-01-21 20:26:29 +01:00
Samy Pessé 748f004609 Add summary utils 2015-01-21 20:21:55 +01:00
Samy Pessé cb709930bb Normalize summary in gitbook 2015-01-21 20:21:47 +01:00
Samy Pessé 98027cb008 Fix path to assets in website 2015-01-21 20:04:03 +01:00
Samy Pessé 3d8db17bc3 Copy theme assets to output 2015-01-21 19:51:35 +01:00
Samy Pessé 3c605ea809 generate an index.html for entry points 2015-01-21 19:40:40 +01:00
Samy Pessé bd931c5cbd Adapt themes website templates 2015-01-21 19:15:57 +01:00
Samy Pessé c6e3a27284 Add normalization of plugins 2015-01-21 13:36:09 +01:00
Samy Pessé b5d7e7966f Fix site generator polluting basegenerator 2015-01-21 11:43:39 +01:00
Samy Pessé be2da0fab1 Fix json template preparation 2015-01-21 11:33:33 +01:00
Samy Pessé 0da50819d6 Fix asciidoc test generation 2015-01-21 11:28:59 +01:00
Samy Pessé 9f9265ad76 Add asciidoc support 2015-01-21 10:17:58 +01:00
Samy Pessé a5ebbc34c7 Add styles configuration in book.json 2015-01-20 13:30:22 +01:00
Samy Pessé 33e32b20d9 Use latest version fo theme 2015-01-20 11:32:11 +01:00
Samy Pessé 238cd9f7f0 Add back theme 2015-01-20 11:29:26 +01:00
Samy Pessé bac25cdf29 Improve tests for multilingual json output 2015-01-19 22:44:17 +01:00
Samy Pessé c15399613c Normalize paths in html content 2015-01-19 22:39:23 +01:00
Samy Pessé d6f7f1f4fb Add test for parsing of navigation 2015-01-19 21:19:41 +01:00
Samy Pessé a67dad8cbe Fix list of files and parsing of navigation files only 2015-01-19 21:16:06 +01:00
Samy Pessé b549158483 Parse navigation and progress in parsed page 2015-01-19 20:54:59 +01:00
Samy Pessé 9a2b03b183 Handle different structure in json multilingual output 2015-01-19 20:46:05 +01:00
Samy Pessé 2b2b4f46c2 Complete json generator for multilingual book
Add tests
2015-01-19 20:41:34 +01:00
Samy Pessé 6344928580 Write file in json generator 2015-01-19 18:49:02 +01:00
Samy Pessé 2dbf9b0d4a Start adapting json generator 2015-01-19 17:32:59 +01:00
Samy Pessé be4d2679a4 Add base test for generation 2015-01-19 17:25:16 +01:00
Samy Pessé 70189a5ee2 Fix parsing of plugins list 2015-01-19 16:59:42 +01:00
Samy Pessé ad233c0d8e Improve plugins installation to prevent installation of default plugins 2015-01-19 16:53:20 +01:00
Samy Pessé 41c3db4c04 Add command to install plugins 2015-01-19 16:30:52 +01:00
Samy Pessé 7f01f4b048 Add plugin object 2015-01-19 16:23:44 +01:00
Samy Pessé 5ed5844490 Parse list of files and add test for it 2015-01-19 16:00:12 +01:00
Samy Pessé 777963c97c Change name of Book.init to Book.parse 2015-01-19 15:52:35 +01:00
Samy Pessé 2f3d6f8dff Improve test for parsing multilanguages books 2015-01-19 15:48:22 +01:00
Samy Pessé 2ae3924365 Fix parsing of langs 2015-01-19 15:46:34 +01:00
Samy Pessé d172aaefee Add test for glossary parsing 2015-01-19 15:31:58 +01:00
Samy Pessé f0ea7bc53b Add test for readme parsing 2015-01-19 15:28:13 +01:00
Samy Pessé 793600ab2f Improve test to test a all book 2015-01-19 15:26:31 +01:00
Samy Pessé 354b4afba1 Parse readme 2015-01-19 15:12:08 +01:00
Samy Pessé 8569a74103 Use template before parsing glossary, summary and langs 2015-01-19 15:05:13 +01:00
Samy Pessé b314972195 Add configuration to send structures files 2015-01-19 14:51:35 +01:00
Samy Pessé 52179163dd Fix output for sub-books in multi languages 2015-01-19 13:27:17 +01:00
Samy Pessé 8ed9f645fc Fix parsing of langs
Add command to build
2015-01-19 13:22:34 +01:00
Samy Pessé e1594cde2c Remove doc about custom styles 2015-01-19 13:14:52 +01:00
Samy Pessé 60993d3123 Parse langs and glossary 2015-01-19 12:06:04 +01:00
Samy Pessé 39b2aaf489 Add parsing of summary and associated tests 2015-01-19 10:59:43 +01:00
Samy Pessé 58b04da60f Add test for loading configuration from book.js 2015-01-19 10:15:53 +01:00
Samy Pessé d9c020194d Add base object to load configuration 2015-01-19 10:08:49 +01:00
Samy Pessé ec586dd3cd Clear folder 2015-01-19 09:47:36 +01:00
Samy Pessé 8043216170 Merge pull request #555 from GitbookIO/feature/styles
Add custom styles options
2015-01-15 06:29:14 +01:00
Samy Pessé 3c7372dff5 Add doc about custom styles 2015-01-14 22:53:27 +01:00
Samy Pessé 2cab018791 Merge pull request #553 from GitbookIO/fix/summary-whitespace
Fix/summary whitespace
2015-01-14 22:41:34 +01:00
Samy Pessé 9467cda131 Apply styles to ebook output 2015-01-14 22:31:36 +01:00
Samy Pessé 3382f1b084 Include styles in website format 2015-01-14 22:19:40 +01:00
Aaron O'Mullan ae52ef5b78 Handle whitespace between lists in SUMMARY.md 2015-01-14 22:17:15 +01:00
Aaron O'Mullan f88951546d Add test/bin/summary.js
Another small useful tool
2015-01-14 22:16:37 +01:00
Samy Pessé 7d90cd2a9e Add default values for "styles" 2015-01-14 22:08:42 +01:00
Samy Pessé 94a9db3d54 Move theme folder "book" to "website" 2015-01-14 22:08:31 +01:00
Aaron O'Mullan 3f36d83bfb Add test/bin/lex.js utility
Helpful binary when developing / debugging
2015-01-14 21:56:57 +01:00
Aaron O'Mullan c7e3370ac0 Add summary whitespace tests 2015-01-14 21:45:32 +01:00
Samy Pessé bcb34dcd79 Merge pull request #547 from JozoVilcek/patch-2
Change link to mermaid plugin
2015-01-12 00:13:17 +01:00
Jozef Vilcek 71905aa0c8 Change link to mermaid plugin
Repository name for mermaid plugin has changed to better reflect naming conventions
2015-01-12 00:11:02 +01:00
Samy Pessé dcbf115f25 Adapt platform command to gitbook.com 2015-01-11 15:14:50 +01:00
Samy Pessé 668f2f9e2c Update urls in package.json 2015-01-11 15:09:25 +01:00
Samy Pessé 530975b4fb Improve names of plugins 2015-01-11 14:53:57 +01:00
Samy Pessé d35ce31af2 Merge pull request #545 from JozoVilcek/patch-1
Enlist gitbook-mermaid plugin
2015-01-11 14:52:49 +01:00
Jozef Vilcek e5f17cd694 Enlist gitbook-mermaid plugin 2015-01-11 13:52:11 +01:00
Aaron O'Mullan b50dea9c70 Update kramed to 0.4.4 2015-01-06 15:15:48 +01:00
Aaron O'Mullan 6b76032bb1 Bump version to 1.5.0 2014-12-17 17:08:09 +01:00
Aaron O'Mullan 85b09eda56 Add 1.4.2's changes 2014-12-17 17:07:10 +01:00
Aaron O'Mullan c4be78a81f Merge pull request #506 from Nijikokun/feature/clarity-midnight
Clarity: Midnight Theme (Night)
2014-12-16 18:53:09 +01:00
Aaron O'Mullan e7309f71d2 Merge pull request #530 from GitbookIO/fix/cli-error-handling
Robust CLI error handling
2014-12-16 17:46:01 +01:00
Aaron O'Mullan 6c979c9419 Robust CLI error handling
Fixes #528, fixes #524, fixes #518
2014-12-16 16:05:50 +01:00
Aaron O'Mullan 7fd7732345 Bump version to 1.4.2 2014-12-10 23:27:01 +01:00
Aaron O'Mullan 960ef4d945 Fix descriptor and me leak with bad write queues
Node.js for some reason queues up writes from fs.writeFile causing
memory and descriptor leaks, preventing building large books. This is
now fixed

Fixes #336, fixes #454
2014-12-10 16:32:49 +01:00
Aaron O'Mullan 92523fb4b5 Force process.exit at end of build 2014-12-09 17:31:23 +01:00
Samy Pessé 66bb46df22 Merge pull request #516 from jr0cket/patch-1
Add gitbook init command to "how to use" section
2014-12-08 00:46:04 +01:00
John Stevenson 0454710d3b Add gitbook init command to "how to use" section
Highlight that Gitbook can generate the files and directories for a book from its SUMMARY.md file.
2014-12-07 23:44:41 +00:00
Samy Pessé c9a31cc987 Add option isbn for books 2014-12-03 23:19:47 +01:00
Samy Pessé f03c316274 Bump version to 1.4.1 2014-11-30 17:01:47 +01:00
Samy Pessé 001a4f91be Fix command 'install' without arguments 2014-11-30 17:00:12 +01:00
Samy Pessé 44a3bfe296 Bump version to 1.4.0 2014-11-30 14:59:08 +01:00
Samy Pessé a9ce6f808d Add doc about gitbook install 2014-11-30 14:54:34 +01:00
Samy Pessé e5c667e0fa Add test for parsing of plugins list with version 2014-11-30 14:50:47 +01:00
Samy Pessé e36f274dbe Handle specific version for plugins 2014-11-30 14:46:21 +01:00
Samy Pessé 2a88427e74 Improve error message when plugins not found 2014-11-30 13:13:00 +01:00
Samy Pessé ed48f5f3ee Add command "install" to install plugins from book.json 2014-11-30 13:04:38 +01:00
Samy Pessé 7b4accb117 Bump version to 1.3.4 2014-11-25 18:55:33 +01:00
Samy Pessé d6437d31d4 Omit "generator" when building file with config file 2014-11-25 18:53:02 +01:00
Samy Pessé 3dd33f1f3c Merge pull request #502 from tonka3000/X-UA-Compatible-tag
add X-UA-Compatible meta tag for IE
2014-11-25 15:20:14 +01:00
Samy Pessé 3a0f00411b Fix #505: add glossary to ebook file 2014-11-24 22:08:19 +01:00
Samy Pessé 5b655bb29a Fx typo 2014-11-24 21:56:33 +01:00
Samy Pessé faf10605e8 Add hook finish:before 2014-11-24 21:41:50 +01:00
Nijiko Yonskai c52aecdbd5 Initial release 2014-11-22 20:37:06 -08:00
Samy Pessé 5c98b3350b Merge pull request #503 from jr0cket/ebook-command-fix
updated eBook generation commands - resolves #432
2014-11-22 16:41:19 +01:00
John Stevenson 6f4e1d10c1 made commands clearer by seperating output filename option 2014-11-22 14:47:12 +00:00
John Stevenson 870886599a updated eBook generation commands 2014-11-22 11:26:08 +00:00
Michael Aigner 1b9801b8a4 add X-UA-Compatible meta tag for IE (https://github.com/GitbookIO/gitbook/issues/501) 2014-11-20 10:16:40 +01:00
Samy Pessé 897463b22e Bump version to 1.3.3 2014-11-14 22:10:19 +01:00
Samy Pessé aa4894e94c Fix parsing of already lexed content 2014-11-14 22:09:30 +01:00
Samy Pessé 8a0180ae6b Bump version to 1.3.2 2014-11-14 18:53:57 +01:00
Samy Pessé d6776b98d3 Fix bundle task 2014-11-14 18:53:48 +01:00
Samy Pessé 6a04ba89a5 Update gitbook bundle 2014-11-14 18:53:39 +01:00
Samy Pessé 05eaeeb0d0 Fix #441: Improve validity of epub output 2014-11-13 08:34:35 +01:00
Samy Pessé 77043464b2 Fix #496: improve replacement of glossary terms in html 2014-11-12 22:10:38 +01:00
Samy Pessé b90f74a821 Merge pull request #494 from cnDelbert/master
Bug fix for issue#493: 2-level or more deep relative links go wrong when in win32
2014-11-12 19:06:33 +01:00
Aaron O'Mullan f804eb42ac Merge pull request #495 from romanlytkin/patch-1
Update README.md
2014-11-07 15:58:18 +01:00
romanlytkin 74fd8c159b Update README.md
Hi, i add 2 new plugins for gitbook, I hope it will be useful to someone.
2014-11-07 17:37:27 +03:00
Delbert a741ec1350 Bug fix for issue #493: 2-level or more deep relative links may go wrong when in win32 2014-11-06 15:50:59 +08:00
Samy Pessé 4b26c31b3b Remove unnecessary option "repo" from tests 2014-11-03 17:43:44 +01:00
Samy Pessé dfd487692a Adapt new page.parse api for tests 2014-11-03 17:40:38 +01:00
Samy Pessé 195374ecee Merge pull request #489 from codepiano/fork
bugfix,init page object's lexed attribute.
2014-11-03 17:29:54 +01:00
Samy Pessé 1659778a77 Bump version to 1.3.1 2014-11-03 16:58:37 +01:00
Samy Pessé 40c4035afb Fix #491: handle correctly url without path for links 2014-11-03 16:57:35 +01:00
codepiano 1502d65286 Merge branch 'master' of github.com:GitbookIO/gitbook into fork
Conflicts:
	lib/parse/page.js
2014-11-02 01:34:28 +08:00
Samy Pessé 0feb672d70 Bump version to 1.3.0 2014-11-01 15:36:10 +01:00
Samy Pessé 2a4ef5bbf4 Fix dependency in renderer 2014-11-01 15:21:16 +01:00
Samy Pessé c4540332a7 Bundle gitbook parser as a client side library 2014-11-01 15:09:58 +01:00
Samy Pessé 2104404cb3 Remove dependency for path in parser 2014-11-01 15:09:41 +01:00
Samy Pessé 002d685ebb Adapt include in page parsing to works on clientside 2014-11-01 15:00:13 +01:00
codepiano 9da10e2b25 bugfix,init page object's lexed attribute.
the page object's attribute 'lexed' is not correctly inited.so when
use page.lexed to generate the search index file,nothing will be
indexed.
2014-10-31 18:00:09 +08:00
Samy Pessé 1e4632080b Bump version to 1.2.0 2014-10-30 18:27:56 +01:00
Samy Pessé 5191106396 Update documentation in readme 2014-10-30 18:27:26 +01:00
Samy Pessé 6ab5cafaf3 Improve toc in ebook (Fixes #338, #322) 2014-10-30 18:14:06 +01:00
Samy Pessé d1c0cb9c71 Normalize template paths 2014-10-30 18:01:56 +01:00
Samy Pessé 38c750101c Fix #487: Use generated toc as base for ebook generation 2014-10-30 17:52:39 +01:00
Samy Pessé ba0f379a89 Add plugin infinitescroll 2014-10-30 16:19:19 +01:00
Samy Pessé 1d9509b3b6 Merge pull request #485 from citizenmatt/Nested_list_spacing
Fix bottom border on nested ul
2014-10-30 14:15:54 +01:00
Samy Pessé 3c8de4a8ab Add 'variables' to book.json doc 2014-10-29 17:20:30 +01:00
Samy Pessé 591d8fc9ee Use book.json to store variables 2014-10-29 17:19:19 +01:00
Samy Pessé d480e9cea4 Update highlight.js@8.3.0 2014-10-23 17:05:27 +02:00
Matt Ellis 32a71869da Fix bottom border on nested ul 2014-10-23 09:19:02 +01:00
Samy Pessé fdbfda64a6 Merge pull request #483 from dharmeshkakadia/patch-1
Corrected a small typo in Plugins description
2014-10-21 15:45:45 +02:00
Dharmesh Kakadia a6f48be39e Corrected a small typo in Plugins description 2014-10-21 00:47:37 +05:30
Aaron O'Mullan ce50b893e9 Merge pull request #482 from GitbookIO/feature/includes
Add include support, with variables and the whole shebang
2014-10-15 21:29:23 +02:00
Aaron O'Mullan 225ff27dd1 Fix small incompatibility mistake 2014-10-15 21:28:53 +02:00
Aaron O'Mullan 52e8361846 Add include support, with variables and the whole shebang
Fixes #462
2014-10-15 21:20:10 +02:00
Samy Pessé 49e3bbc3d6 Bump version to 1.1.1 2014-10-13 16:03:47 +02:00
Aaron O'Mullan c9ec911d0e Merge pull request #472 from GitbookIO/fix/quizzes
Fix/quizzes
2014-10-13 15:55:32 +02:00
Aaron O'Mullan 84d7662fd8 Allow quiz titles in validation 2014-10-13 15:55:59 +02:00
Aaron O'Mullan 676b2287ee Rewrite quiz logic to be more robust
Fixes #470
2014-10-13 15:50:12 +02:00
Samy Pessé 32a64be407 Fix #460: search for glossary term on all nodes 2014-10-13 15:23:51 +02:00
Samy Pessé 138cddf3d6 Ste GitBook as publisher 2014-10-13 15:23:00 +02:00
Aaron O'Mullan d730a3aac6 Split section classification to separate files
Maybe have a sections folder in the future and one per type
(quiz/exercise/normal) ?
2014-10-13 15:07:46 +02:00
Aaron O'Mullan ffb0b12012 Add unit test for quiz false positivies 2014-10-13 14:17:08 +02:00
Samy Pessé 78e25f8252 Add link to gitbook.gitignore 2014-10-13 11:10:28 +02:00
Samy Pessé 09f42f57e1 Improve comments 2014-10-13 11:01:00 +02:00
Samy Pessé 950ad1d060 Remove reference to single page output 2014-10-13 10:59:32 +02:00
Samy Pessé ed6b29c1a4 Adapt tests 2014-10-13 10:57:47 +02:00
Samy Pessé 36785120b1 Fix default for pdf templates 2014-10-13 10:56:14 +02:00
Samy Pessé 26fad5b888 Remove ref to github options 2014-10-13 10:53:51 +02:00
Samy Pessé f049576575 Merge branch 'alexandreaquiles-pdf_header_and_footer' 2014-10-13 10:48:33 +02:00
Samy Pessé a7ecbb87e4 Force type of header and footer templates 2014-10-13 10:48:02 +02:00
Samy Pessé 1da341741b Merge pull request #471 from GitbookIO/feature/multipages
Use multiple HTML files for ebook generation
2014-10-13 10:41:23 +02:00
Samy Pessé 2dd6192576 Remove old codes 2014-10-12 22:25:39 +02:00
Samy Pessé 52c9347b9c Improve style for exercises and quizzes in ebook 2014-10-12 22:07:37 +02:00
Samy Pessé e2295591ed Handle correctly quizzes 2014-10-12 11:42:32 +02:00
Samy Pessé 0c1cb724d7 Handle correctly exercises in ebook 2014-10-12 11:37:51 +02:00
Samy Pessé 7cee248426 Generate multiple page for ebook 2014-10-12 11:32:45 +02:00
Aaron O'Mullan 6ea5b2b539 Fix incorrect page breaks after h1 and h2 divs
Fixes #463, fixes #337, fixes #293
2014-10-08 20:08:22 +02:00
Alexandre Aquiles a56b559d43 Adding options to set header and footer in PDF generation 2014-10-06 13:17:34 -03:00
Samy Pessé df1a82e0e4 Add changelog for 1.1.0 2014-09-24 14:57:50 +02:00
Samy Pessé f15a1efe71 Bump version to 1.1.0 2014-09-24 14:56:09 +02:00
Samy Pessé b8379fc6fa Update kramed@0.4.3 2014-09-24 14:53:42 +02:00
Samy Pessé d69cc74647 Merge pull request #440 from GitbookIO/feature/ebookplugins
Apply plugins to ebook generation
2014-09-17 15:02:22 +02:00
Samy Pessé f83874a9ca Fix correct folder for assets 2014-09-17 14:16:04 +02:00
Samy Pessé 1968bb79c2 Use correct resources file for ebook 2014-09-17 13:17:30 +02:00
Samy Pessé 60c721db40 Enable css from plugins in page output 2014-09-17 13:10:36 +02:00
Samy Pessé 11b299653f Remove githubId
Enable hook for ebook
2014-09-17 13:08:30 +02:00
Samy Pessé c8c07fe8ce Add base to use plugins in page format 2014-09-17 13:00:28 +02:00
Samy Pessé be0a4f08e9 Merge pull request #435 from markcxz/master
fix radio input uncheck failed
2014-09-10 09:56:12 +02:00
markcxz 4da4e28d07 fix radio input uncheck failed 2014-09-10 10:27:27 +08:00
Samy Pessé 9dc19026c6 Add changelog for version 1.0.3 2014-09-05 17:15:04 +02:00
Samy Pessé 31ca9f7fcb Bump version to 1.0.3 2014-09-05 17:12:03 +02:00
Samy Pessé 6925d39e8d Fix GitbookIO/editor#136: update highlight.js@8.2.0 2014-09-05 17:10:47 +02:00
Samy Pessé a24cafd975 Update plugin-mathjax@0.0.6 2014-09-02 23:25:33 +02:00
Aaron O'Mullan e3fdf8b404 Bump version to 1.0.2 2014-08-20 17:03:31 -07:00
Aaron O'Mullan c861223378 Use gitbook-plugin-mathjax@0.0.5 2014-08-20 17:01:14 -07:00
Aaron O'Mullan f5c6d8df71 Bump version to 1.0.1 2014-08-20 16:30:04 -07:00
Aaron O'Mullan 452c846e90 Update framed to 0.4.2
This uses the new kramdown convention for inline math
2014-08-20 16:27:50 -07:00
Samy Pessé aedd875ab7 Fix url for sharing 2014-08-20 15:54:11 -07:00
Samy Pessé d2ec2f8f02 Add plugins exercises and quizzes by default 2014-08-20 10:33:34 -07:00
Samy Pessé 5af0df93c3 Normalize titles in readme 2014-08-19 16:39:54 -07:00
Samy Pessé 5b4b5e1af7 Bump version to 1.0.0 2014-08-19 16:18:29 -07:00
Samy Pessé 21704c4ac2 Add documentation for glossary format 2014-08-19 16:16:59 -07:00
Aaron O'Mullan 71aff10092 Merge pull request #413 from GitbookIO/feature/glossary
Glossary terms highlight in page
2014-08-19 16:09:47 -07:00
Samy Pessé 4b390667e5 Replace whole word with glossary term 2014-08-19 16:10:02 -07:00
Samy Pessé 14dda3148d Improve replace of words with glossary links 2014-08-19 16:05:57 -07:00
Samy Pessé 511dc9f805 Add action on glossary term in the page 2014-08-19 15:40:37 -07:00
Samy Pessé d0a14dcbcc Write correct glossary to disk 2014-08-19 10:36:27 -07:00
Samy Pessé ec8dc2cdb0 Improve design for glossary page 2014-08-18 22:00:34 -07:00
Samy Pessé 6f1ef585be Show index on glossary page 2014-08-18 21:53:07 -07:00
Samy Pessé d84acd0b82 Dump glossary index to glossary_index.json 2014-08-18 21:32:10 -07:00
Samy Pessé e1723ad3d5 Remove debug 2014-08-18 21:25:27 -07:00
Samy Pessé f77404afe1 Merge pull request #411 from GitbookIO/glossary-search
Glossary search
2014-08-18 19:14:14 -07:00
Aaron O'Mullan fbd7522748 Replace kramed-text-renderer references
with “kramed-text-renderer”
2014-08-18 18:36:38 -07:00
Aaron O'Mullan 90320fd26c Add glossary indexing 2014-08-18 17:25:26 -07:00
Aaron O'Mullan 4f9b474fdd Use kramed 0.4.1 2014-08-18 12:01:26 -07:00
Aaron O'Mullan 4c921bdc09 Use kramed-text-renderer (0.2.1) 2014-08-18 12:01:12 -07:00
Aaron O'Mullan 93e0864063 Fix dump typo in glossary's entryId func 2014-08-17 21:18:42 -07:00
Aaron O'Mullan 80e2f23714 Add "id" attribute to parsed glossary entries 2014-08-17 21:13:39 -07:00
Samy Pessé 00496dbd09 Add link to glossary if exists 2014-08-17 17:46:55 -07:00
Samy Pessé 54fb9a58d7 Add base less for glossary 2014-08-17 11:34:33 -07:00
Samy Pessé 6b0ad22b19 Base template for glossary 2014-08-17 11:26:20 -07:00
Samy Pessé 17f40540ae Parse glossary during build 2014-08-17 11:16:36 -07:00
Samy Pessé d337a500dc Merge pull request #408 from GitbookIO/feature-glossary
Feature glossary
2014-08-15 12:12:20 -07:00
Aaron O'Mullan cbe4e9edec Simplify output of glossary parsing to more simple objects 2014-08-15 12:09:36 -07:00
Samy Pessé 402e88f866 Add best practices for .gitignore 2014-08-15 11:55:01 -07:00
Aaron O'Mullan e0aed828e0 Add very basic glossary parsing test 2014-08-11 19:41:06 -07:00
Aaron O'Mullan 323facbdc8 Add glossary parser 2014-08-11 18:57:39 -07:00
Aaron O'Mullan 2a61c858e4 Add GLOSSARY.md fixture 2014-08-11 18:53:05 -07:00
Aaron O'Mullan d216661f27 Merge pull request #403 from GitbookIO/version/1.0.0
Version 1.0.0
2014-08-11 09:42:18 -07:00
Samy Pessé 50dfee99b6 Fix code coloration in book markdown 2014-08-11 09:37:25 -07:00
Samy Pessé 9e8ed9ac68 Use new markdown content css 2014-08-11 08:42:47 -07:00
Samy Pessé 3a54554713 Normalize markdown rendering with ebook (pdf, epub, mobi) 2014-08-11 08:38:11 -07:00
Samy Pessé fc113ce0c3 Fix style for table on night and sepia themes 2014-08-11 07:36:54 -07:00
Samy Pessé f605f0b6c8 Fix color or title for sepia and night 2014-08-11 07:36:54 -07:00
Samy Pessé 08788edfd3 Change list of plugins to a table 2014-08-11 07:36:54 -07:00
Samy Pessé 4a0e19935f Improve readme doc 2014-08-11 07:36:54 -07:00
Samy Pessé a3454bb7a8 Update preview 2014-08-11 07:36:53 -07:00
Samy Pessé 7245fa8ad7 Add icon for iOS 2014-08-11 07:36:53 -07:00
Samy Pessé d771ff341d Improve spacing between titles 2014-08-11 07:36:53 -07:00
Samy Pessé 8171241666 Remove quizzes handling from core 2014-08-11 07:36:53 -07:00
Samy Pessé 1125e89b49 Fix error with markdown rendering 2014-08-11 07:36:53 -07:00
Samy Pessé 67fd5a060b Add style for buttons 2014-08-11 07:36:52 -07:00
Samy Pessé 4f60eda3ee Add style for alerts
Remove style for exercises
2014-08-11 07:36:52 -07:00
Samy Pessé 6c62d75eae Remove exercises execution 2014-08-11 07:36:52 -07:00
Samy Pessé bcfcf3d979 Fix sharing to instapaper 2014-08-11 07:36:52 -07:00
Samy Pessé b4497029db Improve normalization of variables for dropdown 2014-08-11 07:36:52 -07:00
Samy Pessé 23ac4b846d Add sharing to instapaper 2014-08-11 07:36:51 -07:00
Samy Pessé 691d04e994 Improve dropdown to make it global
Add dropdown for sharing
2014-08-11 07:36:51 -07:00
Samy Pessé a54959ee4f Show title on hover of header 2014-08-11 07:36:51 -07:00
Samy Pessé 76ebca8c55 Fix url.js inclusion 2014-08-11 07:36:51 -07:00
Samy Pessé 786c4f147d Use fontawesome from bower 2014-08-11 07:36:51 -07:00
Samy Pessé 7028fc7118 Remove useless comments from less 2014-08-11 07:36:50 -07:00
Samy Pessé 1c3210e789 Fix display of input in search 2014-08-11 07:36:50 -07:00
Samy Pessé c28b804352 Remove bootstrap dependency 2014-08-11 07:36:50 -07:00
Samy Pessé 6d841c909b Remove appCache handling from client js 2014-08-11 07:36:50 -07:00
Samy Pessé e917fd28e0 Change term "Generated" to "Published" 2014-08-11 07:36:49 -07:00
Samy Pessé ab88459a56 Change default font 2014-08-11 07:36:49 -07:00
Samy Pessé fe95c361be Fix options parsing 2014-08-11 07:36:49 -07:00
Samy Pessé 7e78546516 Change links system for sidebar 2014-08-11 07:36:49 -07:00
Samy Pessé d07b9450b1 Fix defaults for configuration 2014-08-11 07:36:49 -07:00
Samy Pessé c30b431b7b Remove link home in header 2014-08-11 07:36:48 -07:00
Samy Pessé 0fe54fbd57 Fix navigation color for sepia and night 2014-08-11 07:36:48 -07:00
Samy Pessé 1bec19029f Fix navigation on mobile 2014-08-11 07:36:48 -07:00
Samy Pessé 21ccf7757e Improve padding on page content 2014-08-11 07:36:48 -07:00
Samy Pessé ceb766a124 Adapt to latest github markdown style 2014-08-11 07:36:48 -07:00
Samy Pessé 046b789fa8 Fix navigation links position 2014-08-11 07:36:47 -07:00
Samy Pessé cd50a1402f Fix border on search input (sepia and night) 2014-08-11 07:36:47 -07:00
Samy Pessé 1b0ae5a827 Fix border on dropdown selector 2014-08-11 07:36:47 -07:00
Samy Pessé 01b6ca76e8 Limit transitions to positions 2014-08-11 07:36:47 -07:00
Samy Pessé 06b9c345c9 Improve design of search bar 2014-08-11 07:36:47 -07:00
Samy Pessé 152276c1d7 Improve display of sidebar on mobile 2014-08-11 07:36:46 -07:00
Samy Pessé 275eedf076 Change button color on header 2014-08-11 07:36:46 -07:00
Samy Pessé 5e959d65a2 Start new design for website 2014-08-11 07:36:46 -07:00
Samy Pessé 66c1b89da2 Use only default config 2014-08-11 07:36:46 -07:00
Samy Pessé 78c68c7b9e Remove config for github urls 2014-08-11 07:36:46 -07:00
Samy Pessé d914eae40a Remove html5 cache manifest 2014-08-11 07:36:45 -07:00
Samy Pessé 74f95f4d0d Merge pull request #404 from Viv-Rajkumar/master
Fix path operator in Windows for index.html with multi lang
2014-08-11 07:31:10 -07:00
Viv-Rajkumar d803052461 Fix Langs path operator for Windows using 'links.js' 2014-08-11 12:09:07 +01:00
Aaron O'Mullan 633e52c4be Bump version to 0.7.1 2014-08-08 15:37:03 -07:00
Aaron O'Mullan 1512bcf808 Update fs-extra to 0.10.0
Fixes potential race condition on copies
2014-08-08 15:31:49 -07:00
Samy Pessé 4e46d088ca Add build for search results 2014-08-05 09:47:08 -07:00
Samy Pessé 388c7ffd32 Merge pull request #396 from codepiano/hold-search-keyword
keep the search result list after user click a link
2014-08-05 09:44:54 -07:00
codepiano 7ba8653935 keep the search result list after user click a link
Record search keyword to LocalStorage, when navigate to a new url,fetch
keyword from LocalStorage, init the search input element,then filter the
sidebar menu.
So User can iterator the result list without type the keyword every
time.
2014-08-05 15:14:10 +08:00
Samy Pessé a4403aad1e Add changes for 0.7.0 2014-08-01 14:01:20 -07:00
Samy Pessé b629b78dba Bump version to 0.7.0 2014-08-01 13:58:36 -07:00
Samy Pessé f62c218735 Fix #278: Add page break between chapters/articles 2014-08-01 13:55:19 -07:00
Aaron O'Mullan 725510028f Use marked-text-renderer@0.1.0 2014-08-01 00:09:45 -07:00
Aaron O'Mullan ad7927242d Add comments to default introduction chapter code
Fixes #388
2014-07-31 08:43:57 -07:00
Aaron O'Mullan 5692bdd229 Merge pull request #386 from codepiano/china-social-network-sharing
add sharing to weibo.com.
2014-07-31 01:41:56 -07:00
codepiano 3402746719 add sharing to weibo.com.
google、facebook and twitter are block by GFW in China,Chinese can
not visit these websites.
add 'weibo' config in option links.sharing,the share link will not be
used by default,users should set the value of 'weibo' to true to turn
on sharing to weibo.com.
2014-07-31 16:31:31 +08:00
Aaron O'Mullan 30a8414b06 Switch to graceful-fs, fix #373 2014-07-30 20:45:33 -07:00
Aaron O'Mullan 9d46899ea7 Replace "marked" with "kramed" 2014-07-30 16:17:47 -07:00
Samy Pessé 58f14fd9ca Fix font settings apply 2014-07-30 11:17:28 -07:00
Samy Pessé b6af14b13e Remove github count stars and watchers 2014-07-30 10:43:10 -07:00
Aaron O'Mullan ba2134c480 Bump version to 0.6.3 2014-07-30 10:23:11 -07:00
Aaron O'Mullan 4705548860 Fix resource normalization in when loading plugins
Fixes #384
2014-07-30 10:17:07 -07:00
Samy Pessé 7d51ae3689 Add changelogs for 0.6.2 2014-07-30 00:26:44 -07:00
Aaron O'Mullan b9360de3e3 Bump version to 0.6.2 2014-07-30 00:22:49 -07:00
Aaron O'Mullan 9f241457bb Fix minor issues with new plugin additions 2014-07-29 23:45:54 -07:00
Aaron O'Mullan 60a7c28e66 Support generating a plugin's book info dynamically 2014-07-29 21:50:26 -07:00
Samy Pessé 5dff9b795e Fix #345: Improve navigation on dark theme 2014-07-29 21:33:47 -07:00
Aaron O'Mullan 0134677e0e Improve path normalization when parsing SUMMARY.md 2014-07-29 20:49:11 -07:00
Aaron O'Mullan 39ef4fa199 Add invalid paths in SUMMARY.md fixture
To test for correct path normalization
2014-07-29 20:46:14 -07:00
Samy Pessé b507a30301 Bump version to 0.6.1 2014-07-23 16:49:57 -07:00
Samy Pessé 539c2d0c57 Update plugin-mathjax@0.0.4 2014-07-23 16:28:38 -07:00
Samy Pessé aa6f3530f9 Fix readme spacing 2014-07-22 23:28:13 -07:00
Samy Pessé 98057af219 Merge pull request #372 from justanotheranonymoususer/patch-1
Update summary.html (fixed an HTML typo)
2014-07-20 14:04:12 -07:00
justanotheranonymoususer bb48c8233c Update summary.html 2014-07-20 23:57:56 +03:00
Aaron O'Mullan 8f14db64df Merge pull request #370 from nightwing/patch-1
Add keyboard shortcut for submitting exercise
2014-07-15 21:33:58 -07:00
Harutyun Amirjanyan 37d40dc66c Add keyboard shortcut for submitting exercise 2014-07-16 08:07:22 +04:00
Samy Pessé 6c96680cca Merge pull request #366 from shaform/ignore
Ignore config files by default in fs.list
2014-07-14 10:08:29 -07:00
Shaform 4e475857d5 Ignore config files by default in fs.list 2014-07-13 08:40:23 -07:00
Samy Pessé f8ff0453dd Merge pull request #359 from jcouyang/patch-1
add jsbin embedded plugin
2014-07-12 07:02:18 -07:00
Samy Pessé 3cc5c47535 Bump version to 0.6.0 2014-07-12 23:28:07 +02:00
Samy Pessé a2046814b4 Change command "git:push" to "publish" 2014-07-12 23:25:40 +02:00
Samy Pessé 82f814fdbd Fix #303: generate header id the same as github 2014-07-12 23:23:03 +02:00
Jichao Ouyang cd382dc8fc add jsbin embedded support 2014-07-12 21:42:52 +08:00
Samy Pessé 3842e5bf4a Merge pull request #358 from GitbookIO/featureplatform
Add base command git:push and git:remote
2014-07-11 17:42:16 -07:00
Samy Pessé f05b138fd6 Add base command git:push and git:remote 2014-07-12 09:23:15 +02:00
Samy Pessé 1b87cec893 Merge pull request #266 from shaform/ref_links
Add reference links support
2014-07-11 17:20:43 -07:00
Samy Pessé 4a894b1e18 Merge pull request #268 from rlmv/master
Fix page.path for plugins
2014-07-11 17:19:26 -07:00
Samy Pessé c7c98009e7 Merge pull request #347 from rlmv/custom_links
Add custom links to TOC
2014-07-11 17:15:37 -07:00
Samy Pessé 356322e0ed Merge pull request #353 from citizenmatt/active_page
Highlight active page in summary
2014-07-11 17:14:36 -07:00
Samy Pessé 7a47049367 Merge pull request #354 from citizenmatt/summary_hooks
Plugin hooks for summary data
2014-07-11 17:13:40 -07:00
Samy Pessé a9f473260c Merge pull request #356 from GitbookIO/feature/includes
Support importing code snippets
2014-07-10 17:59:34 -07:00
Aaron O'Mullan d16577e8bf Add tests for includes 2014-07-10 17:49:50 +02:00
Aaron O'Mullan 15b4053d6b Support code includes for exercises 2014-07-10 17:30:12 +02:00
Aaron O'Mullan 925a9b1388 Support importing code snippets
Allowing to keep code in separate files, which can be cleaner in a
quite a few scenarios
2014-07-11 01:22:07 +02:00
Matt Ellis fc942fdeca Hooks for summary data 2014-07-09 17:17:40 +01:00
Matt Ellis 75a6ecbf52 Highlight active page in summary 2014-07-09 16:06:55 +01:00
Aaron O'Mullan 520045441b Merge pull request #352 from citizenmatt/links_with_fragments
Convert links with fragments from md to html
2014-07-08 21:45:01 +02:00
Matt Ellis 00c3e966d3 Convert links with fragments from md to html 2014-07-08 16:25:39 +01:00
Samy Pessé 8b6ebe86b8 Merge pull request #348 from rlmv/anchors_readme
Add anchor plugin to README
2014-07-06 17:12:57 +02:00
Bo Marchman d5bd3453e1 add heading anchors plugin to readme 2014-07-02 23:49:07 -04:00
Bo Marchman ddacbbe73b update readme with custom links 2014-07-02 23:40:57 -04:00
Bo Marchman f7d52f0eff Add custom link capability
Users can add custom links at the top of the table of contents by
adding a links.custom object to book.json. Issue #304
2014-07-02 23:38:14 -04:00
Robert Marchman 39c50640ea pass 'rawPath' page path to plugins 2014-06-24 12:33:19 -04:00
Samy Pessé 16128c7e60 Bump version to 0.5.6 2014-06-24 12:35:13 +02:00
Samy Pessé 8b6a80cffb Fix error when chapters list is empty
Fix GitbookIO/gitbook.io#101 and GitbookIO/gitbook.io#102
2014-06-24 12:34:29 +02:00
Aaron O'Mullan 86f8a9d8fb Remove useless (and bad) sort on progress
Fixes bad ordering of chapters on gitbook.io
2014-06-20 03:40:47 -07:00
Aaron O'Mullan 790dfd601e Add csharp language highlight mapping
Fixes #327
2014-06-18 11:26:50 -07:00
Aaron O'Mullan 3426428142 Bump version to 0.5.5 2014-06-18 00:25:23 -07:00
Aaron O'Mullan 6c5c8e6eb7 Fix LANGS.md parsing
And cleanup Summary parsing
2014-06-17 16:18:08 -07:00
Aaron O'Mullan 3aefcaea73 Bump version to 0.5.4 2014-06-17 10:56:45 -07:00
Aaron O'Mullan 04c025774d Improve robustness of link utility functions
Fixes #321, fixes #323
2014-06-17 10:56:13 -07:00
Aaron O'Mullan 80aac7f581 Support --verbose flag, fixes #325 2014-06-17 10:46:56 -07:00
Samy Pessé 266f7ca73d Add infos about debugging 2014-06-17 18:45:44 +02:00
Shaform 6bbefad24e Merge remote-tracking branch 'upstream/master' into ref_links 2014-06-17 22:08:46 +08:00
Aaron O'Mullan d6eb8e4c60 Support URLs in "github" config
Fixes GitbookIO/gitbook.io#90
2014-06-16 18:52:36 -07:00
Aaron O'Mullan c87edb155a Better string slicing in parse.git.githubID() 2014-06-16 17:48:18 -07:00
Samy Pessé ef0468ad5d Fix #310: improve display of long title in header 2014-06-16 14:03:28 +02:00
Samy Pessé f03153eb0c Remove page break between articles in ebook
Add title for exercise solutions sections
2014-06-16 13:55:07 +02:00
Samy Pessé 3d8b6e550a Merge pull request #319 from GitbookIO/enchancement/custom_intro
Enchancement/custom intro
2014-06-16 13:02:38 +02:00
Aaron O'Mullan 4c3dbca5ca Normalize intro node in Summary parsing 2014-06-16 00:26:11 -07:00
Aaron O'Mullan a258feea37 Remove special case in navigation
For intro node
2014-06-16 00:25:59 -07:00
Aaron O'Mullan 3a3332d0b9 Adapt summary tests to new summary parsing
We now insert default README.md (introduction) node in parsing the
SUMMARY.md logic
2014-06-16 00:25:33 -07:00
Aaron O'Mullan 4259283f32 Refactor Summary rendering
Introduction is no longer an edge case
2014-06-16 00:09:48 -07:00
Aaron O'Mullan 243d977cd6 Add test for level regarding #318 2014-06-15 23:36:40 -07:00
Aaron O'Mullan 94bbbecedf Support custom intro node, fixes #318 2014-06-15 23:30:43 -07:00
Aaron O'Mullan f49eab42a9 Fix test for #318 2014-06-15 23:29:24 -07:00
Aaron O'Mullan ce6b2bc47d Add extra navigation tests for #318 2014-06-15 23:19:28 -07:00
Aaron O'Mullan 3245d7e430 Drop Travis tests for Node 0.8 2014-06-15 22:49:15 -07:00
Aaron O'Mullan 6ee17c32ae Bump version to 0.5.3 2014-06-15 22:39:18 -07:00
Aaron O'Mullan bf7ffe6d4c Skip extra files and folders in copy phase of generation 2014-06-15 22:37:15 -07:00
Aaron O'Mullan ec7bc6b347 Add link to gitbook.io in readme 2014-06-15 22:36:51 -07:00
Aaron O'Mullan b425db0979 Allow external links in summary, fixes #300 2014-06-08 12:31:52 -07:00
Samy Pessé 30c6d1c9de Remove useless log 2014-06-08 02:21:05 +02:00
Samy Pessé cee1d90fc6 Bump version to 0.5.2 2014-06-08 01:09:51 +02:00
Samy Pessé 522342667c Fix font size for mono font on pdf output 2014-06-08 00:27:18 +02:00
Samy Pessé d1c1277bb9 Fix cover picture for multilangs book convertion to ebook 2014-06-08 00:11:50 +02:00
Aaron O'Mullan 9a66f56c79 Bump version to 0.5.1 2014-06-07 11:42:37 -07:00
Samy Pessé 087ca28ca2 Fix style for main languages index page 2014-06-07 16:30:11 +02:00
Samy Pessé 3d5281ff3a Fix GitbookIO/gitbook.io#69: copy cover files at multi-langs root 2014-06-07 16:27:40 +02:00
Samy Pessé f62cf340c5 Fix title and description for pages in website 2014-06-07 16:04:03 +02:00
Samy Pessé 7e12bd3588 Don't use cdn for ace 2014-06-07 16:02:02 +02:00
Samy Pessé 4dbdb95ebe Show quiz inside ebook 2014-06-06 22:20:02 +02:00
Samy Pessé 2c5ddbcd8f Use base style for ebook instead of bootstrap 2014-06-06 21:47:59 +02:00
Samy Pessé be4fd74f90 Improve navigation links design 2014-06-06 20:06:03 +02:00
Samy Pessé 57491e3a8b Improve meta tags for books 2014-06-06 20:00:38 +02:00
Samy Pessé f7a442d297 Improve font sizes and spacing on content 2014-06-06 19:33:41 +02:00
Samy Pessé cfebdc6f6b Fix #296: fix static links on windows 2014-06-06 18:37:35 +02:00
Samy Pessé 65319e8fd6 Bump version to 0.5.0 2014-06-03 22:30:42 +02:00
Samy Pessé 55db44a3b4 Fix #289: center images on ebook 2014-06-03 22:20:51 +02:00
Samy Pessé 13b6045300 Font Merriweather 600 doesn't exists 2014-06-03 20:45:55 +02:00
Samy Pessé b7ff879c31 Remove fonts Anonymous Pro and EB Garamond 2014-06-03 20:43:47 +02:00
Samy Pessé 57ade87fe1 Fix #275: fix emphasized font path 2014-06-03 20:30:04 +02:00
Samy Pessé 907e9ea5a7 Improve font on title
Set sans-serif as default
2014-06-03 20:14:44 +02:00
Samy Pessé 215488dc45 Improve design (more flat) 2014-06-03 18:43:13 +02:00
Samy Pessé a195b3eac2 Improve less files organisation 2014-06-03 18:11:03 +02:00
Samy Pessé 77c6f0e967 Merge pull request #291 from bebraw/book.js
Allow book.js to be used in addition to book.json
2014-06-03 17:20:26 +02:00
Juho Vepsalainen f0e18afec1 In case there's no config file, do not fail 2014-06-03 17:59:26 +03:00
Juho Vepsalainen b6d11d88b7 Allow book.js to be used in addition to book.json
Now it's possible to comment configuration properly and do some dynamic
things if needed.

Closes #287.
2014-06-03 17:42:30 +03:00
Samy Pessé c803270af8 Add option pdf.pageNumber
Fix GitbookIO/editor#38
2014-06-03 16:24:35 +02:00
Samy Pessé 5d51263a58 Remove mixpanel as a default addon 2014-06-03 15:29:15 +02:00
Samy Pessé 7e30720b2c Merge pull request #292 from bebraw/typofix
Fix build success message typo
2014-06-03 15:07:29 +02:00
Juho Vepsalainen 771c5e8b68 Fix build success message typo 2014-06-03 15:58:22 +03:00
Samy Pessé 8f53afab6b Fix #286: fix doc about formats 2014-06-02 20:12:56 +02:00
Samy Pessé 0ad0403d41 Merge pull request #283 from GitbookIO/feature/pdfoptions
Add more options for PDF
2014-06-02 18:22:07 +02:00
Samy Pessé 2515c1dd73 Remove useless command "gitbook ebook" 2014-06-02 18:17:02 +02:00
Samy Pessé 7dfcd102dd Fix calcul of output format for ebook 2014-06-02 18:16:44 +02:00
Samy Pessé a91245d575 Add options paperSize and margin for pdf 2014-06-02 17:57:47 +02:00
Samy Pessé 5f207f5e14 Add options pdf.toc and pdf.fontSize 2014-06-02 17:49:05 +02:00
Samy Pessé 718692de3b Langs index page now use direct link to html file 2014-06-02 14:49:40 +02:00
Samy Pessé 9856a51255 Fix #282: stop generation of langs index for page format 2014-06-02 14:13:52 +02:00
Samy Pessé 58eaaf5514 Fix error when plugin don't extend book 2014-06-02 12:51:22 +02:00
Samy Pessé c0ae0138f8 Improve documentation about book.json 2014-06-02 11:41:16 +02:00
Samy Pessé b1b9dc5b0a Fix error during generation 2014-06-02 11:37:25 +02:00
Samy Pessé f85c5a6498 Add error message when generator is invalid
Fixes #276, #277
2014-06-02 11:32:09 +02:00
Aaron O'Mullan 32eafefc45 Bump version to 0.4.8 2014-05-29 16:36:56 -07:00
Aaron O'Mullan 336999a34e Set default pdf font size to 12 2014-05-29 15:57:56 -07:00
Samy Pessé 1bf5f3b984 Force paper format to A4 fro pdf 2014-05-30 00:33:35 +02:00
Samy Pessé c76d070237 Merge pull request #274 from emmanuel-keller/patch-1
Adding a new plugin (Piwik Open Analytics plugin)
2014-05-30 00:11:38 +02:00
Emmanuel Keller 8c7da1351f Adding a new plugin.
I Just published a first version of the Piwik Open Analytics plugin, on both GIT and NPM.
2014-05-29 23:31:38 +02:00
Samy Pessé 34588c6092 Add margin on pdf output 2014-05-29 18:53:08 +02:00
Samy Pessé 9f00bf8060 Add toc at the end of pdf 2014-05-29 18:33:05 +02:00
Samy Pessé f4a17b182f Improve ebook generation (toc, ...) 2014-05-29 18:28:09 +02:00
Samy Pessé 5c3b345fa6 Generate valid first level table of content for ebook 2014-05-29 17:28:18 +02:00
Samy Pessé 46321fffd9 Use ebook-convert for pdf generation 2014-05-29 17:07:03 +02:00
Shaform 1f4cf33dd0 Improve code syntax for links assignment 2014-05-28 06:57:50 +08:00
Shaform 7274aa6940 fix links error 2014-05-27 22:24:23 +08:00
Shaform 125e804cd5 Add reference links support
This commit resolves #184
2014-05-27 17:24:47 +08:00
Aaron O'Mullan 89ba17de84 Bump version to 0.4.7 2014-05-26 12:14:32 -07:00
Aaron O'Mullan 115fba837c Merge pull request #265 from GitbookIO/feature/levels
More than two section level in summary
2014-05-26 11:27:27 -07:00
Samy Pessé 4df51546b2 Remove command log in ebook convert 2014-05-26 18:02:32 +02:00
Samy Pessé f68aaf7ff9 Fix cover option for ebook 2014-05-26 18:02:09 +02:00
Samy Pessé e3d1746ba3 Fix use of cover.jpg in ebook 2014-05-26 17:58:08 +02:00
Samy Pessé a0d5646034 Adapt navigation parsing to third and more levels in summary 2014-05-26 17:42:05 +02:00
Samy Pessé 2f8af5f136 Improve design of summary for deep articles 2014-05-26 17:33:10 +02:00
Samy Pessé 8b7abbd6f4 Render articles of level > 2 in summary 2014-05-26 17:31:35 +02:00
Samy Pessé f228f646eb Remove useless method parseArticle 2014-05-26 17:23:19 +02:00
Samy Pessé 45891d80c7 Parse more than two level in summary 2014-05-26 17:21:23 +02:00
Samy Pessé ac900aa37f Merge pull request #263 from jpoesen/patch-1
Minor typo, grammar and style corrections.
2014-05-26 10:44:25 +02:00
Joeri Poesen 422cbed796 Minor typo, grammar and style corrections. 2014-05-26 08:13:35 +02:00
Samy Pessé 38cbbe46aa Fix cache manifest generation 2014-05-25 20:47:57 +02:00
Aaron O'Mullan c1b57a387b Bump version to 0.4.6 2014-05-23 16:35:44 -07:00
Samy Pessé aaa9ae8bb7 Fix loading button display on navigation 2014-05-24 01:32:39 +02:00
Samy Pessé 6340a64cff Fix #235: search after navigation to another page 2014-05-23 22:28:36 +02:00
Samy Pessé 96bcfa4e20 Fix #218: keep state of font settings 2014-05-23 22:20:36 +02:00
Samy Pessé af0f56b26b Change position of menu action in header 2014-05-23 21:49:11 +02:00
Samy Pessé aed5befa48 Fix display of divider in lateral menu 2014-05-23 21:48:04 +02:00
Samy Pessé 8e37da672d Minor css improvements 2014-05-23 21:43:47 +02:00
Samy Pessé c0f68c45e2 Fix #249: fix links.toAbsolute on windows 2014-05-23 21:10:58 +02:00
Samy Pessé 47fdd73791 Fix cache manifest in the html tag
Serve command disable cache
2014-05-23 17:45:46 +02:00
Samy Pessé 7c0b88cf2e Plugins can extend html 2014-05-23 17:00:37 +02:00
Samy Pessé bf21633b6c Support multi-languages book in json format 2014-05-23 16:35:34 +02:00
Samy Pessé ad9b1fd6f7 Fix order of progress for level superior to x.9
Related to GitbookIO/gitbook.io#23
2014-05-21 23:31:57 +02:00
Samy Pessé d245895085 Add link to documentation 2014-05-21 20:22:28 +02:00
Samy Pessé c7439d12f7 Add livereload as default plugins only for serve 2014-05-21 17:34:36 +02:00
Samy Pessé 8d6923ce2c Merge pull request #234 from davidagraf/livereload
Livereload
2014-05-21 17:17:08 +02:00
David Graf b21fb24a82 gitbook-plugin-livereload dependency to npm 2014-05-21 16:35:55 +02:00
David Graf e7be132194 Merge branch 'master' into livereload 2014-05-21 16:24:07 +02:00
Samy Pessé 0e1717f4bb Improve grammar (thanks to @theoutlander ) 2014-05-21 10:46:26 +02:00
Aaron O'Mullan 276dbe29c7 Bump version to 0.4.5 2014-05-20 23:29:39 -07:00
Aaron O'Mullan 21fd5924b8 Fix generate failing on README parsing
Failed if no title or description could be extracted
2014-05-20 23:29:06 -07:00
Aaron O'Mullan 443def6cfd Bump version to 0.4.4 2014-05-20 22:59:26 -07:00
Samy Pessé 75464574d7 For multi-langs, run build one by one 2014-05-21 00:09:40 +02:00
Samy Pessé 86f05c68c5 Improve parsing of readme (extraction of title and description as plain text and not markdown) 2014-05-20 23:45:35 +02:00
Samy Pessé 8dd407eaa8 Fix merge of output for multi-languages books 2014-05-20 23:31:22 +02:00
Samy Pessé ea7ad10e8a Add support for multi-languages books in JSON format 2014-05-20 23:21:12 +02:00
Samy Pessé 62ec695dc8 Extract title and description from readme before switching to multi-languages handling 2014-05-20 23:07:41 +02:00
Samy Pessé ca37ac73a9 Add more infos about gitbook.io 2014-05-20 14:40:22 +02:00
Samy Pessé 96edd50c8f Add norm for small cover 2014-05-20 01:23:49 +02:00
Samy Pessé 3993c1e35a Change advised ratio for cover 2014-05-19 21:47:41 +02:00
Aaron O'Mullan 5298558925 Bump version to 0.4.3 2014-05-18 02:25:53 -07:00
Samy Pessé c6ba147917 Print stack only when env DEBUG is set 2014-05-17 20:35:41 +02:00
Samy Pessé 7efecea3d6 Exit process with -1 when error occurs 2014-05-17 20:35:13 +02:00
Aaron O'Mullan a73fed3ebd Merge pull request #240 from ajschumacher/patch-1
typo: "blockin" to "block in"
2014-05-16 09:06:15 -07:00
Aaron Schumacher 50ef7bcd23 typo: "blockin" to "block in" 2014-05-16 12:02:06 -04:00
Aaron O'Mullan 82e422cb89 Fix issue of disabling issues and contribute
Improve robustness of template display conditions
2014-05-15 21:35:09 -07:00
Aaron O'Mullan dab46c779d Allow github support to be disabled in book.json
Fixes #238
2014-05-15 21:24:28 -07:00
David Graf 7c65adc9b2 disable cache manifest import if cache is disabled 2014-05-15 12:07:51 +02:00
David Graf 9b96ef9bae added livereload dependency 2014-05-15 11:41:59 +02:00
David Graf e97d1941dc Introducing livereload server 2014-05-15 08:09:02 +02:00
David Graf 0b0ac46e34 Introducing option to disable cache manifest generation 2014-05-15 08:07:24 +02:00
David Graf 622bbcb8ea ignore vim swap files 2014-05-15 07:43:59 +02:00
Samy Pessé 58a5245d21 Merge pull request #233 from embreinhardt/master
Add LESS variable for sidebar full-width breakpoint
2014-05-14 20:10:02 +02:00
Erika Reinhardt 612f9a6dc7 Add LESS variable for sidebar full-width breakpoint 2014-05-14 11:01:57 -07:00
Samy Pessé 90d4dff263 Merge pull request #232 from embreinhardt/master
Make font-settings.html indentation consistent
2014-05-14 10:35:32 +02:00
Erika Reinhardt 0f38385c7d Make font-settings.html indentation consistent
[Minor] Was mix of tabs and spaces, which messed with text edit display
2014-05-14 01:25:18 -07:00
Samy Pessé 2b50616251 Merge pull request #231 from embreinhardt/master
Add HTML classes to make plugins easier to write
2014-05-14 10:20:42 +02:00
Erika Reinhardt 5b7f37f0d4 Add HTML classes to make plugins easier to write 2014-05-14 01:14:21 -07:00
Aaron O'Mullan 6ca8e26741 Merge pull request #229 from weitzman/patch-1
Fix recent typo in README.MD
2014-05-12 14:04:52 -07:00
Moshe Weitzman a3ada05598 Fix recent typo in README.MD 2014-05-12 16:18:50 -04:00
Samy Pessé 42eb11aaff Add infos about cover 2014-05-11 16:47:30 +02:00
Samy Pessé b581859afd Merge pull request #223 from cef62/fix-windows-paths
Force forward slashes on SUMMARY.md path for articles
2014-05-08 22:54:40 +02:00
Matteo Ronchi 2e22fae52a Force forward slashes on SUMMARY.md paths
this prevent windows user to generate invalid path on unix OS
Reference to issue #39 on gitbook-editor
2014-05-08 22:46:53 +02:00
Aaron O'Mullan 603ac8b91d Merge pull request #221 from frodsan/patch-1
Don't show divider even if githubId is present.
2014-05-08 09:58:06 -07:00
Francesco Rodríguez 5faa4841ca Don't show divider even if githubId is present. 2014-05-08 13:40:15 -03:00
Samy Pessé 7416b826e0 Fix #218: Add settings for client theme (font family, size, theme) 2014-05-08 13:16:30 +02:00
Aaron O'Mullan 82afc34755 Merge pull request #219 from BjoernSchotte/feature/doc-theme
added documentation for theme option
2014-05-07 23:08:53 -07:00
Björn Schotte da39631a5a added documentation for theme option 2014-05-08 07:57:33 +02:00
Aaron O'Mullan fc8685a7c1 Merge pull request #216 from ianmcburnie/accessibility
Accessibility: added aria-labels to header
2014-05-06 12:34:43 -07:00
Ian McBurnie 5e0204a980 Accessibility: added aria-labels to header
Feel free to change any of the label text that I have chosen :-)
2014-05-06 11:27:54 -07:00
Samy Pessé 6bb0f33f39 Fix #211: read config file before cleaning output folder 2014-05-06 12:08:27 +02:00
Aaron O'Mullan ed4fd565b2 Merge pull request #213 from ianmcburnie/accessibility
Accessibility: aria-label added to navigation links
2014-05-05 22:37:21 -07:00
Ian McBurnie 79cff28abd Accessibility: aria-label added to navigation links
Current behavior: Screenreader just reads ‘link’ when landing on the
previous and next navigation links, giving the user no indication of
what the link does or where it goes. New Behaviour: Screenreader reads
“Previous page: {page title}” and “Next page: {page title}”
respectively.
2014-05-05 22:29:22 -07:00
Samy Pessé 27329239f7 Fix #208: correct name for edit/contribute link in doc 2014-05-05 17:55:19 +02:00
Samy Pessé 9de86fc0e4 Add tests for book generation 2014-05-05 15:25:15 +02:00
Samy Pessé 7fa7826372 Merge pull request #203 from GitbookIO/improve/generate
Improve generate's reliability, fixes #202
2014-05-04 22:37:42 +02:00
Aaron O'Mullan 96ecfd098b Improve generate's reliability, fixes #202
This also improves speed on multi language books
2014-05-04 12:53:24 -07:00
Samy Pessé f7fe976c7e Fix #197: use URI.js for calculation of relative url
Use bower for client dependencies
2014-05-04 15:15:18 +02:00
Samy Pessé 756629b91d Add bower dependencies 2014-05-04 15:03:47 +02:00
Samy Pessé e640d124d4 Add bower vendors to gitignore 2014-05-04 14:58:45 +02:00
Samy Pessé 7f41466297 Remove vendors directory 2014-05-04 14:58:01 +02:00
Samy Pessé 57dfc062d2 Create CHANGES.md 2014-05-04 13:09:27 +02:00
Aaron O'Mullan 799815d85a Bump version to 0.4.2 2014-05-01 16:17:05 -07:00
Samy Pessé 2946246834 Fix #191: remove log for changes in files 2014-05-01 18:55:45 +02:00
Samy Pessé 6d276d1e79 Add option to remove home link 2014-05-01 18:53:49 +02:00
Samy Pessé 6a3a369b3e Add options to remove sharing links 2014-05-01 18:37:30 +02:00
Samy Pessé 5d8afa2135 Merge pull request #196 from mrpotes/new-plugins
New plugins
2014-05-01 18:33:30 +02:00
Samy Pessé ab3e6aa8ce Fix font-size for titles in markdown content 2014-05-01 18:29:42 +02:00
James Phillpotts 822092736e New plugins 2014-05-01 17:00:38 +01:00
Samy Pessé 7497acd2e3 Center navigation button on mobile on start page 2014-05-01 17:37:38 +02:00
Samy Pessé ae137885b8 Fix book content padding on mobile 2014-05-01 17:27:03 +02:00
Samy Pessé b964cc7009 Fix #162: hide watch/star buttons on mobile 2014-05-01 17:16:09 +02:00
Samy Pessé c2ea126c5f Fix #182: Replace all book body when page changes 2014-05-01 14:05:14 +02:00
Samy Pessé b668dba479 Update gaze version to 0.5.1 2014-05-01 13:26:50 +02:00
Samy Pessé 2cae5a0310 Secure .book position 2014-05-01 13:26:19 +02:00
Samy Pessé b6a0f3ff67 Fix #164: use position absolute instead of fixed 2014-04-30 17:01:25 +02:00
Samy Pessé fa00b52fb5 Fix #127: add configuration for changing links in sidebar 2014-04-30 16:46:24 +02:00
Samy Pessé 2999d90907 Merge pull request #188 from snipe/feature/json-doc
Added quotes for JSON example, per #127
2014-04-30 12:48:28 +02:00
snipe b6696bcad2 Added quotes for JSON example, per #127 2014-04-30 06:46:28 -04:00
Samy Pessé 728c87c525 Merge pull request #187 from snipe/feature/typo-fixes
Fixed typos
2014-04-30 12:05:12 +02:00
snipe ace394ee2d Fixed typos 2014-04-30 05:28:18 -04:00
Samy Pessé 076ee98f64 Fix #186: Plugins that don't have assets should be skipped 2014-04-30 11:15:01 +02:00
Samy Pessé 2e472654ca Fix error when calling hooks in site generation 2014-04-30 10:54:45 +02:00
Aaron O'Mullan d46bd14678 0.4.1 2014-04-29 10:23:54 -07:00
Samy Pessé b3e5b3d106 Fix #183: normalize hooks and transformation of page (content, progress, ..° 2014-04-29 17:45:54 +02:00
Samy Pessé b830ef5dca Merge pull request #179 from erixtekila/master
Update README.md
2014-04-29 08:23:33 +02:00
Eric Priou 45326c4ad2 Update README.md 2014-04-29 03:45:03 +02:00
Aaron O'Mullan 603b61e8c8 Bump version to 0.4.0 2014-04-28 13:26:40 -07:00
Samy Pessé efb066c8e3 Update doc about how to configure gitbook 2014-04-28 20:45:10 +02:00
Samy Pessé c30db427b1 Remove some options from command line (moved to book.json) 2014-04-28 20:33:25 +02:00
Samy Pessé 23056fc85d Use a global configuration file for a book (default to book.json) 2014-04-28 20:29:36 +02:00
Samy Pessé 5f1bfc0280 Fix #163: Move logic of git infos extraction to lib 2014-04-28 20:16:30 +02:00
Samy Pessé b715901f92 Add hooks "page:before" and "page:after" 2014-04-28 19:56:40 +02:00
Samy Pessé 38fea06cf9 Use hook to allow plugins to edit page content during generation (Fixes #176) 2014-04-28 17:21:06 +02:00
Aaron O'Mullan 4481b5f556 Bump version to 0.3.2 2014-04-27 13:46:20 -07:00
Samy Pessé 0e0d051f7c Merge pull request #173 from erixtekila/master
Update README.md
2014-04-27 22:26:56 +02:00
Eric Priou a1b649a279 Update README.md 2014-04-27 22:24:37 +02:00
Eric Priou e6bc0a0fb7 Update README.md
3rd party plugins done in the weekend
2014-04-27 22:18:09 +02:00
Samy Pessé 93e4016c09 Add link to disqus plugin 2014-04-27 21:55:50 +02:00
Samy Pessé 20c741a248 Fix stupid typo thanks to @erixtekila 2014-04-27 21:21:48 +02:00
Samy Pessé 54f530c7c3 Merge pull request #171 from GitbookIO/feature/offlineCache
Improve pages loading
2014-04-27 18:05:13 +02:00
Samy Pessé 9fdc5da22d Update page when new version of application cache 2014-04-27 17:57:34 +02:00
Samy Pessé 99ce48b146 Add base loading indicator for navigation
#161
2014-04-27 17:36:12 +02:00
Samy Pessé 6a33ad9ef7 Add base cache manifest 2014-04-27 17:14:57 +02:00
Samy Pessé ca94055adf Adapt tests for plugins 2014-04-27 15:45:16 +02:00
Samy Pessé 36a67e4c91 Fix #169: fix resolve of external plugins 2014-04-27 15:41:02 +02:00
Samy Pessé 69431e1bbb Fix #165: replace separator from ":" to "," 2014-04-27 09:14:39 +02:00
Samy Pessé a3fc4ee2b0 Fix display of code element in sepia/night 2014-04-25 18:14:41 +02:00
Samy Pessé e505fd6d54 Improve summary divider for theme sepia and night 2014-04-25 18:12:39 +02:00
Samy Pessé 93a3785e4c Improve highlight theme for sepia and night themes 2014-04-25 18:05:09 +02:00
Samy Pessé a02de84812 Change highlight theme to tomorrow 2014-04-25 17:56:48 +02:00
Samy Pessé c0521f0ec7 Improve display of pre in markdown content 2014-04-25 17:48:31 +02:00
Samy Pessé 83d8c16853 Add file watcher in "gitbook serve" command (Fix #47, #89, #140) 2014-04-25 16:23:13 +02:00
Samy Pessé 47e9506397 Fix #153 and Improve pushState navigation 2014-04-25 15:12:19 +02:00
Samy Pessé b8a3d0e254 Merge pull request #144 from attomos/master
Make quiz easier to click by surround it with label.
2014-04-25 14:29:04 +02:00
Samy Pessé 001d7ec44e Merge pull request #155 from pborreli/patch-1
Fixed typo
2014-04-24 22:44:36 +02:00
Pascal Borreli 5cb0ec447a Fixed typo 2014-04-24 21:43:32 +01:00
Aaron O'Mullan 67e7d77302 Bump version to 0.3.1 2014-04-24 10:45:55 -07:00
Aaron O'Mullan 8cbd8b2b48 Reorder plugin names
Improves #149 and improves GitBookIO/editor#12
2014-04-24 01:38:42 -07:00
Aaron O'Mullan 7c404dbf96 Fix plugin tests 2014-04-24 01:34:35 -07:00
Aaron O'Mullan c4a67b6f2f Require plugin names to contain gitbook-*
Fixes #149, fixes GitBookIO/editor#12
2014-04-24 01:28:04 -07:00
Samy Pessé 3b70347625 Fix #146: complete license 2014-04-24 09:00:15 +02:00
Aaron O'Mullan bb0a7935e9 Merge pull request #141 from frodsan/niceties
Niceties
2014-04-23 11:34:08 -07:00
Nattaphoom Ch 8f4b799d3c Make quiz easier to click by surround it with label. 2014-04-24 01:19:13 +07:00
Francesco Rodriguez 931e0c66c9 Update color themes for highlight.js link. 2014-04-23 12:30:05 -03:00
Francesco Rodriguez 0212084862 Fix typo. 2014-04-23 12:28:44 -03:00
Samy Pessé 9abbabbce3 Merge pull request #138 from Hermanya/patch-1
Add @Hermanya as a contributor
2014-04-22 23:47:13 +02:00
Hermanya ac610487e8 Add @Hermanya as a contributor 2014-04-22 17:45:41 -04:00
Aaron O'Mullan a9a0f89892 Bump version to 0.3.0 2014-04-22 14:05:52 -07:00
Samy Pessé 305f221077 Fix #136: replace links to .md by links to .html
Add more tests for links in page
2014-04-22 17:45:12 +02:00
Samy Pessé 53514f2602 Improve sepia theme sidebar 2014-04-22 14:27:48 +02:00
Samy Pessé 00327778cb Improve font-settings dropdown design 2014-04-22 14:12:53 +02:00
Samy Pessé 37fadec787 Merge branch 'master' of https://github.com/Hermanya/gitbook into Hermanya-master 2014-04-22 14:02:19 +02:00
Samy Pessé ada11d0b59 Add section in readme about plugins 2014-04-22 12:51:10 +02:00
Aaron O'Mullan 4c90fdb7b2 Merge pull request #123 from GitbookIO/feature/plugins
Fix #65: Plugins Architecture
2014-04-21 14:26:09 -07:00
Samy Pessé 98c133df3c Change plugins separator to "," 2014-04-21 23:23:53 +02:00
Samy Pessé f86c27b090 Add option --pluginsConfig 2014-04-21 22:58:51 +02:00
Samy Pessé b5b8ed72a5 Update default addons 2014-04-21 22:39:23 +02:00
Samy Pessé 5beff86548 Change js interface for plugins and add configuration 2014-04-21 22:20:41 +02:00
Samy Pessé dd395edae1 Use mathjax plugin version 0.0.2 2014-04-21 16:30:02 +02:00
Aaron O'Mullan d1c1d7b75b Bump version to 0.2.4 2014-04-20 16:41:09 -07:00
Samy Pessé 4a380e9279 Fix #36: add mathjax plugin as default 2014-04-20 15:20:21 +02:00
Samy Pessé 878c105def Use complete assets folder for plugins 2014-04-20 02:04:15 +02:00
Samy Pessé 74d628676b Add option to change templates from plugin 2014-04-20 00:10:46 +02:00
Samy Pessé 6fdd98ec3a Trigger event on document when ready 2014-04-19 20:39:58 +02:00
Samy Pessé 2ed1be3533 Add global js interface for plugins and remove mixpanel 2014-04-19 20:10:03 +02:00
Samy Pessé 0ac04e1584 Add call for hooks "init" and "finish" 2014-04-19 19:50:32 +02:00
Herman Starikov 2a38d33d8a Font settings, closes #102 2014-04-19 13:46:14 -04:00
Samy Pessé fb14caf5b3 Add resources to site build 2014-04-19 19:31:02 +02:00
Samy Pessé cf51772f54 Add command line option "plugins" 2014-04-19 18:00:24 +02:00
Samy Pessé cc8516df83 Load plugins during generation 2014-04-19 17:57:40 +02:00
Samy Pessé c6a624bc6b Add method to load a list of plugins from generator options 2014-04-19 17:54:15 +02:00
Samy Pessé 8be8b825ee Add base loading of default addons
Add mixpanel as default addon
2014-04-19 17:28:44 +02:00
Samy Pessé 56eb4a2897 Add base plugin object and test validation of plugin 2014-04-19 15:41:29 +02:00
Samy Pessé 7a461eaa61 Remove theme readme
Add semver dependency
2014-04-19 14:40:46 +02:00
Samy Pessé fd64c05809 Fix #118: fix single page generation when file from summary doesn't exists 2014-04-18 23:42:02 +02:00
Aaron O'Mullan 6bce93d893 Bump version to 0.2.3 2014-04-18 11:53:18 -07:00
Aaron O'Mullan c9db068227 Refactor navigation generation to be functional
This makes it a lot less error prone and far more robust. As well as a
lot easier to understand
2014-04-18 11:49:55 -07:00
Samy Pessé 8a6d36ac4d Improve stability of mixpanel tracking 2014-04-18 20:42:18 +02:00
Samy Pessé 64622c5945 Load css before content 2014-04-18 20:19:45 +02:00
Samy Pessé 837813edb0 Add warning about theme 2014-04-18 20:16:21 +02:00
Aaron O'Mullan 0d9d62f1a9 Merge pull request #117 from GitbookIO/fix/99
Fix #99
2014-04-18 10:17:20 -07:00
Samy Pessé f7e9abf984 Fix quiz interractivity 2014-04-18 19:10:13 +02:00
Samy Pessé dd0579b60d Update tests for relative images 2014-04-18 17:23:33 +02:00
Samy Pessé b5bb953e47 Fix image path calcul 2014-04-18 17:15:03 +02:00
Samy Pessé ef4a8ea1b6 Fix #116: update url before updating html content 2014-04-18 15:49:53 +02:00
Samy Pessé 49cde96ee7 Add contributors to package.json and change homepage 2014-04-18 15:00:40 +02:00
Samy Pessé 627be20e48 Add editor and twitter links in the readme 2014-04-18 14:48:03 +02:00
Samy Pessé e45bb84b02 Fix navigation on chrome for iOS: disable pushState 2014-04-18 13:09:16 +02:00
Aaron O'Mullan 4e8876c725 Update README.md 2014-04-17 16:39:06 -07:00
Aaron O'Mullan 6d5be15ec9 Bump version to 0.2.2 2014-04-17 15:31:57 -07:00
Samy Pessé 1a8db646f2 Improve styling for pdf and ebook 2014-04-17 12:15:28 +02:00
Samy Pessé d3aba2c906 Fix state update after navigation 2014-04-17 11:48:04 +02:00
Samy Pessé 457a83282f Improve style for pdf and ebook 2014-04-17 11:27:21 +02:00
Samy Pessé 48e94c937d Remove useless caracter from page format 2014-04-17 11:17:40 +02:00
Samy Pessé 6e613e9f71 Fix #107: Render all the page in single page format 2014-04-17 11:16:18 +02:00
Aaron O'Mullan b698d43d7d Bump version to 0.2.1 2014-04-17 01:10:11 -07:00
Aaron O'Mullan a36b9a6088 Normalize code language before highlighting 2014-04-17 01:09:26 -07:00
Samy Pessé 20acd89c8a Merge pull request #104 from GitbookIO/fix/auto_highlighting
Disable automatic highlighting
2014-04-17 09:24:56 +02:00
Aaron O'Mullan 7bed9a257d Merge pull request #105 from ptagell/master
Removed duplicate line of readme
2014-04-16 14:38:49 -07:00
Paul Tagell 19c83aa5a8 Removed duplicate line of readme 2014-04-17 07:35:28 +10:00
Aaron O'Mullan 52610d7d61 Disable automatic highlighting
Fallback to no highlighting rather that potentially funky highlighting
2014-04-16 13:15:35 -07:00
Aaron O'Mullan 9e4b393b7a In parse/page remove global marked settings
Highlighter settings were global, moved them to the render function
(where they should have been)
2014-04-16 13:07:35 -07:00
Samy Pessé a0ae34a3b7 Fix #100: fix section test isQuiz 2014-04-16 17:16:18 +02:00
Samy Pessé 413dc5d004 Add more test for quiz (related to #100) 2014-04-16 17:15:45 +02:00
Aaron O'Mullan c9eb27bfe7 Do not pass SUMMARY.md to generator, fixes #93
We want to parse SUMMARY.md but not generate a file from it, thus it
should be removed from the list of files to be processed by the
generator
2014-04-16 00:18:35 -07:00
Aaron O'Mullan b78505c290 Ignore .gitignore file by default in fs.list
Partial fix of #93
2014-04-16 00:11:54 -07:00
Samy Pessé 95f9ae83d0 Fix #97: keep scroll position during page changement 2014-04-15 17:42:46 +02:00
Samy Pessé 9304289315 Fix progress display when page change 2014-04-14 23:00:40 +02:00
Samy Pessé 1b726ca293 Update preview 2014-04-14 22:35:10 +02:00
Samy Pessé 656ca18929 Improve languages list design 2014-04-14 21:29:26 +02:00
Aaron O'Mullan b8cacaee00 Bump to version 0.2.0 2014-04-14 11:48:29 -07:00
Samy Pessé f349012f0f Add analytics on page changement 2014-04-14 20:33:45 +02:00
Samy Pessé ddd49509ce Improve design of header buttons 2014-04-14 20:21:57 +02:00
Samy Pessé 28257e1ce7 Fix search with pusState navigation 2014-04-14 20:15:04 +02:00
Samy Pessé 24d8e15ee2 Fix scrolling on new design 2014-04-14 20:08:55 +02:00
Samy Pessé d6d9223ea1 Revert "Fix ebook and pdf generator"
This reverts commit f43e630528.
2014-04-14 20:00:15 +02:00
Samy Pessé 05f1eed9ce Fix #91: Extract defaults title and description from README.md 2014-04-14 19:48:12 +02:00
Samy Pessé c0ca055bf4 Add readme parsing for extracting title and description 2014-04-14 19:21:43 +02:00
Samy Pessé f43e630528 Fix ebook and pdf generator 2014-04-14 19:05:23 +02:00
Samy Pessé e4fa8aaca7 Fix generate.file method 2014-04-14 18:56:20 +02:00
Samy Pessé 1b147d3e30 Merge branch 'master' of https://github.com/tcorral/gitbook into tcorral-master
Conflicts:
	theme/javascript/app.js
2014-04-14 16:44:11 +02:00
Samy Pessé 5848f5db51 Merge pull request #88 from GitbookIO/feature/clarity
Feature/clarity
2014-04-14 16:36:12 +02:00
Samy Pessé 9f1ba8483b Merge head styles so that ace stays stable 2014-04-14 16:34:19 +02:00
Samy Pessé 6da48764e8 Fix header interractive actions: buttons and github 2014-04-14 16:29:02 +02:00
Samy Pessé 8c4cfed609 Add complete refresh of head and body on page navigation 2014-04-14 16:16:34 +02:00
Samy Pessé 1ff7e88cea Focs and reset scroll on page body 2014-04-14 15:43:11 +02:00
Samy Pessé c3ba975d6c Improve quiz sections design 2014-04-14 15:37:13 +02:00
Samy Pessé 8c02e949fc Fix exercises binding when page changed
Add base binding for quiz
2014-04-14 12:43:45 +02:00
Samy Pessé 56e1803b34 Fix title update with pushState navigation 2014-04-14 12:32:22 +02:00
Samy Pessé c511037f46 New languages page 2014-04-14 01:04:58 +02:00
Samy Pessé 730fe982f5 Add @Nijikokun as a contributor 2014-04-14 00:49:25 +02:00
Samy Pessé ca71a1c9e6 Fix regression on github as an option 2014-04-14 00:49:09 +02:00
Samy Pessé 01bc283638 Add fonts locally 2014-04-14 00:40:02 +02:00
Samy Pessé 4ca719b108 Fix fonts path 2014-04-14 00:23:38 +02:00
Samy Pessé 889183ccc9 Improve search input design 2014-04-14 00:17:16 +02:00
Samy Pessé 4a6ae8d4e0 Switch to 4spaces indentations for less files 2014-04-14 00:15:35 +02:00
Samy Pessé b77debae24 Made progress bar static 2014-04-14 00:11:51 +02:00
Samy Pessé 9ffa462111 Add base from clarity theme from @Nijikokun 2014-04-14 00:06:58 +02:00
Samy Pessé 1bbef54015 Remove logs from core module 2014-04-13 23:55:13 +02:00
Samy Pessé 3c7cae6262 Move more build logic to the core generation module 2014-04-13 23:53:34 +02:00
tcorral 646a4513e3 Allow scroll in computers that put the navigation over scroll control. When the document is ready it will check the difference between the body-inner and the page-wrapper width to move the layer only this width allowing the user to scroll. 2014-04-13 04:24:07 +02:00
tcorral d9e34fc671 Allow scroll in computers that put the navigation over scroll control. When the document is ready it will check the difference between the body-inner and the page-wrapper width to move the layer only this width allowing the user to scroll. 2014-04-13 03:09:50 +02:00
tcorral 2242963258 Allow scroll in computers that put the navigation over scroll control. When the document is ready it will check the difference between the body-inner and the page-wrapper width to move the layer only this width allowing the user to scroll. 2014-04-13 03:07:44 +02:00
Aaron O'Mullan 555c0d63ee Add gitbook init command, fixes #67 2014-04-12 12:27:13 -07:00
Aaron O'Mullan fb05609e09 Refactor binary's buildCommand
Be more “commander-like”
2014-04-12 11:58:55 -07:00
Aaron O'Mullan 78cb9a56ba Merge pull request #85 from GitbookIO/pr/63
Pr/63
2014-04-12 01:51:06 -07:00
Aaron O'Mullan 6173fb76ad Refactor, document, improve section type detection
Especially for quiz types
2014-04-12 01:50:48 -07:00
Aaron O'Mullan ca25511d7a Fixup page lexing in test/page 2014-04-12 01:34:36 -07:00
James Phillpotts b07681a16a Quiz with GFM checkbox lists 2014-04-12 01:26:03 -07:00
James Phillpotts f6595f5111 Tabular quiz 2014-04-12 01:25:07 -07:00
Samy Pessé ab27725b99 Update AUTHORS.md 2014-04-11 23:31:39 +02:00
Samy Pessé 32b1be3dee Create AUTHORS.md 2014-04-11 23:30:40 +02:00
Samy Pessé d715b5b154 Merge pull request #84 from Tim-Zhang/master
Fix title problem when repo url doesn't have .git suffix
2014-04-11 23:15:30 +02:00
TimZhang 177ca32b9b Fix title problem when repo url doesn't have .git suffix 2014-04-11 18:04:01 +08:00
Aaron O'Mullan 892ec04f52 Merge pull request #78 from mrpotes/mocha-windows
Fix URL creation on windows
2014-04-10 11:44:33 -07:00
James Phillpotts 8f457a752e Use OS-agnostic path generation for images too 2014-04-10 11:00:52 +01:00
James Phillpotts 435a4b8c99 Use API from node 0.8 2014-04-10 10:45:54 +01:00
Samy Pessé 02d8272c74 Merge pull request #77 from GitbookIO/improve/sections_lexing
Improve/sections lexing
2014-04-10 11:34:56 +02:00
Aaron O'Mullan e54b808093 Improve section detection, fixes #68 2014-04-10 02:32:37 -07:00
James Phillpotts fb7653bd14 Fix URL creation on windows 2014-04-10 10:31:32 +01:00
Aaron O'Mullan 04774df372 Add better tests for ambiguous section detection 2014-04-10 02:27:42 -07:00
Aaron O'Mullan 619ded93ad Improve language normalization
Check for null before converting to lower case
2014-04-10 02:21:54 -07:00
Samy Pessé 2e85380cd8 Merge pull request #62 from oliverh855/master
Changes the default font from Helvetica to Open Sans
2014-04-09 11:13:56 +02:00
Oliver Hoffmann 241ad7cb0e Removes unused font-family appLight 2014-04-09 11:09:31 +02:00
Oliver Hoffmann 0171c32996 Removes helvetica font from repository 2014-04-09 11:08:39 +02:00
Oliver Hoffmann d275bd516a Changes the default font from Helvetica to Open Sans. See #14 2014-04-09 10:55:52 +02:00
Samy Pessé 99594791e0 Merge Optional github 2014-04-09 08:23:11 +02:00
Samy Pessé 1b432288f0 Merge branch 'optional-github' of https://github.com/mrpotes/gitbook into mrpotes-optional-github 2014-04-09 08:17:37 +02:00
Aaron O'Mullan 2cc23b7e34 Bump version to 0.1.3 2014-04-08 17:03:13 -07:00
Aaron O'Mullan 61b6848a95 Uglify output JS theme/assets/app.js 2014-04-08 17:01:43 -07:00
Aaron O'Mullan 9265b0185a Add context code support to exercises (optional)
Partial #52, fixes #49, fixes #46
2014-04-08 16:58:04 -07:00
Aaron O'Mullan 392573a990 Add lexing support for content code in exercises
#52, #49, #46
2014-04-08 15:01:12 -07:00
Aaron O'Mullan 554d6a6170 Fix URL rewriting error on empty URLs
Fixes #54, fixes #59
2014-04-08 14:47:36 -07:00
James Phillpotts fa2f82d52f Tidy up use of github, and make error more descriptive 2014-04-08 10:00:10 +01:00
Samy Pessé 2182baa2e9 Merge pull request #51 from calmdev/fix/gh-enterprise
Fixes --githubHost option for use with Github Enterprise.
2014-04-07 10:42:55 -07:00
Levi Lewis 7fe189907e Fixes --githubHost option for use with Github Enterprise. 2014-04-07 13:11:44 -04:00
James Phillpotts 58a90886da Whoops, missed a couple of extra uses of githubId 2014-04-07 10:51:41 +01:00
James Phillpotts 80794997a4 Make use of github optional 2014-04-07 10:38:06 +01:00
349 changed files with 35443 additions and 53064 deletions
+10
View File
@@ -0,0 +1,10 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+1
View File
@@ -0,0 +1 @@
theme/**/*
+19
View File
@@ -0,0 +1,19 @@
{
"rules": {
"indent": [ 2, 4 ],
"quotes": [ 2, "single" ],
"linebreak-style": [ 2, "unix" ],
"semi": [ 2, "always" ],
"no-unused-vars": [ 2, {
"vars": "all",
"args": "none"
} ],
"spaced-comment": [ 2, "always" ]
},
"env": {
"node": true,
"mocha": true,
"browser": true
},
"extends": "eslint:recommended"
}
+3
View File
@@ -23,3 +23,6 @@ build/Release
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
# vim swapfile
*.swp
+6 -3
View File
@@ -1,5 +1,8 @@
sudo: false
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.8"
- "stable"
- "4.1"
- "0.12"
before_install:
- npm install svgexport -g
+63
View File
@@ -0,0 +1,63 @@
Authors
=======
Also see https://github.com/GitbookIO/gitbook/graphs/contributors.
Names below are ordered by first contribution.
Author
------
- Samy Pessé <samypesse@gmail.com> (@SamyPesse)
- Aaron O'Mullan <aaron.omullan@gmail.com> (@AaronO)
Contributors
------------
- Nijiko Yonskai (@Nijikokun)
- Herman Starikov (@Hermanya)
Translators
------------
- German
- Winnie (@winniehell)
- Italian
- Giulio Bonanome (@gbonanome)
- Russian
- Andrey Akinshin (@AndreyAkinshin)
- Norwegian
- Knut Melvær (@kmelve)
- Persian (Farsi)
- Mohammad Hossein Mojtahedi (@mhm5000)
- Polish
- Łukasz Szeremeta (@lszeremeta)
- Portuguese
- Ryan O'Mullan (@RyanOM)
- Spanish
- Ryan O'Mullan (@RyanOM)
- Simplifiled Chinese
- Hu Hao (@howiehu)
- Traditional Chinese
- Hu Hao (@howiehu)
- French
- Samy Pessé (@SamyPesse)
- Romanian
- Iancu Aurel (@awrelll)
- Finnish
- Tommi Savikko (@savikko)
- Japanese
- Iancu Aurel (@awrelll)
- Korean
- Iancu Aurel (@awrelll)
- SangYeob Yu (@deminoth)
- Vietnamese
- Hong Nguyen (@nghong)
- Hebrew
- @a-moses
- Ukrainian
- @Karnaukhov
- Czech
- @mjanda
- Swedish
- Jacob Burenstam (@buren)
+318
View File
@@ -0,0 +1,318 @@
# Release notes
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.6.6
- Fix custom CSS that are generated by plugins for PDF output
## 2.6.5
- Fix support for plugins generating custom stylesheets (`styles-less` and `styles-sass`)
- Fix glossary terms being replaced in script (ex: math)
## 2.6.4
- Fix regression introduced by `2.6.3` of single HTML tags in markdown
## 2.6.3
- Fix parsing bug with inline HTML in Markdown
## 2.6.2
- Fix `gitbook.state.bookRoot`, `gitbook.state.root` now has a trailing slash
- Update nunjucks to 2.2.0
## 2.6.1
- Use CamelCase for `gitbook.state.innerLanguage`
## 2.6.0
- Close sidebar after clicking a link on mobile
- Add root for multilingual books: `gitbook.state.bookRoot`
- Fix color of h6 headings
- Fix bottom margin of lists and blockquotes
- Add Swedish translation (`sv`)
- Add Czech translation (`cs`)
- Fix locale names for `zh-hans` and `jp`
- Update plugin `search` to fix crashes
- Aceept case-incensitive structure files (README, GLOSSARY, etc)
## 2.5.2
- Fix custom stylesheets for ebook generation
- Trigger event `start` before `page.change`
## 2.5.1
- Fix calcul of `gitbook.state.root` when serving HTML index as `/`
## 2.5.0
- Font settings, sharing and search are externalized as default plugins
- Plugins can define a configuration schema in the manifest, this schema will be used to validate configuration during build
- New Node.js API for plugin: `book.formatString(type, content)`
- New client side API for website plugins: `gitbook.toolbar.createButton(opts)`
- Better header/footer for PDF, CSS wil be inlined to easily style the header/footer
- Cleaner table of contents for ebooks
- Support for RTL in ebook's table of contents
- Better colors for mobi (links and code blocks)
- Fix installation of plugins when using a pre-release
- Fix support for pre-releases
- Update asciidoc parser to remove git dependency
- Fix templating in imported content
- Fix querystring in image urls
- Normalize heading IDs like GitHub
- Use Arial as default font for PDFs
- Add `root`, `chapterTitle` and `filepath` to `gitbook.state` JS API
## 2.4.3
- Add ukrainian translation (`uk`)
- Add `book.json` configuration for maximum size of search index
- Improve reliability of summary parser
## 2.4.2
- Default plugins should not be installed by `gitbook install`
- Limit search index size to avoid crash during generation
- Fix code highlighting for html without language specified
- Fix warning message for gitbook version when building a multilingual book
## 2.4.1
- Fix disabling of default plugins, ex: `-highlight`
## 2.4.0
- Fix page being updated when user wants to open a link in a new tab
- Plugins can now replaced default code highlighter
- Add semantic information for screen readers (web version)
- Content references accept absolute paths, resolved to book folder
- Improve overall reliability
## 2.3.3
- Fix bug in SUMMARY parsing preventing multiple entries without filenames
## 2.3.2
- Fix blocks (like maths) in Asciidoc
- Fix error when checking gitbook version
## 2.3.1
- Fix black font color for ebooks (mobi, pdf and epub)
- Fix ISO code for korean language
- Fix korean translation
- Fix syntax highlighting for asciidoc
- Fix inline html escaping in markdown
- Add warning for file outside SUMMARY
- Force SUMMARY entries to be unique by filename
## 2.3.0
- Fix nunjucks issue with multiple `{% raw %}` blocks
- Fix crash when git conref failed
- Fix crash when failed to download remote image (better error message)
- Fix flicking effect when changing page (big UX improvement)
- Add Hebrew translation (`he`)
- Add utility method `book.config.get` for plugins
- Hooks `page:before` and `page` are no longer deprecated
- Remove webfonts to make website lighter
- Make glossary's order case insensitive
## 2.2.0
- Fix direction in code blocks (always LTR)
- Add options `chapterMark` and `pageBreaksBefore` for PDF
- Update code highlighting library
- `book.json` accessible as `config` in templating syntax
- Add Vietnamese translation (`vi`)
## 2.1.0
- Fix error in calcul of `levels` in table of contents, error introduced a few versions ago
- Add optional `styles/print.css` to replace `print.css` used in ebook
## 2.0.4
- Fix `{% raw %}`, got confused with "fake" variable declarations
- Fix title of language chooser
- Fix the X-UA-Compatible meta tag
- Move style sheets to the <head> section
## 2.0.3
- Fix `gitbook init` for SUMMARY with empty entries
- Fix escaping of code blocks in markdown
## 2.0.2
- Fix relative links in windows
- Improve watcher in serve command (switch to chokidar)
- Add Romanian translation (`ro`)
- Add Finish translation (`fi`)
- Add Japanese translation (`jp`)
- Add Korean translation (`kr`)
## 2.0.1
- Improve error logging (display file, line and column)
- Add back support for `options.originalInput`
- Don't process math in markdown parser (delegated to `mathjax` plugin)
- Fix some cases of code blocks escaping
- Fix i18n for introduction title in json format
- Fix reload when book configuration is updated
- Fix backslashes in url when building on windows
## 2.0.0
- Fix page title of introduction
- Ignore codeblocks when replacing glossary terms
- Improve Unit Tests
- Fix scrolling position in website when preparing page
## 2.0.0-beta.5
- Fix progress order in json format
## 2.0.0-beta.4
- Fix default generator for use programmatically
- Add option "author" for html meta tags
- Fix links normalization (content and hash)
## 2.0.0-beta.3
- Fix odd cases with code blocks escaping
## 2.0.0-beta.2
- Fix definition of entry point title using SUMMARY.md
## 2.0.0-beta.1
- Fix windows incompatibility
- Add support for rtl (enabled by default for `ar` and `fa`)
- Escape code blocks in markdown parser
- Add Persian/Farsi translation (`fa`)
- Add Arabic translation (`ar`)
- Add Bengali translation (`bn`)
- Provide generator name in template context
## 2.0.0-alpha.9
- Fix links in sidebar
- Fix normalization of html link (README to index)
- Fix html snippets escaping
## 2.0.0-alpha.8
- Improve locale detection for i18n
- Fix chapter name for Glossary in pdf
- Don't escape html in glossary items
- Fix generation of multilingual book as ebook
- Add "post" block attribute to post-process
## 2.0.0-alpha.7
- Fix display of glossary in ebook formats
- Add default footer and header to pdf
- Fix generation of json format compatible with 1.x.x
- Add Simplifiled Chinese and Traditional Chinese translations
## 2.0.0-alpha.6
- Add es and pt translations
- Fix replacement of glossary terms
## 2.0.0-alpha.5
- Fix copy of files/covers
- Add back `finish:before` hook
## 2.0.0-alpha.4
- Fix copy of cover for multilingal books
## 2.0.0-alpha.3
- Norwegian translation
- Load plugins from book in priority
## 2.0.0-alpha.3
- Fix init command
- Update parsers to fix spaces in summary (`gitbook-parsers@0.3.1`)
## 2.0.0-alpha.1
- Externalize parsing into `gitbook-parsers` module
- Supports AsciiDoc and reStructuredText
- Hooks for page (`page:*`) are now deprecated, plugins should extend filters and blocks instead
- Hooks `summary` and `glossary` (after and before) have been removed
- Exercises and Quizzes are no longer parsed in the markdown parser
- Support for more markdown extensions: `.markdown`, `.mdown`
- Templates are rendered with nunjucks instead of swig, syntax is almost compatible, there is some changes with contexts and filters. `{{ super() }}` should be use instead of `{% parent %}`
- Clean output folder on build without removing `.git` and `.svn`
- MathJAX is no longer a default plugin
- SVG images are converted to PNG during generation of ebooks
- i18n in website and ebook (ru, it, de, fr)
- New templating syntax
- Content references (both internal and external)
- Glossary terms are handled during generation (also in ebook format)
## 1.5.0
- Fix `serve` command, broken by `1.4.2`
- Add nicer `dark` theme :)
## 1.4.2
- Force `process.exit` after builds, to prevent (possibly) lingering plugins
## 1.4.1
- Fix command 'install' without arguments
## 1.4.0
- Add command `gitbook install` to install plugins from book.json
- `package.json` is no longer necessary
## 1.3.4
- Add glossary to ebooks
- Fix autocover with new hook "finish:before"
- Add X-UA-Compatible meta tag for IE
## 1.3.3
- Fix parsing of lexed content using the client library
## 1.3.2
- ePub files are now passing validation from epubcheck
- Fix replacement of multiple glossary terms in a single sentence
- Fix on windows deep relative links
- Fix search indexer
## 1.3.1
- Fix error with links in markdown
## 1.3.0
- Bundle gitbook parsing library as a client side library in `gitbook.js` and `gitbook.min.js`
## 1.2.0
- Improvements on ebook generation
- Fix incorrect follow of links in ebook generation
- Move Table of Contents at the beginning of the ebook
- Update to last highlight.js (includes Swift)
- Includes of templates and variables (from book.json)
## 1.1.1
- Rewrite quiz logic to be more robust
- Improve integration of glossary
- Improve generation of ebook by using a multiple HTML pages input source
- Fix incorrect page breaks after h1 and h2 divs
- New options to set header and footer in PDF generation
## 1.1.0
- Plugins can now extend the ebook generation (pdf, epub, mobi)
- Update `kramed` to version 0.4.3
## 1.0.3
- Update `mathjax` plugin and MathJAx to version 2.4
- Update `highlight.js` to 8.2.0
## 1.0.2
- Update `mathjax` plugin, fixes issues with inline math rendering (no longer wanted)
## 1.0.1
- New inline math convention (kramdown's), using `$$` rather than `$` as delimiters
- Fix instapaper sharing
- The `exercises` & `quizzes` plugins are now by default
## 1.0.0
- New design
- Support for glossary
- Support for sharing to instapaper
- Support for footnotes
## 0.7.1
- Update `fs-extra` to `0.10.0` (fixes potential race conditions)
## 0.7.0
- Add page break in ebook (pdf, epub, mobi) between chapters/articles
- Start using kramed instead of marked
- Fix display of inline math
- Switch to graceful-fs to fix EMFILE errors
- Add sharing to weibo.com
## 0.6.2
- Support generating a plugin's book info dynamically
- Improve navigation on dark theme
- Improve path normalization when parsing SUMMARY.md
## 0.6.0
- Generate header id the same as github
- Custom links can be added at top of sidebar
- Summary can now be transformed by plugins
- Support importing code snippets
-72
View File
@@ -1,72 +0,0 @@
module.exports = function (grunt) {
var path = require("path");
// Load NPM tasks
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-requirejs');
// Init GRUNT configuraton
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
options: {
compress: true,
yuicompress: true,
optimization: 2
},
files: {
"theme/assets/style.css": "theme/stylesheets/main.less",
"theme/assets/print.css": "theme/stylesheets/print.less"
}
}
},
requirejs: {
compile: {
options: {
name: "app",
baseUrl: "theme/javascript/",
out: "theme/assets/app.js",
preserveLicenseComments: false,
optimize: "none", //"uglify",
include: ["requireLib"],
paths: {
"jQuery": 'vendors/jquery',
"lodash": 'vendors/lodash',
"requireLib": 'vendors/require',
"Mousetrap": 'vendors/mousetrap',
"mixpanel": 'vendors/mixpanel',
"lunr": path.join(__dirname, "node_modules/lunr/lunr")
},
shim: {
'jQuery': {
exports: '$'
},
'lodash': {
exports: '_'
},
'Mousetrap': {
exports: 'Mousetrap'
},
'mixpanel': {
exports: 'mixpanel'
},
'lunr': {
exports: 'lunr'
}
}
}
}
}
});
// Build
grunt.registerTask('build', [
'less',
'requirejs'
]);
grunt.registerTask('default', [
'build'
]);
};
+2 -2
View File
@@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Copyright 2014 FriendCode Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -198,4 +198,4 @@ Apache License
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
+162 -58
View File
@@ -1,9 +1,18 @@
GitBook
=======
[![Build Status](https://travis-ci.org/GitbookIO/gitbook.png?branch=master)](https://travis-ci.org/GitbookIO/gitbook)
[![NPM version](https://badge.fury.io/js/gitbook.svg)](http://badge.fury.io/js/gitbook)
[![Linux Build Status](https://travis-ci.org/GitbookIO/gitbook.png?branch=master)](https://travis-ci.org/GitbookIO/gitbook)
[![Windows Build status](https://ci.appveyor.com/api/projects/status/63nlflxcwmb2pue6?svg=true)](https://ci.appveyor.com/project/GitBook/gitbook)
[![Slack Status](https://slack.gitbook.com/badge.svg)](https://slack.gitbook.com)
GitBook is a command line tool (and Node.js library) for building beautiful programming books and exercises using GitHub/Git and Markdown. You can see an example: [Learn Javascript](http://gitbookio.github.io/javascript/).
GitBook is a command line tool (and Node.js library) for building beautiful books using GitHub/Git and Markdown (or AsciiDoc). Here is an example: [Learn Javascript](https://www.gitbook.com/book/GitBookIO/javascript).
You can publish and host book easily online using [gitbook.com](https://www.gitbook.com), a desktop editor is [also available](https://www.gitbook.com/editor).
Check out the [GitBook Community Slack Channel](https://slack.gitbook.com), Stay updated by following [@GitBookIO](https://twitter.com/GitBookIO) on Twitter or [GitBook](https://www.facebook.com/gitbookcom) on Facebook.
Complete documentation is available at [help.gitbook.com](http://help.gitbook.com/).
![Image](https://raw.github.com/GitbookIO/gitbook/master/preview.png)
@@ -12,51 +21,60 @@ GitBook is a command line tool (and Node.js library) for building beautiful prog
GitBook can be installed from **NPM** using:
```
$ npm install gitbook -g
$ npm install gitbook-cli -g
```
Create the directories and files for a book from its [SUMMARY.md](https://github.com/GitbookIO/gitbook#book-format) file (if existing) using
```
$ gitbook init
```
You can serve a repository as a book using:
```
$ gitbook serve ./repository
$ gitbook serve
```
Or simply build the static website using:
```
$ gitbook build ./repository --output=./outputFolder
$ gitbook build
```
Options for commands `build` and `serve` are:
## Features
```
-t, --title <name> Name of the book to generate, defaults to repo name
-i, --intro <intro> Description of the book to generate
-g, --github <repo_path> ID of github repo like : username/repo
-o, --output <directory> Path to output directory, defaults to ./_book
-f, --format <name> Change generation format, defaults to site, availables are: site, page, pdf, json
-i, --intro <intro> Description of the book to generate
-gh, --githubHost <url> The url of the github host (defaults to https://github.com/)
--theme <path> Path to theme directory
```
* [Output as a website or ebook (pdf, epub, mobi)](http://help.gitbook.com/format/output.html)
* [Multi-Languages](http://help.gitbook.com/format/languages.html)
* [Glossary](http://help.gitbook.com/format/glossary.html)
* [Cover](http://help.gitbook.com/format/cover.html)
* [AsciiDoc Support](http://help.gitbook.com/format/asciidoc.html)
* [Variables and Templating](http://help.gitbook.com/format/templating.html)
* [Content References](http://help.gitbook.com/format/conrefs.html)
* [Plugins](http://help.gitbook.com/format/plugins.html)
* Interractive reader website:
* Search
* Font Settings (Serif, Sans Serif)
* Themes: white, sepia, night
## Output Formats
GitBook can generate your book in the following formats:
* **Static Website**: This is the default format, it generates a complete interactive static website that can be for example hosted on GitHub Pages.
* **PDF**: A complete PDF book with exercise solutions at the end of the book. Generate to this format using: ```gitbook pdf ./myrepo```, you need to have [gitbook-pdf](https://github.com/GitbookIO/gitbook-pdf) installed.
* **eBook**: A complete eBook with exercise solutions at the end of the book. Generate to this format using: ```gitbook ebook ./myrepo```, you need to have [ebook-convert](http://manual.calibre-ebook.com/cli/ebook-convert.html) installed.
* **Single Page**: The book will be stored in a single printable HTML page, this format is used for conversion to PDF or eBook. Generate to this format using: ```gitbook build ./myrepo -f page```.
* **JSON**: This format is used for debugging or extracting metadata from a book. Generate to this format using: ```gitbook build ./myrepo -f json```.
* **Static Website**: This is the default format. It generates a complete interactive static website that can be, for example, hosted on GitHub Pages.
* **eBook**: You need to have [ebook-convert](http://manual.calibre-ebook.com/cli/ebook-convert.html) installed. You can specify the eBook filename as the second argument, otherwise `book` will be used.
* Generate a **PDF** using: `gitbook pdf ./myrepo ./mybook.pdf`
* Generate a **ePub** using: `gitbook epub ./myrepo ./mybook.epub`
* Generate a **MOBI** using: `gitbook mobi ./myrepo ./mybook.mobi`
* **JSON**: This format is used for debugging or extracting metadata from a book. Generate this format using: ```gitbook build ./myrepo --format=json```.
## Book Format
A book is a GitHub repository containing at least 2 files: `README.md` and `SUMMARY.md`.
A book is a Git repository containing at least 2 files: `README.md` and `SUMMARY.md`.
#### README.md
As usual, it should contains an introduction for your book. It will be automatically added to the final summary.
Typically, this should be the introduction for your book. It will be automatically added to the final summary.
#### SUMMARY.md
@@ -64,7 +82,7 @@ The `SUMMARY.md` defines your book's structure. It should contain a list of chap
Example:
```
```markdown
# Summary
This is the summary of my book.
@@ -76,44 +94,13 @@ This is the summary of my book.
* [example 1](section2/example1.md)
```
Files that are not included in the `SUMMARY.md` will not be processed by `gitbook`.
#### Exercises
A book can contain interactive exercises (currently only in Javascript but Python and Ruby are coming soon ;) ). An exercise is a code challenge provided to the reader, which is given a code editor to write a solution which is checked against the book author's validation code.
An exercise is defined by 4 simple parts:
* Exercise **Message**/Goals (in markdown/text)
* **Initial** code to show to the user, providing a starting point
* **Solution** code, being a correct solution to the exercise
* **Validation** code that tests the correctness of the user's input
Exercises need to start and finish with a separation bar (```---``` or ```***```). It should contain 3 code elements (**base**, **solution** and **validation**).
---
Define a variable `x` equal to 10.
```js
var x =
```
```js
var x = 10;
```
```js
assert(x == 10);
```
---
Files that are not included in `SUMMARY.md` will not be processed by `gitbook`.
#### Multi-Languages
GitBook supports building books written in multiple languages. Each language should be a sub-directory following the normal GitBook format, and a file named `LANGS.md` should be present at the root of the repository with the following format:
```
```markdown
* [English](en/)
* [French](fr/)
* [Español](es/)
@@ -121,6 +108,123 @@ GitBook supports building books written in multiple languages. Each language sho
You can see a complete example with the [Learn Git](https://github.com/GitbookIO/git) book.
#### Glossary
Allows you to specify terms and their respective definitions to be displayed in the glossary. Based on those terms, `gitbook` will automatically build an index and highlight those terms in pages.
The `GLOSSARY.md` format is very simple :
```markdown
# term
Definition for this term
# Another term
With it's definition, this can contain bold text and all other kinds of inline markup ...
```
#### Variables and Templating
A set of variables can be defined in the `book.json`:
```js
{
"variables": {
"host": "mybook.com"
}
}
```
These variables can be used in the markdown files:
```
The host is {{ book.host }}
```
You can also use condition with these variables:
```
{% if book.host == "mybook.com" %}
{% else %}
{% endif %}
```
Variables of `book.json` are available in the `book` namespace. You can also access informations about the `file` itself and the `gitbook` version:
```
My file is {{ file.path }}
Modified at {{ file.mtime }}
Book built with GitBook {{ gitbook.version }}
```
#### Content References
You can use "content references," or conrefs, when writing books or documentation using GitBook.
Include a file from the same book:
```
{% include "./test.md" %}
```
or from a git repository (with a specific revision):
```
{% include "git+https://github.com/GitbookIO/documentation.git/README.md#1.0.1" %}
```
Includes can be used with variables (see [Variables and Templating](#variables-and-templating)):
```
{% include book.ref_doc_readme %}
```
#### Ignoring files & folders
GitBook will read the `.gitignore`, `.bookignore` and `.ignore` files to get a list of files and folders to skip. (The format inside those files, follows the same convention as `.gitignore`)
GitBook will read the `.gitignore`, `.bookignore` and `.ignore` files to get a list of files and folders to skip. (The format inside those files follows the same convention as `.gitignore`).
Best practices for the `.gitignore` is to ignore build files from **node.js** (`node_modules`, ...) and build files from GitBook: `_book`, `*.epub`, `*.mobi` and `*.pdf` ([Download GitBook.gitignore](https://github.com/github/gitignore/blob/master/GitBook.gitignore)).
#### Cover
A cover image can be set by creating a file: **/cover.jpg**.
The best resolution is **1800x2360**. The generation of the cover can be done automatically using the plugin [autocover](https://github.com/GitbookIO/plugin-autocover).
A small version of the cover can also be set by creating a file: **/cover_small.jpg**.
#### AsciiDoc
Since version 2.0.0, AsciiDoc can be used instead of Markdown, simply replace the `.md` by the `.adoc` extension. Chapters in the summary are detected from an ordered list in the `SUMMARY.adoc`.
## Publish your book
The platform [GitBook.com](https://www.gitbook.com/) is like an "Heroku for books": you can create a book on it (public, paid, or private) and update it using **git push**.
## Plugins
Plugins can be used to extend your book's functionality. Read [GitbookIO/plugin](https://github.com/GitbookIO/plugin) for more information about how to build a plugin for GitBook.
Plugins needed to build a book can be installed using: `gitbook install ./`. You can find plugins at [plugins.gitbook.com](http://plugins.gitbook.com).
## Debugging
You can use the options `--log=debug` and `--debug` to get better error messages (with stack trace). For example:
```
$ gitbook build ./ --log=debug --debug
```
#### How to use the latest commit from GitBook in gitbook-cli
To use the latest commit from `GitBook/gitbook` with `gitbook-cli`:
```
$ git clone https://github.com/GitbookIO/gitbook.git ./gitbook
$ gitbook versions:link ./gitbook
```
Now `gitbook-cli` will be using the `./gitbook` folder.
You can uninstall it using: `gitbook versions:uninstall latest`.
+29
View File
@@ -0,0 +1,29 @@
# Fix line endings in Windows. (runs before repo cloning)
init:
- git config --global core.autocrlf input
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "0.12"
- nodejs_version: "4.1"
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install svgexport
- npm install svgexport -g
# install modules
- npm install
# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test
# Don't actually build.
build: off
-113
View File
@@ -1,113 +0,0 @@
var path = require('path');
var Q = require('q');
var _ = require('lodash');
var tmp = require('tmp');
var utils = require('./utils');
var generate = require("../lib/generate");
var parse = require("../lib/parse");
var fs = require('../lib/generate/fs');
var generators = require("../lib/generate").generators;
var buildFunc = function(dir, options) {
dir = dir || process.cwd();
outputDir = options.output || path.join(dir, '_book');
console.log('Starting build ...');
// Get repo's URL
return utils.gitURL(dir)
.then(function(url) {
// Get ID of repo
return utils.githubID(url);
}, function(err) {
return null;
})
.then(function(repoID) {
var githubID = options.github || repoID;
if(!githubID) {
throw new Error('Needs a githubID (username/repo). Either set repo origin to a github repo or use the -g flag');
}
var parts = githubID.split('/', 2);
var user = parts[0], repo = parts[1];
var title = options.title || utils.titleCase(repo);
return generate.folder(
_.extend(options.options || {}, {
input: dir,
output: outputDir,
title: title,
description: options.intro,
github: githubID,
generator: options.format,
theme: options.theme
})
);
})
.then(function(output) {
console.log("Successfuly built !");
return output;
}, utils.logError);
};
var buildFiles = function(dir, outputFile, options, masterOptions) {
var ext = masterOptions.extension;
outputFile = outputFile || path.resolve(dir, "book."+ext);
Q.nfcall(tmp.dir)
.then(function(tmpDir) {
return buildFunc(
dir,
_.extend(options, {
output: tmpDir,
format: masterOptions.format,
options: masterOptions.options
})
)
.then(function(_options) {
var copyPDF = function(lang) {
var _outputFile = outputFile;
var _tmpDir = tmpDir;
if (lang) {
_outputFile = _outputFile.slice(0, -path.extname(_outputFile).length)+"_"+lang+path.extname(_outputFile);
_tmpDir = path.join(_tmpDir, lang);
}
console.log("Generating in", _outputFile);
return fs.copy(
path.join(_tmpDir, "index."+ext),
_outputFile
);
};
// Multi-langs book
return Q()
.then(function() {
if (_options.langsSummary) {
console.log("Generating for all the languages");
return Q.all(
_.map(_options.langsSummary.list, function(lang) {
return copyPDF(lang.lang);
})
);
} else {
return copyPDF();
}
})
.then(function() {
return fs.remove(tmpDir);
})
.fail(utils.logError);
});
})
};
module.exports = {
folder: buildFunc,
files: buildFiles
};
+4 -85
View File
@@ -1,88 +1,7 @@
#! /usr/bin/env node
var Q = require('q');
var _ = require('lodash');
var path = require('path');
var prog = require('commander');
var color = require('bash-color');
var pkg = require('../package.json');
var generators = require("../lib/generate").generators;
var fs = require('../lib/generate/fs');
var utils = require('./utils');
var build = require('./build');
// General options
prog
.version(pkg.version);
var buildCommand = function(command, action) {
return command
.option('-o, --output <directory>', 'Path to output directory, defaults to ./_book')
.option('-f, --format <name>', 'Change generation format, defaults to site, availables are: '+_.keys(generators).join(", "))
.option('-t, --title <name>', 'Name of the book to generate, defaults to repo name')
.option('-i, --intro <intro>', 'Description of the book to generate')
.option('-g, --github <repo_path>', 'ID of github repo like : username/repo')
.option('-gh, --githubHost <url>', 'The url of the github host (defaults to https://github.com/')
.option('--theme <path>', 'Path to theme directory')
.action(action);
}
buildCommand(prog
.command('build [source_dir]')
.description('Build a gitbook from a directory'), build.folder);
buildCommand(prog
.command('serve [source_dir]')
.description('Build then serve a gitbook from a directory')
.option('-p, --port <port>', 'Port for server to listen on', 4000),
function(dir, options) {
build.folder(dir, options)
.then(function(_options) {
console.log();
console.log('Starting server ...');
return utils.serveDir(_options.output, options.port)
.fail(utils.logError);
})
.then(function() {
console.log('Serving book on http://localhost:'+options.port);
console.log();
console.log('Press CTRL+C to quit ...');
});
});
buildCommand(prog
.command('pdf [source_dir] [output_file]')
.description('Build a gitbook as a PDF')
.option('-pf, --paperformat <format>', 'PDF paper format (default is A4): "5in*7.5in", "10cm*20cm", "A4", "Letter"'),
function(dir, output, options) {
build.files(dir, output, options, {
extension: "pdf",
format: "pdf",
options: {
paperformat: options.paperformat
}
});
});
buildCommand(prog
.command('ebook [source_dir] [output_file]')
.description('Build a gitbook as a eBook')
.option('-c, --cover <path>', 'Cover image, default is cover.png if exists'),
function(dir, output, options) {
var ext = output ? path.extname(output) : "epub";
build.files(dir, output, options, {
extension: ext,
format: "ebook",
options: {
extension: ext,
cover: options.cover
}
});
});
// Parse and fallback to help if no args
if(_.isEmpty(prog.parse(process.argv).args) && process.argv.length === 2) {
prog.help();
}
console.log(color.red('You need to install "gitbook-cli" to have access to the gitbook command anywhere on your system.'));
console.log(color.red('If you\'ve installed this package globally, you need to uninstall it.'));
console.log(color.red('>> Run "npm uninstall -g gitbook" then "npm install -g gitbook-cli"'));
-98
View File
@@ -1,98 +0,0 @@
var Q = require('q');
var _ = require('lodash');
var http = require('http');
var send = require('send');
var url = require('url');
var cp = require('child_process');
// Get the remote of a given repo
function gitURL(path) {
var d = Q.defer();
cp.exec("git config --get remote.origin.url", {
cwd: path,
env: process.env,
}, function(err, stdout, stderr) {
if(err) {
return d.reject(err);
}
return d.resolve(stdout);
});
return d.promise
.then(function(output) {
return output.replace(/(\r\n|\n|\r)/gm, "");
});
}
// Poorman's parsing
// Parse a git URL to a github ID : username/reponame
function githubID(_url) {
// Detect HTTPS repos
var parsed = url.parse(_url);
if(parsed.protocol === 'https:' && parsed.host === 'github.com') {
return parsed.path.slice(1, -4);
}
// Detect SSH repos
if(_url.indexOf('git@') === 0) {
return _url.split(':', 2)[1].slice(0, -4);
}
// None found
return null;
}
function titleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
function serveDir(dir, port) {
var d = Q.defer();
var server = http.createServer(function(req, res){
// Render error
function error(err) {
res.statusCode = err.status || 500;
res.end(err.message);
}
// Redirect to directory's index.html
function redirect() {
res.statusCode = 301;
res.setHeader('Location', req.url + '/');
res.end('Redirecting to ' + req.url + '/');
}
// Send file
send(req, url.parse(req.url).pathname)
.root(dir)
.on('error', error)
.on('directory', redirect)
.pipe(res);
}).listen(port);
d.resolve(server);
return d.promise;
}
function logError(err) {
console.log(err.stack || err.message || err);
return Q.reject(err);
};
// Exports
module.exports = {
gitURL: gitURL,
githubID: githubID,
titleCase: titleCase,
serveDir: serveDir,
logError: logError
};
+47
View File
@@ -0,0 +1,47 @@
var _ = require('lodash');
var gulp = require('gulp');
var gutil = require('gulp-util');
var less = require('gulp-less');
var rename = require('gulp-rename');
var minifyCSS = require('gulp-minify-css');
var browserify = require('browserify');
var mergeStream = require('merge-stream');
var source = require('vinyl-source-stream');
gulp.task('css', function() {
var merged = mergeStream();
_.each({
'ebook.less': 'ebook/ebook.css',
'pdf.less': 'ebook/pdf.css',
'mobi.less': 'ebook/mobi.css',
'epub.less': 'ebook/epub.css',
'website.less': 'website/style.css'
}, function(out, input) {
gutil.log('compiling', input, 'into', out);
merged.add(gulp.src('theme/stylesheets/'+input)
.pipe(less())
.pipe(minifyCSS())
.pipe(rename(out))
.pipe(gulp.dest('theme/assets/')));
});
return merged;
});
gulp.task('js', function() {
return browserify('./theme/javascript/index.js')
.bundle()
.pipe(source('app.js'))
.pipe(gulp.dest('./theme/assets/website'));
});
gulp.task('assets', function() {
return gulp.src('./node_modules/font-awesome/fonts/*')
.pipe(gulp.dest('theme/assets/website/fonts/fontawesome/'));
});
gulp.task('default', ['css', 'js', 'assets'], function() {
});
+11
View File
@@ -0,0 +1,11 @@
var _ = require('lodash');
module.exports = {
// Return non-parsed html
// since blocks are by default non-parsable, a simple identity method works fine
html: _.identity,
// Highlight a code block
// This block can be extent by plugins
code: _.identity
};
+823
View File
@@ -0,0 +1,823 @@
var Q = require('q');
var _ = require('lodash');
var path = require('path');
var parsers = require('gitbook-parsers');
var fs = require('./utils/fs');
var parseNavigation = require('./utils/navigation');
var parseProgress = require('./utils/progress');
var pageUtil = require('./utils/page');
var pathUtil = require('./utils/path');
var links = require('./utils/links');
var i18n = require('./utils/i18n');
var logger = require('./utils/logger');
var Configuration = require('./configuration');
var TemplateEngine = require('./template');
var PluginsList = require('./pluginslist');
var generators = require('./generators');
var Book = function(root, context, parent) {
this.context = _.defaults(context || {}, {
// Extend book configuration
config: {},
// Log function
log: function(msg) {
process.stdout.write(msg);
},
// Log level
logLevel: 'info'
});
// Log
this.log = logger(this.context.log, this.context.logLevel);
// Root folder of the book
this.root = path.resolve(root);
// Parent book
this.parent = parent;
// Configuration
this.config = new Configuration(this, this.context.config);
Object.defineProperty(this, 'options', {
get: function () {
return this.config.options;
}
});
// Template
this.template = new TemplateEngine(this);
// Summary
this.summary = {};
this.navigation = [];
// Glossary
this.glossary = [];
// Langs
this.langs = [];
// Sub-books
this.books = [];
// Files in the book
this.files = [];
// List of plugins
this.plugins = new PluginsList(this);
// Structure files
this.summaryFile = null;
this.glossaryFile = null;
this.readmeFile = null;
this.langsFile = null;
// Bind methods
_.bindAll(this);
};
// Return string representation
Book.prototype.toString = function() {
return '[Book '+this.root+']';
};
// Initialize and parse the book: config, summary, glossary
Book.prototype.parse = function() {
var that = this;
var multilingual = false;
return this.parseConfig()
.then(function() {
return that.parsePlugins();
})
.then(function() {
return that.parseLangs()
.then(function() {
multilingual = that.langs.length > 0;
if (multilingual) that.log.info.ln('Parsing multilingual book, with', that.langs.length, 'languages');
// Sub-books that inherit from the current book configuration
that.books = _.map(that.langs, function(lang) {
that.log.info.ln('Preparing language book', lang.lang);
return new Book(
path.join(that.root, lang.path),
_.merge({}, that.context, {
config: _.extend({}, that.options, {
'output': path.join(that.options.output, lang.lang),
'language': lang.lang
})
}),
that
);
});
});
})
.then(function() {
if (multilingual) return;
return that.listAllFiles();
})
.then(function() {
if (multilingual) return;
return that.parseReadme();
})
.then(function() {
if (multilingual) return;
return that.parseSummary();
})
.then(function() {
if (multilingual) return;
return that.parseGlossary();
})
.then(function() {
// Init sub-books
return _.reduce(that.books, function(prev, book) {
return prev.then(function() {
return book.parse();
});
}, Q());
})
.thenResolve(this);
};
// Generate the output
Book.prototype.generate = function(generator) {
var that = this;
that.options.generator = generator || that.options.generator;
that.log.info.ln('start generation with', that.options.generator, 'generator');
return Q()
// Clean output folder
.then(function() {
that.log.info('clean', that.options.generator, 'generator');
return fs.clean(that.options.output)
.progress(function(p) {
that.log.debug.ln('remove', p.file, '('+p.i+'/'+p.count+')');
})
.then(function() {
that.log.info.ok();
});
})
// Create generator
.then(function() {
var Generator = generators[generator];
if (!Generator) throw 'Generator \''+that.options.generator+'\' doesn\'t exist';
generator = new Generator(that);
return generator.prepare();
})
// Transform configuration
.then(function() {
return that.callHook('config', that.config.dump())
.then(function(newConfig) {
that.config.replace(newConfig);
});
})
// Generate content
.then(function() {
if (that.isMultilingual()) {
return that.generateMultiLingual(generator);
} else {
// Separate list of files into the different operations needed
var ops = _.groupBy(that.files, function(file) {
if (file[file.length -1] == '/') {
return 'directories';
} else if (_.contains(parsers.extensions, path.extname(file)) && that.navigation[file]) {
return 'content';
} else {
return 'files';
}
});
return Q()
// First, let's create folder
.then(function() {
return _.reduce(ops.directories || [], function(prev, folder) {
return prev.then(function() {
that.log.debug.ln('transferring folder', folder);
return Q(generator.transferFolder(folder));
});
}, Q());
})
// Then, let's copy other files
.then(function() {
return Q.all(_.map(ops.files || [], function(file) {
that.log.debug.ln('transferring file', file);
return Q(generator.transferFile(file));
}));
})
// Finally let's generate content
.then(function() {
var nFiles = (ops.content || []).length;
return _.reduce(ops.content || [], function(prev, file, i) {
return prev.then(function() {
var p = ((i*100)/nFiles).toFixed(0)+'%';
that.log.debug.ln('processing', file, p);
return Q(generator.convertFile(file))
.fail(function(err) {
// Transform error message to signal file
throw that.normError(err, {
fileName: file
});
});
});
}, Q());
});
}
})
// Finish generation
.then(function() {
return that.callHook('finish:before');
})
.then(function() {
return generator.finish();
})
.then(function() {
return that.callHook('finish');
})
.then(function() {
that.log.info.ln('generation is finished');
});
};
// Generate the output for a multilingual book
Book.prototype.generateMultiLingual = function() {
var that = this;
return Q()
.then(function() {
// Generate sub-books
return _.reduce(that.books, function(prev, book) {
return prev.then(function() {
return book.generate(that.options.generator);
});
}, Q());
});
};
// Extract files from ebook generated
Book.prototype.generateFile = function(output, options) {
var book = this;
options = _.defaults(options || {}, {
ebookFormat: path.extname(output).slice(1)
});
output = output || path.resolve(book.root, 'book.'+options.ebookFormat);
return fs.tmp.dir()
.then(function(tmpDir) {
book.setOutput(tmpDir);
return book.generate(options.ebookFormat)
.then(function() {
var copyFile = function(lang) {
var _outputFile = output;
var _tmpDir = tmpDir;
if (lang) {
_outputFile = _outputFile.slice(0, -path.extname(_outputFile).length)+'_'+lang+path.extname(_outputFile);
_tmpDir = path.join(_tmpDir, lang);
}
book.log.debug.ln('copy ebook to', _outputFile);
return fs.copy(
path.join(_tmpDir, 'index.'+options.ebookFormat),
_outputFile
);
};
// Multi-langs book
return Q()
.then(function() {
if (book.isMultilingual()) {
return Q.all(
_.map(book.langs, function(lang) {
return copyFile(lang.lang);
})
)
.thenResolve(book.langs.length);
} else {
return copyFile().thenResolve(1);
}
})
.then(function(n) {
book.log.info.ok(n+' file(s) generated');
return fs.remove(tmpDir);
});
});
});
};
// Parse configuration
Book.prototype.parseConfig = function() {
var that = this;
that.log.info('loading book configuration....');
return that.config.load()
.then(function() {
that.log.info.ok();
});
};
// Parse list of plugins
Book.prototype.parsePlugins = function() {
var that = this;
// Load plugins
return that.plugins.load(that.options.plugins)
.then(function() {
if (_.size(that.plugins.failed) > 0) return Q.reject(new Error('Error loading plugins: '+that.plugins.failed.join(',')+'. Run \'gitbook install\' to install plugins from NPM.'));
that.log.info.ok(that.plugins.count()+' plugins loaded');
that.log.debug.ln('normalize plugins list');
});
};
// Parse readme to extract defaults title and description
Book.prototype.parseReadme = function() {
var that = this;
var filename = that.config.getStructure('readme', true);
that.log.debug.ln('start parsing readme:', filename);
return that.findFile(filename)
.then(function(readme) {
if (!readme) throw 'No README file';
if (!_.contains(that.files, readme.path)) throw 'README file is ignored';
that.readmeFile = readme.path;
that._defaultsStructure(that.readmeFile);
that.log.debug.ln('readme located at', that.readmeFile);
return that.template.renderFile(that.readmeFile)
.then(function(content) {
return readme.parser.readme(content)
.fail(function(err) {
throw that.normError(err, {
name: err.name || 'Readme Parse Error',
fileName: that.readmeFile
});
});
});
})
.then(function(readme) {
that.options.title = that.options.title || readme.title;
that.options.description = that.options.description || readme.description;
});
};
// Parse langs to extract list of sub-books
Book.prototype.parseLangs = function() {
var that = this;
var filename = that.config.getStructure('langs', true);
that.log.debug.ln('start parsing languages index:', filename);
return that.findFile(filename)
.then(function(langs) {
if (!langs) return [];
that.langsFile = langs.path;
that._defaultsStructure(that.langsFile);
that.log.debug.ln('languages index located at', that.langsFile);
return that.template.renderFile(that.langsFile)
.then(function(content) {
return langs.parser.langs(content)
.fail(function(err) {
throw that.normError(err, {
name: err.name || 'Langs Parse Error',
fileName: that.langsFile
});
});
});
})
.then(function(langs) {
that.langs = langs;
});
};
// Parse summary to extract list of chapters
Book.prototype.parseSummary = function() {
var that = this;
var filename = that.config.getStructure('summary', true);
that.log.debug.ln('start parsing summary:', filename);
return that.findFile(filename)
.then(function(summary) {
if (!summary) throw 'No SUMMARY file';
// Remove the summary from the list of files to parse
that.summaryFile = summary.path;
that._defaultsStructure(that.summaryFile);
that.files = _.without(that.files, that.summaryFile);
that.log.debug.ln('summary located at', that.summaryFile);
return that.template.renderFile(that.summaryFile)
.then(function(content) {
return summary.parser.summary(content, {
entryPoint: that.readmeFile,
entryPointTitle: that.i18n('SUMMARY_INTRODUCTION'),
files: that.files
})
.fail(function(err) {
throw that.normError(err, {
name: err.name || 'Summary Parse Error',
fileName: that.summaryFile
});
});
});
})
.then(function(summary) {
that.summary = summary;
that.navigation = parseNavigation(that.summary, that.files);
});
};
// Parse glossary to extract terms
Book.prototype.parseGlossary = function() {
var that = this;
var filename = that.config.getStructure('glossary', true);
that.log.debug.ln('start parsing glossary: ', filename);
return that.findFile(filename)
.then(function(glossary) {
if (!glossary) return [];
// Remove the glossary from the list of files to parse
that.glossaryFile = glossary.path;
that._defaultsStructure(that.glossaryFile);
that.files = _.without(that.files, that.glossaryFile);
that.log.debug.ln('glossary located at', that.glossaryFile);
return that.template.renderFile(that.glossaryFile)
.then(function(content) {
return glossary.parser.glossary(content)
.fail(function(err) {
throw that.normError(err, {
name: err.name || 'Glossary Parse Error',
fileName: that.glossaryFile
});
});
});
})
.then(function(glossary) {
that.glossary = glossary;
});
};
// Parse a page
Book.prototype.parsePage = function(filename, options) {
var that = this, page = {};
options = _.defaults(options || {}, {
// Transform svg images
convertImages: false,
// Interpolate before templating
interpolateTemplate: _.identity,
// Interpolate after templating
interpolateContent: _.identity
});
var interpolate = function(fn) {
return Q(fn(page))
.then(function(_page) {
page = _page || page;
});
};
that.log.debug.ln('start parsing file', filename);
var extension = path.extname(filename);
var filetype = parsers.get(extension);
if (!filetype) return Q.reject(new Error('Can\'t parse file: '+filename));
// Type of parser used
page.type = filetype.name;
// Path relative to book
page.path = filename;
// Path absolute in the system
page.rawPath = path.resolve(that.root, filename);
// Progress in the book
page.progress = parseProgress(that.navigation, filename);
that.log.debug.ln('render template', filename);
// Read file content
return that.readFile(page.path)
.then(function(content) {
page.content = content;
return interpolate(options.interpolateTemplate);
})
// Prepare page markup
.then(function() {
return filetype.page.prepare(page.content)
.then(function(content) {
page.content = content;
});
})
// Generate template
.then(function() {
return that.template.renderPage(page);
})
// Prepare and Parse markup
.then(function(content) {
page.content = content;
that.log.debug.ln('use file parser', filetype.name, 'for', filename);
return filetype.page(page.content);
})
// Post process sections
.then(function(_page) {
return _.reduce(_page.sections, function(prev, section) {
return prev.then(function(_sections) {
return that.template.postProcess(section.content || '')
.then(function(content) {
section.content = content;
return _sections.concat([section]);
});
});
}, Q([]));
})
// Prepare html
.then(function(_sections) {
return pageUtil.normalize(_sections, {
book: that,
convertImages: options.convertImages,
input: filename,
navigation: that.navigation,
base: path.dirname(filename) || './',
output: path.dirname(filename) || './',
glossary: that.glossary
});
})
// Interpolate output
.then(function(_sections) {
page.sections = _sections;
return interpolate(options.interpolateContent);
})
.then(function() {
return page;
});
};
// Find file that can be parsed with a specific filename
Book.prototype.findFile = function(filename) {
var that = this;
var ext = path.extname(filename);
var basename = path.basename(filename, ext);
// Ordered list of extensions to test
var exts = parsers.extensions;
if (ext) exts = _.uniq([ext].concat(exts));
return _.reduce(exts, function(prev, ext) {
return prev.then(function(output) {
// Stop if already find a parser
if (output) return output;
var filepath = basename+ext;
return fs.findFile(that.root, filepath)
.then(function(realFilepath) {
if (!realFilepath) return null;
return {
parser: parsers.get(ext),
path: realFilepath
};
});
});
}, Q(null));
};
// Format a string using a specific markup language
Book.prototype.formatString = function(extension, content) {
return Q()
.then(function() {
var filetype = parsers.get(extension);
if (!filetype) throw new Error('Filetype doesn\'t exist: '+filetype);
return filetype.page(content);
})
// Merge sections
.then(function(page) {
return _.reduce(page.sections, function(content, section) {
return content + section.content;
}, '');
});
};
// Check if a file exists in the book
Book.prototype.fileExists = function(filename) {
return fs.exists(
this.resolve(filename)
);
};
// Check if a file path is inside the book
Book.prototype.fileIsInBook = function(filename) {
return pathUtil.isInRoot(this.root, filename);
};
// Read a file
Book.prototype.readFile = function(filename) {
return fs.readFile(
this.resolve(filename),
{ encoding: 'utf8' }
);
};
// Return stat for a file
Book.prototype.statFile = function(filename) {
return fs.stat(this.resolve(filename));
};
// List all files in the book
Book.prototype.listAllFiles = function() {
var that = this;
return fs.list(this.root, {
ignoreFiles: ['.ignore', '.gitignore', '.bookignore'],
ignoreRules: [
// Skip Git stuff
'.git/',
'.gitignore',
// Skip OS X meta data
'.DS_Store',
// Skip stuff installed by plugins
'node_modules',
// Skip book outputs
'_book',
'*.pdf',
'*.epub',
'*.mobi',
// Skip config files
'.ignore',
'.bookignore',
'book.json',
]
})
.then(function(_files) {
that.files = _files;
});
};
// Return true if the book is a multilingual book
Book.prototype.isMultilingual = function() {
return this.books.length > 0;
};
// Return root of the parent
Book.prototype.parentRoot = function() {
if (this.parent) return this.parent.parentRoot();
return this.root;
};
// Return true if it's a sub-book
Book.prototype.isSubBook = function() {
return !!this.parent;
};
// Test if the file is the entry point
Book.prototype.isEntryPoint = function(fp) {
return fp == this.readmeFile;
};
// Alias to book.config.get
Book.prototype.getConfig = function(key, def) {
return this.config.get(key, def);
};
// Resolve a path in the book source
// Enforce that the output path in the root folder
Book.prototype.resolve = function() {
return pathUtil.resolveInRoot.apply(null, [this.root].concat(_.toArray(arguments)));
};
// Resolve a path in the book output
// Enforce that the output path in the output folder
Book.prototype.resolveOutput = function() {
return pathUtil.resolveInRoot.apply(null, [this.options.output].concat(_.toArray(arguments)));
};
// Convert an abslute path into a relative path to this
Book.prototype.relative = function(p) {
return path.relative(this.root, p);
};
// Normalize a path to .html and convert README -> index
Book.prototype.contentPath = function(link) {
if (
path.basename(link, path.extname(link)) == 'README' ||
link == this.readmeFile
) {
link = path.join(path.dirname(link), 'index'+path.extname(link));
}
link = links.changeExtension(link, '.html');
return link;
};
// Normalize a link to .html and convert README -> index
Book.prototype.contentLink = function(link) {
return links.normalize(this.contentPath(link));
};
// Default structure paths to an extension
Book.prototype._defaultsStructure = function(filename) {
var that = this;
var extension = path.extname(filename);
that.readmeFile = that.readmeFile || that.config.getStructure('readme')+extension;
that.summaryFile = that.summaryFile || that.config.getStructure('summary')+extension;
that.glossaryFile = that.glossaryFile || that.config.getStructure('glossary')+extension;
that.langsFile = that.langsFile || that.config.getStructure('langs')+extension;
};
// Change output path
Book.prototype.setOutput = function(p) {
var that = this;
this.options.output = path.resolve(p);
_.each(this.books, function(book) {
book.setOutput(path.join(that.options.output, book.options.language));
});
};
// Translate a strign according to the book language
Book.prototype.i18n = function() {
var args = Array.prototype.slice.call(arguments);
return i18n.__.apply({}, [this.config.normalizeLanguage()].concat(args));
};
// Normalize error
Book.prototype.normError = function(err, opts, defs) {
if (_.isString(err)) err = new Error(err);
// Extend err
_.extend(err, opts || {});
_.defaults(err, defs || {});
err.lineNumber = err.lineNumber || err.lineno;
err.columnNumber = err.columnNumber || err.colno;
err.toString = function() {
var attributes = [];
if (this.fileName) attributes.push('In file \''+this.fileName+'\'');
if (this.lineNumber) attributes.push('Line '+this.lineNumber);
if (this.columnNumber) attributes.push('Column '+this.columnNumber);
return (this.name || 'Error')+': '+this.message+((attributes.length > 0)? ' ('+attributes.join(', ')+')' : '');
};
return err;
};
// Call a hook in plugins
Book.prototype.callHook = function(name, data) {
return this.plugins.hook(name, data);
};
module.exports= Book;
+109
View File
@@ -0,0 +1,109 @@
var path = require('path');
module.exports = {
// Options that can't be extend
'configFile': 'book',
'generator': 'website',
'extension': null,
// Book metadats (somes are extracted from the README by default)
'title': null,
'description': null,
'isbn': null,
'language': 'en',
'direction': null,
'author': null,
// version of gitbook to use
'gitbook': '*',
// Structure
'structure': {
'langs': 'LANGS.md',
'readme': 'README.md',
'glossary': 'GLOSSARY.md',
'summary': 'SUMMARY.md'
},
// CSS Styles
'styles': {
'website': 'styles/website.css',
'print': 'styles/print.css',
'ebook': 'styles/ebook.css',
'pdf': 'styles/pdf.css',
'mobi': 'styles/mobi.css',
'epub': 'styles/epub.css'
},
// Plugins list, can contain '-name' for removing default plugins
'plugins': [],
// Global configuration for plugins
'pluginsConfig': {},
// Variables for templating
'variables': {},
// Set another theme with your own layout
// It's recommended to use plugins or add more options for default theme, though
// See https://github.com/GitbookIO/gitbook/issues/209
'theme': path.resolve(__dirname, '../theme'),
// Links in template (null: default, false: remove, string: new value)
'links': {
// Custom links at top of sidebar
'sidebar': {
// 'Custom link name': 'https://customlink.com'
},
// Sharing links
'sharing': {
'google': null,
'facebook': null,
'twitter': null,
'weibo': null,
'all': null
}
},
// Options for PDF generation
'pdf': {
// Add toc at the end of the file
'toc': true,
// Add page numbers to the bottom of every page
'pageNumbers': false,
// Font for the file content
'fontSize': 12,
'fontFamily': 'Arial',
// Paper size for the pdf
// Choices are [ua0, ua1, ua2, ua3, ua4, ua5, ua6, ub0, ub1, ub2, ub3, ub4, ub5, ub6, ulegal, uletter]
'paperSize': 'a4',
// How to mark detected chapters.
// Choices are “pagebreak”, “rule”, 'both' or “none”.
'chapterMark' : 'pagebreak',
// An XPath expression. Page breaks are inserted before the specified elements.
// To disable use the expression: '/'
'pageBreaksBefore': '/',
// Margin (in pts)
// Note: 72 pts equals 1 inch
'margin': {
'right': 62,
'left': 62,
'top': 56,
'bottom': 56
},
// Header HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_.
'headerTemplate': null,
// Footer HTML template. Available variables: _PAGENUM_, _TITLE_, _AUTHOR_ and _SECTION_.
'footerTemplate': null
}
};
+210
View File
@@ -0,0 +1,210 @@
var _ = require('lodash');
var Q = require('q');
var path = require('path');
var semver = require('semver');
var pkg = require('../package.json');
var i18n = require('./utils/i18n');
var version = require('./version');
var DEFAULT_CONFIG = require('./config_default');
// Default plugins added to each books
var DEFAULT_PLUGINS = ['highlight', 'search', 'sharing', 'fontsettings'];
// Check if a plugin is a default plugin
// Plugin should be in the list
// And version from book.json specified for this plugin should be satisfied
function isDefaultPlugin(name, version) {
if (!_.contains(DEFAULT_PLUGINS, name)) return false;
try {
var pluginPkg = require('gitbook-plugin-'+name+'/package.json');
return semver.satisfies(pluginPkg.version, version || '*');
} catch(e) {
return false;
}
}
// Normalize a list of plugins to use
function normalizePluginsList(plugins, addDefaults) {
// Normalize list to an array
plugins = _.isString(plugins) ? plugins.split(',') : (plugins || []);
// Remove empty parts
plugins = _.compact(plugins);
// Divide as {name, version} to handle format like 'myplugin@1.0.0'
plugins = _.map(plugins, function(plugin) {
if (plugin.name) return plugin;
var parts = plugin.split('@');
var name = parts[0];
var version = parts[1];
return {
'name': name,
'version': version, // optional
'isDefault': isDefaultPlugin(name, version)
};
});
// List plugins to remove
var toremove = _.chain(plugins)
.filter(function(plugin) {
return plugin.name.length > 0 && plugin.name[0] == '-';
})
.map(function(plugin) {
return plugin.name.slice(1);
})
.value();
// Merge with defaults
if (addDefaults !== false) {
_.each(DEFAULT_PLUGINS, function(plugin) {
if (_.find(plugins, { name: plugin })) {
return;
}
plugins.push({
'name': plugin,
'isDefault': true
});
});
}
// Remove plugin that start with '-'
plugins = _.filter(plugins, function(plugin) {
return !_.contains(toremove, plugin.name) && !(plugin.name.length > 0 && plugin.name[0] == '-');
});
// Remove duplicates
plugins = _.uniq(plugins, 'name');
return plugins;
}
var Configuration = function(book, options) {
this.book = book;
this.replace(options);
};
// Read and parse the configuration
Configuration.prototype.load = function() {
var that = this;
return Q()
.then(function() {
var configPath, _config;
try {
configPath = require.resolve(
that.book.resolve(that.options.configFile)
);
// Invalidate node.js cache for livreloading
delete require.cache[configPath];
_config = require(configPath);
that.options = _.merge(
that.options,
_.omit(_config, 'configFile', 'defaultsPlugins', 'generator', 'extension')
);
}
catch(err) {
if (err instanceof SyntaxError) return Q.reject(err);
return Q();
}
})
.then(function() {
if (!that.book.isSubBook()) {
if (!version.satisfies(that.options.gitbook)) {
throw new Error('GitBook version doesn\'t satisfy version required by the book: '+that.options.gitbook);
}
if (that.options.gitbook != '*' && !semver.satisfies(semver.inc(pkg.version, 'patch'), that.options.gitbook)) {
that.book.log.warn.ln('gitbook version specified in your book.json might be too strict for future patches, \''+(_.first(pkg.version.split('.'))+'.x.x')+'\' is more adequate');
}
}
that.options.output = path.resolve(that.options.output || that.book.resolve('_book'));
that.options.plugins = normalizePluginsList(that.options.plugins);
that.options.defaultsPlugins = normalizePluginsList(that.options.defaultsPlugins || '', false);
that.options.plugins = _.union(that.options.plugins, that.options.defaultsPlugins);
that.options.plugins = _.uniq(that.options.plugins, 'name');
// Default value for text direction (from language)
if (!that.options.direction) {
var lang = i18n.getCatalog(that.options.language);
if (lang) that.options.direction = lang.direction;
}
that.options.gitbook = pkg.version;
});
};
// Extend the configuration
Configuration.prototype.extend = function(options) {
_.extend(this.options, options);
};
// Replace the whole configuration
Configuration.prototype.replace = function(options) {
var that = this;
this.options = _.cloneDeep(DEFAULT_CONFIG);
this.options = _.merge(this.options, options || {});
// options.input == book.root
Object.defineProperty(this.options, 'input', {
get: function () {
return that.book.root;
}
});
// options.originalInput == book.parent.root
Object.defineProperty(this.options, 'originalInput', {
get: function () {
return that.book.parent? that.book.parent.root : undefined;
}
});
// options.originalOutput == book.parent.options.output
Object.defineProperty(this.options, 'originalOutput', {
get: function () {
return that.book.parent? that.book.parent.options.output : undefined;
}
});
};
// Dump configuration as json object
Configuration.prototype.dump = function() {
return _.cloneDeep(this.options);
};
// Get structure file
Configuration.prototype.getStructure = function(name, dontStripExt) {
var filename = this.options.structure[name];
if (dontStripExt) return filename;
filename = filename.split('.').slice(0, -1).join('.');
return filename;
};
// Return normalized language
Configuration.prototype.normalizeLanguage = function() {
return i18n.normalizeLanguage(this.options.language);
};
// Return a configuration
Configuration.prototype.get = function(key, def) {
return _.get(this.options, key, def);
};
// Update a configuration
Configuration.prototype.set = function(key, value) {
return _.set(this.options, key, value);
};
// Default configuration
Configuration.DEFAULT = DEFAULT_CONFIG;
module.exports= Configuration;
+73
View File
@@ -0,0 +1,73 @@
var _ = require('lodash');
var path = require('path');
var nunjucks = require('nunjucks');
var git = require('./utils/git');
var fs = require('./utils/fs');
var pathUtil = require('./utils/path');
// The loader should handle relative and git url
var BookLoader = nunjucks.Loader.extend({
async: true,
init: function(book, opts) {
this.opts = _.defaults(opts || {}, {
interpolate: _.identity
});
this.book = book;
},
getSource: function(fileurl, callback) {
var that = this;
git.resolveFile(fileurl)
.then(function(filepath) {
// Is local file
if (!filepath) filepath = path.resolve(fileurl);
else that.book.log.debug.ln('resolve from git', fileurl, 'to', filepath);
// Read file from absolute path
return fs.readFile(filepath)
.then(function(source) {
return that.opts.interpolate(filepath, source.toString());
})
.then(function(source) {
return {
src: source,
path: filepath,
// We disable cache sincde content is modified (shortcuts, ...)
noCache: true
};
});
})
.nodeify(callback);
},
resolve: function(from, to) {
// If origin is in the book, we enforce result file to be in the book
if (this.book.fileIsInBook(from)) {
return this.book.resolve(
this.book.relative(path.dirname(from)),
to
);
}
// If origin is in a git repository, we resolve file in the git repository
var gitRoot = git.resolveRoot(from);
if (gitRoot) {
return pathUtil.resolveInRoot(gitRoot, to);
}
// If origin is not in the book (include from a git content ref)
return path.resolve(path.dirname(from), to);
},
// Handle all files as relative, so that nunjucks pass responsability to 'resolve'
// Only git urls are considered as absolute
isRelative: function(filename) {
return !git.checkUrl(filename);
}
});
module.exports = BookLoader;
-70
View File
@@ -1,70 +0,0 @@
var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
var exec = require('child_process').exec;
var fs = require("fs");
var parse = require("../../parse");
var BaseGenerator = require("../page");
/*
* This generator inherits from the single page generator
* and convert the page output to ebook
*/
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Options for eBook generation
this.options = _.defaults(this.options, {
extension: "epub"
});
if (!this.options.cover && fs.existsSync(path.join(this.options.input, "cover.png"))) {
this.options.cover = path.join(this.options.input, "cover.png")
}
};
util.inherits(Generator, BaseGenerator);
Generator.prototype.finish = function() {
var that = this;
return BaseGenerator.prototype.finish.apply(this)
.then(function() {
var d = Q.defer();
var _options = {
"--cover": that.options.cover
};
var command = [
"ebook-convert",
path.join(that.options.output, "index.html"),
path.join(that.options.output, "index."+that.options.extension),
_.chain(_options)
.map(function(value, key) {
if (value == null) return null;
return key+"="+value;
})
.compact()
.value()
.join(" ")
].join(" ");
exec(command, function (error, stdout, stderr) {
if (error) {
if (error.code == 127) {
error.message = "Need to install ebook-convert from Calibre";
} else {
error.message = error.message + " "+stdout;
}
return d.reject(error);
}
d.resolve();
});
return d.promise;
});
};
module.exports = Generator;
-54
View File
@@ -1,54 +0,0 @@
var Q = require("q");
var fs = require("fs");
var fsExtra = require("fs-extra");
var Ignore = require("fstream-ignore");
var getFiles = function(path) {
var d = Q.defer();
// Our list of files
var files = [];
var ig = Ignore({
path: path,
ignoreFiles: ['.ignore', '.gitignore', '.bookignore']
});
// Add extra rules to ignore common folders
ig.addIgnoreRules([
'.git/'
], '__custom_stuff');
// Push each file to our list
ig.on('child', function (c) {
files.push(
c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
);
});
ig.on('end', function() {
// Normalize paths on Windows
if(process.platform === 'win32') {
return d.resolve(files.map(function(file) {
return file.replace(/\\/g, '/');
}));
}
// Simply return paths otherwise
return d.resolve(files);
});
ig.on('error', d.reject);
return d.promise;
};
module.exports = {
list: getFiles,
readFile: Q.denodeify(fs.readFile),
writeFile: Q.denodeify(fs.writeFile),
mkdirp: Q.denodeify(fsExtra.mkdirp),
copy: Q.denodeify(fsExtra.copy),
remove: Q.denodeify(fsExtra.remove),
symlink: Q.denodeify(fsExtra.symlink),
};
-36
View File
@@ -1,36 +0,0 @@
var path = require("path");
var Q = require("q");
var fs = require("./fs");
var BaseGenerator = function(options) {
this.options = options;
};
BaseGenerator.prototype.convertFile = function(content, input) {
return Q.reject(new Error("Could not convert "+input));
};
BaseGenerator.prototype.transferFile = function(input) {
return fs.copy(
path.join(this.options.input, input),
path.join(this.options.output, input)
);
};
BaseGenerator.prototype.transferFolder = function(input) {
return fs.mkdirp(
path.join(this.options.output, input)
);
};
BaseGenerator.prototype.langsIndex = function(langs) {
return Q.reject(new Error("Langs index is not supported in this generator"));
};
BaseGenerator.prototype.finish = function() {
return Q.reject(new Error("Could not finish generation"));
};
module.exports = BaseGenerator;
-148
View File
@@ -1,148 +0,0 @@
var Q = require("q");
var _ = require("lodash");
var path = require("path");
var swig = require('swig');
var fs = require("./fs");
var parse = require("../parse");
var generators = {
"site": require("./site"),
"page": require("./page"),
"pdf": require("./pdf"),
"ebook": require("./ebook"),
"json": require("./json")
};
var generate = function(options) {
var generator = null;
var files;
options = _.defaults(options || {}, {
// Folders to use
input: null,
output: null,
// Output generator
generator: "site",
// Book title, keyword, description
title: null,
description: "Book generated using GitBook",
// Origin github repository id
github: null,
githubHost: 'https://github.com/',
// Theming
theme: path.resolve(__dirname, '../../theme')
});
if (!options.github || !options.title || !options.input || !options.output) {
return Q.reject(new Error("Need options: github, title, input, output"));
}
if (!generators[options.generator]) {
return Q.reject(new Error("Invalid generator (availables are: "+_.keys(generators).join(", ")));
}
// Clean output folder
return fs.remove(options.output)
.then(function() {
return fs.mkdirp(options.output);
})
// List all files in the repository
.then(function() {
return fs.list(options.input)
.then(function(_files) {
files = _files;
})
})
// Create the generator
.then(function() {
generator = new generators[options.generator](options);
})
// Detect multi-languages book
.then(function() {
if (_.contains(files, "LANGS.md")) {
// Multi-languages book
return fs.readFile(path.join(options.input, "LANGS.md"), "utf-8")
// Generate sub-books
.then(function(_langsSummary) {
options.langsSummary = parse.langs(_langsSummary);
// Generated a book for each valid entry
return Q.all(
_.map(options.langsSummary.list, function(entry) {
return generate(_.extend({}, options, {
input: path.join(options.input, entry.path),
output: path.join(options.output, entry.path)
}));
})
);
})
// Generate languages index
.then(function() {
return generator.langsIndex(options.langsSummary);
});
} else if (!_.contains(files, "SUMMARY.md") || !_.contains(files, "README.md")) {
// Invalid book
return Q.reject(new Error("Invalid gitbook repository, need SUMMARY.md and README.md"));
} else {
// Generate the book
return fs.readFile(path.join(options.input, "SUMMARY.md"), "utf-8")
// Get summary
.then(function(_summary) {
options.summary = parse.summary(_summary);
// Parse navigation
options.navigation = parse.navigation(options.summary);
})
// Copy file and replace markdown file
.then(function() {
return Q.all(
_.chain(files)
.map(function(file) {
if (!file) return;
if (file[file.length -1] == "/") {
return Q(generator.transferFolder(file));
} else if (path.extname(file) == ".md" && options.navigation[file] != null) {
return fs.readFile(path.join(options.input, file), "utf-8")
.then(function(content) {
return Q(generator.convertFile(content, file));
});
} else {
return Q(generator.transferFile(file));
}
})
.value()
);
})
// Finish gneration
.then(function() {
return generator.finish();
});
}
})
// Return all options
.then(function() {
return options;
});
};
module.exports = {
generators: generators,
folder: generate
};
-47
View File
@@ -1,47 +0,0 @@
var util = require("util");
var path = require("path");
var Q = require("q");
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../generator");
var Generator = function() {
BaseGenerator.apply(this, arguments);
};
util.inherits(Generator, BaseGenerator);
Generator.prototype.transferFile = function(input) {
// ignore
};
Generator.prototype.convertFile = function(content, input) {
var that = this;
var json = {
progress: parse.progress(this.options.navigation, input)
};
return Q()
.then(function() {
return parse.page(content, {
repo: that.options.githubId,
dir: path.dirname(input) || '/'
});
})
.then(function(sections) {
json.sections = sections;
})
.then(function() {
return fs.writeFile(
path.join(that.options.output, input.replace(".md", ".json")),
JSON.stringify(json, null, 4)
);
});
};
Generator.prototype.finish = function() {
// ignore
};
module.exports = Generator;
-84
View File
@@ -1,84 +0,0 @@
var _ = require("lodash");
var util = require("util");
var path = require("path");
var Q = require("q");
var swig = require('swig');
var hljs = require('highlight.js');
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../site");
// Swig filter: highlight coloration
swig.setFilter('code', function(code, lang) {
try {
return hljs.highlight(lang, code).value;
} catch(e) {
return hljs.highlightAuto(code).value;
}
});
/*
* This generator will generate a simple index.html which can be converted as a PDF
*/
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Load base template
this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/page.html'));
// List of pages content
this.pages = {};
};
util.inherits(Generator, BaseGenerator);
Generator.prototype.convertFile = function(content, input) {
var that = this;
var json = {
path: input,
progress: parse.progress(this.options.navigation, input)
};
return Q()
.then(function() {
return parse.page(content, {
repo: that.options.githubId,
dir: path.dirname(input) || '/',
outdir: './',
});
})
.then(function(sections) {
json.content = sections;
})
.then(function() {
that.pages[input] = json;
});
};
Generator.prototype.finish = function() {
var that = this;
var basePath = ".";
var output = path.join(this.options.output, "index.html");
return Q()
// Generate html
.then(function(pages) {
return that._writeTemplate(that.template, {
pages: that.pages,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
}, output);
})
// Copy assets
.then(function() {
return fs.copy(
path.join(that.options.theme, "assets"),
path.join(that.options.output, "gitbook")
);
});
};
module.exports = Generator;
-56
View File
@@ -1,56 +0,0 @@
var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
var exec = require('child_process').exec;
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../page");
/*
* This generator inherits from the single page generator
* and convert the page output to pdf using gitbook-pdf
*/
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Options for PDF generation
this.options = _.defaults(this.options, {
paperformat: "A4"
});
};
util.inherits(Generator, BaseGenerator);
Generator.prototype.finish = function() {
var that = this;
return BaseGenerator.prototype.finish.apply(this)
.then(function() {
var d = Q.defer();
var command = [
"gitbook-pdf",
"generate",
path.join(that.options.output, "index.html"),
path.join(that.options.output, "index.pdf"),
"--format="+that.options.paperformat
].join(" ");
exec(command, function (error, stdout, stderr) {
if (error) {
if (error.code == 127) {
error.message = "Need to install gitbook-pdf using: npm install gitbook-pdf -g";
} else {
error.message = error.message + " "+stdout;
}
return d.reject(error);
}
d.resolve();
});
return d.promise;
});
};
module.exports = Generator;
-156
View File
@@ -1,156 +0,0 @@
var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
var swig = require('swig');
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../generator");
var indexer = require('./search_indexer');
// Swig filter for returning the count of lines in a code section
swig.setFilter('lines', function(content) {
return content.split('\n').length;
});
// Swig filter for returning a link to the associated html file of a markdown file
swig.setFilter('mdLink', function(link) {
var link = link.replace(".md", ".html");
if (link == "README.html") link = "index.html";
return link;
});
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Attach methods to instance
_.bindAll(this);
this.revision = Date.now();
this.indexer = indexer();
// Load base template
this.template = swig.compileFile(path.resolve(this.options.theme, 'templates/site.html'));
this.langsTemplate = swig.compileFile(path.resolve(this.options.theme, 'templates/langs.html'));
};
util.inherits(Generator, BaseGenerator);
// Generate a template
Generator.prototype._writeTemplate = function(tpl, options, output) {
var that = this;
return Q()
.then(function(sections) {
return tpl(_.extend({
revision: that.revision,
title: that.options.title,
description: that.options.description,
githubAuthor: that.options.github.split("/")[0],
githubId: that.options.github,
githubHost: that.options.githubHost,
summary: that.options.summary,
allNavigation: that.options.navigation
}, options));
})
.then(function(html) {
return fs.writeFile(
output,
html
);
});
};
Generator.prototype.indexPage = function(lexed, pagePath) {
this.indexer.add(lexed, pagePath);
return Q();
};
// Convert a markdown file to html
Generator.prototype.convertFile = function(content, _input) {
var that = this;
var progress = parse.progress(this.options.navigation, _input);
_output = _input.replace(".md", ".html");
if (_output == "README.html") _output = "index.html";
var input = path.join(this.options.input, _input);
var output = path.join(this.options.output, _output);
var basePath = path.relative(path.dirname(output), this.options.output) || ".";
return Q()
.then(function() {
// Lex page
return parse.lex(content);
})
.then(function(lexed) {
// Index page in search
return that.indexPage(lexed, _output)
.then(_.constant(lexed));
})
.then(function(lexed) {
// Get HTML generated sections
return parse.page(lexed, {
repo: that.options.githubId,
dir: path.dirname(_input) || '/',
outdir: path.dirname(_input) || '/',
});
})
.then(function(sections) {
return that._writeTemplate(that.template, {
progress: progress,
_input: _input,
content: sections,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
}, output);
});
};
// Generate languages index
Generator.prototype.langsIndex = function(langs) {
var that = this;
var basePath = ".";
return this._writeTemplate(this.langsTemplate, {
langs: langs.list,
basePath: basePath,
staticBase: path.join(basePath, "gitbook"),
}, path.join(this.options.output, "index.html"))
.then(function() {
// Copy assets
return that.copyAssets();
});
};
// Copy assets
Generator.prototype.copyAssets = function() {
var that = this;
return fs.copy(
path.join(that.options.theme, "assets"),
path.join(that.options.output, "gitbook")
);
};
// Dump search index to disk
Generator.prototype.writeSearchIndex = function() {
return fs.writeFile(
path.join(this.options.output, 'search_index.json'),
this.indexer.dump()
);
};
Generator.prototype.finish = function() {
return this.copyAssets()
.then(this.writeSearchIndex);
};
module.exports = Generator;
-71
View File
@@ -1,71 +0,0 @@
var Q = require("q");
var _ = require("lodash");
var lunr = require('lunr');
var marked = require('marked');
var textRenderer = require('marked-text-renderer');
function Indexer() {
if(!(this instanceof Indexer)) {
return new Indexer();
}
_.bindAll(this);
// Setup lunr index
this.idx = lunr(function () {
this.ref('url');
this.field('title', { boost: 10 });
this.field('body');
});
this.renderer = textRenderer();
}
Indexer.prototype.text = function(nodes) {
// Copy section
var section = _.toArray(nodes);
// marked's Render expects this, we don't use it yet
section.links = {};
var options = _.extend({}, marked.defaults, {
renderer: this.renderer
});
return marked.parser(section, options);
};
Indexer.prototype.addSection = function(path, section) {
var url = [path, section.id].join('#');
var title = this.text(
_.filter(section, {'type': 'heading'})
);
var body = this.text(
_.omit(section, {'type': 'heading'})
);
// Add to lunr index
this.idx.add({
url: url,
title: title,
body: body,
});
};
Indexer.prototype.add = function(lexedPage, url) {
var sections = lexedPage;
_.map(sections, _.partial(this.addSection, url));
};
Indexer.prototype.dump = function() {
return JSON.stringify(this.idx);
};
// Exports
module.exports = Indexer;
+76
View File
@@ -0,0 +1,76 @@
var _ = require('lodash');
var path = require('path');
var Q = require('q');
var fs = require('./utils/fs');
var BaseGenerator = function(book) {
this.book = book;
Object.defineProperty(this, 'options', {
get: function () {
return this.book.options;
}
});
_.bindAll(this);
};
BaseGenerator.prototype.callHook = function(name, data) {
return this.book.callHook(name, data);
};
// Prepare the genertor
BaseGenerator.prototype.prepare = function() {
var that = this;
return that.callHook('init');
};
// Write a parsed file to the output
BaseGenerator.prototype.convertFile = function(input) {
return Q.reject(new Error('Could not convert '+input));
};
// Copy file to the output (non parsable)
BaseGenerator.prototype.transferFile = function(input) {
return fs.copy(
this.book.resolve(input),
path.join(this.options.output, input)
);
};
// Copy a folder to the output
BaseGenerator.prototype.transferFolder = function(input) {
return fs.mkdirp(
path.join(this.book.options.output, input)
);
};
// Copy the cover picture
BaseGenerator.prototype.copyCover = function() {
var that = this;
return Q.all([
fs.copy(that.book.resolve('cover.jpg'), path.join(that.options.output, 'cover.jpg')),
fs.copy(that.book.resolve('cover_small.jpg'), path.join(that.options.output, 'cover_small.jpg'))
])
.fail(function() {
// If orignaly from multi-lang, try copy from parent
if (!that.book.isSubBook()) return;
return Q.all([
fs.copy(path.join(that.book.parentRoot(), 'cover.jpg'), path.join(that.options.output, 'cover.jpg')),
fs.copy(path.join(that.book.parentRoot(), 'cover_small.jpg'), path.join(that.options.output, 'cover_small.jpg'))
]);
})
.fail(function() {
return Q();
});
};
// At teh end of the generation
BaseGenerator.prototype.finish = function() {
return Q.reject(new Error('Could not finish generation'));
};
module.exports = BaseGenerator;
+172
View File
@@ -0,0 +1,172 @@
var util = require('util');
var path = require('path');
var Q = require('q');
var _ = require('lodash');
var juice = require('juice');
var exec = require('child_process').exec;
var fs = require('../utils/fs');
var stringUtils = require('../utils/string');
var BaseGenerator = require('./website');
var Generator = function(book, format) {
BaseGenerator.apply(this, arguments);
// eBook format
this.ebookFormat = format;
// Resources namespace
this.namespace = 'ebook';
// Styles to use
this.styles = _.compact(['print', 'ebook', this.ebookFormat]);
// Convert images (svg -> png)
this.convertImages = true;
};
util.inherits(Generator, BaseGenerator);
Generator.prototype.prepareTemplates = function() {
this.templates.page = this.book.plugins.template('ebook:page') || path.resolve(this.options.theme, 'templates/ebook/page.html');
this.templates.summary = this.book.plugins.template('ebook:summary') || path.resolve(this.options.theme, 'templates/ebook/summary.html');
this.templates.glossary = this.book.plugins.template('ebook:glossary') || path.resolve(this.options.theme, 'templates/ebook/glossary.html');
return Q();
};
// Generate table of contents
Generator.prototype.writeSummary = function() {
var that = this;
that.book.log.info.ln('write SUMMARY.html');
return this._writeTemplate(this.templates.summary, {}, path.join(this.options.output, 'SUMMARY.html'));
};
// Return template for footer/header with inlined css
Generator.prototype.getPDFTemplate = function(id) {
var tpl = this.options.pdf[id+'Template'];
var defaultTpl = path.resolve(this.options.theme, 'templates/ebook/'+id+'.html');
var defaultCSS = path.resolve(this.options.theme, 'assets/ebook/pdf.css');
// Default template from theme
if (!tpl && fs.existsSync(defaultTpl)) {
tpl = fs.readFileSync(defaultTpl, { encoding: 'utf-8' });
}
// Inline CSS using juice
var stylesheets = [];
// From theme
if (fs.existsSync(defaultCSS)) {
stylesheets.push(fs.readFileSync(defaultCSS, { encoding: 'utf-8' }));
}
// Custom PDF style
if (this.styles.pdf) {
stylesheets.push(fs.readFileSync(this.book.resolveOutput(this.styles.pdf), { encoding: 'utf-8' }));
}
tpl = juice(tpl, {
extraCss: stylesheets.join('\n\n')
});
return tpl;
};
Generator.prototype.finish = function() {
var that = this;
return Q()
.then(this.copyAssets)
.then(this.copyCover)
.then(this.writeGlossary)
.then(this.writeSummary)
.then(function() {
if (!that.ebookFormat) return Q();
if (!that.options.cover && fs.existsSync(path.join(that.options.output, 'cover.jpg'))) {
that.options.cover = path.join(that.options.output, 'cover.jpg');
}
var d = Q.defer();
var _options = {
'--cover': that.options.cover,
'--title': that.options.title,
'--comments': that.options.description,
'--isbn': that.options.isbn,
'--authors': that.options.author,
'--language': that.options.language,
'--book-producer': 'GitBook',
'--publisher': 'GitBook',
'--chapter': 'descendant-or-self::*[contains(concat(\' \', normalize-space(@class), \' \'), \' book-chapter \')]',
'--level1-toc': 'descendant-or-self::*[contains(concat(\' \', normalize-space(@class), \' \'), \' book-chapter-1 \')]',
'--level2-toc': 'descendant-or-self::*[contains(concat(\' \', normalize-space(@class), \' \'), \' book-chapter-2 \')]',
'--level3-toc': 'descendant-or-self::*[contains(concat(\' \', normalize-space(@class), \' \'), \' book-chapter-3 \')]',
'--no-chapters-in-toc': true,
'--max-levels': '1',
'--breadth-first': true
};
if (that.ebookFormat == 'pdf') {
var pdfOptions = that.options.pdf;
_.extend(_options, {
'--chapter-mark': String(pdfOptions.chapterMark),
'--page-breaks-before': String(pdfOptions.pageBreaksBefore),
'--margin-left': String(pdfOptions.margin.left),
'--margin-right': String(pdfOptions.margin.right),
'--margin-top': String(pdfOptions.margin.top),
'--margin-bottom': String(pdfOptions.margin.bottom),
'--pdf-default-font-size': String(pdfOptions.fontSize),
'--pdf-mono-font-size': String(pdfOptions.fontSize),
'--paper-size': String(pdfOptions.paperSize),
'--pdf-page-numbers': Boolean(pdfOptions.pageNumbers),
'--pdf-header-template': that.getPDFTemplate('header'),
'--pdf-footer-template': that.getPDFTemplate('footer'),
'--pdf-sans-family': String(pdfOptions.fontFamily)
});
} else if (that.ebookFormat == 'epub') {
_.extend(_options, {
'--dont-split-on-page-breaks': true
});
}
var command = [
'ebook-convert',
path.join(that.options.output, 'SUMMARY.html'),
path.join(that.options.output, 'index.'+that.ebookFormat),
stringUtils.optionsToShellArgs(_options)
].join(' ');
that.book.log.info('start conversion to', that.ebookFormat, '....');
var child = exec(command, function (error, stdout) {
if (error) {
that.book.log.info.fail();
if (error.code == 127) {
error.message = 'Need to install ebook-convert from Calibre';
} else {
error.message = error.message + ' '+stdout;
}
return d.reject(error);
}
that.book.log.info.ok();
d.resolve();
});
child.stdout.on('data', function (data) {
that.book.log.debug(data);
});
child.stderr.on('data', function (data) {
that.book.log.debug(data);
});
return d.promise;
});
};
module.exports = Generator;
+11
View File
@@ -0,0 +1,11 @@
var _ = require("lodash");
var EbookGenerator = require("./ebook");
module.exports = {
json: require("./json"),
website: require("./website"),
ebook: EbookGenerator,
pdf: _.partialRight(EbookGenerator, "pdf"),
mobi: _.partialRight(EbookGenerator, "mobi"),
epub: _.partialRight(EbookGenerator, "epub")
};
+76
View File
@@ -0,0 +1,76 @@
var util = require('util');
var path = require('path');
var Q = require('q');
var _ = require('lodash');
var fs = require('../utils/fs');
var BaseGenerator = require('../generator');
var links = require('../utils/links');
var Generator = function() {
BaseGenerator.apply(this, arguments);
};
util.inherits(Generator, BaseGenerator);
// Ignore some methods
Generator.prototype.transferFile = function() { };
// Convert an input file
Generator.prototype.convertFile = function(input) {
var that = this;
return that.book.parsePage(input)
.then(function(page) {
var json = {
progress: page.progress,
sections: page.sections
};
var output = links.changeExtension(page.path, '.json');
output = path.join(that.options.output, output);
return fs.writeFile(
output,
JSON.stringify(json, null, 4)
);
});
};
// Finish generation
Generator.prototype.finish = function() {
return this.writeReadme();
};
// Write README.json
Generator.prototype.writeReadme = function() {
var that = this;
var mainLang, langs, readme;
return Q()
.then(function() {
langs = that.book.langs;
mainLang = langs.length > 0? _.first(langs).lang : null;
readme = links.changeExtension(that.book.readmeFile, '.json');
// Read readme from main language
return fs.readFile(
mainLang? path.join(that.options.output, mainLang, readme) : path.join(that.options.output, readme)
);
})
.then(function(content) {
// Extend it with infos about the languages
var json = JSON.parse(content);
_.extend(json, {
langs: langs
});
// Write it as README.json
return fs.writeFile(
path.join(that.options.output, 'README.json'),
JSON.stringify(json, null, 4)
);
});
};
module.exports = Generator;
+268
View File
@@ -0,0 +1,268 @@
var util = require('util');
var path = require('path');
var Q = require('q');
var _ = require('lodash');
var nunjucks = require('nunjucks');
var AutoEscapeExtension = require('nunjucks-autoescape')(nunjucks);
var FilterExtension = require('nunjucks-filter')(nunjucks);
var fs = require('../utils/fs');
var BaseGenerator = require('../generator');
var links = require('../utils/links');
var i18n = require('../utils/i18n');
var pkg = require('../../package.json');
var Generator = function() {
BaseGenerator.apply(this, arguments);
// Revision
this.revision = new Date();
// Resources namespace
this.namespace = 'website';
// Style to integrates in the output
this.styles = ['website'];
// Convert images (svg -> png)
this.convertImages = false;
// Templates
this.templates = {};
};
util.inherits(Generator, BaseGenerator);
// Prepare the genertor
Generator.prototype.prepare = function() {
return BaseGenerator.prototype.prepare.apply(this)
.then(this.prepareStyles)
.then(this.prepareTemplates)
.then(this.prepareTemplateEngine);
};
// Prepare all styles
Generator.prototype.prepareStyles = function() {
var that = this;
this.styles = _.chain(this.styles)
.map(function(style) {
var stylePath = that.options.styles[style];
var styleExists = (
fs.existsSync(that.book.resolveOutput(stylePath)) ||
fs.existsSync(that.book.resolve(stylePath))
);
if (stylePath && styleExists) {
return [style, stylePath];
}
return null;
})
.compact()
.object()
.value();
return Q();
};
// Prepare templates
Generator.prototype.prepareTemplates = function() {
this.templates.page = this.book.plugins.template('site:page') || path.resolve(this.options.theme, 'templates/website/page.html');
this.templates.langs = this.book.plugins.template('site:langs') || path.resolve(this.options.theme, 'templates/website/langs.html');
this.templates.glossary = this.book.plugins.template('site:glossary') || path.resolve(this.options.theme, 'templates/website/glossary.html');
return Q();
};
// Prepare template engine
Generator.prototype.prepareTemplateEngine = function() {
var that = this;
return Q()
.then(function() {
var language = that.book.config.normalizeLanguage();
if (!i18n.hasLocale(language)) {
that.book.log.warn.ln('Language "'+language+'" is not available as a layout locales (en, '+i18n.getLocales().join(', ')+')');
}
var folders = _.chain(that.templates)
.values()
.map(path.dirname)
.uniq()
.value();
that.env = new nunjucks.Environment(
new nunjucks.FileSystemLoader(folders),
{
autoescape: true
}
);
// Add filter
that.env.addFilter('contentLink', that.book.contentLink.bind(that.book));
that.env.addFilter('lvl', function(lvl) {
return lvl.split('.').length;
});
// Add extension
that.env.addExtension('AutoEscapeExtension', new AutoEscapeExtension(that.env));
that.env.addExtension('FilterExtension', new FilterExtension(that.env));
});
};
// Finis generation
Generator.prototype.finish = function() {
return this.copyAssets()
.then(this.copyCover)
.then(this.writeGlossary)
.then(this.writeLangsIndex);
};
// Convert an input file
Generator.prototype.convertFile = function(input) {
var that = this;
return that.book.parsePage(input, {
convertImages: that.convertImages,
interpolateTemplate: function(page) {
return that.callHook('page:before', page);
},
interpolateContent: function(page) {
return that.callHook('page', page);
}
})
.then(function(page) {
var relativeOutput = that.book.contentPath(page.path);
var output = path.join(that.options.output, relativeOutput);
var basePath = path.relative(path.dirname(output), that.options.output) || '.';
if (process.platform === 'win32') basePath = basePath.replace(/\\/g, '/');
that.book.log.debug.ln('write parsed file', page.path, 'to', relativeOutput);
return that._writeTemplate(that.templates.page, {
progress: page.progress,
_input: page.path,
content: page.sections,
basePath: basePath,
staticBase: links.join(basePath, 'gitbook')
}, output);
});
};
// Write the index for langs
Generator.prototype.writeLangsIndex = function() {
if (!this.book.langs.length) return Q();
return this._writeTemplate(this.templates.langs, {
langs: this.book.langs
}, path.join(this.options.output, 'index.html'));
};
// Write glossary
Generator.prototype.writeGlossary = function() {
// No glossary
if (this.book.glossary.length === 0) return Q();
return this._writeTemplate(this.templates.glossary, {}, path.join(this.options.output, 'GLOSSARY.html'));
};
// Convert a page into a normalized data set
Generator.prototype.normalizePage = function(page) {
var that = this;
var _callHook = function(name) {
return that.callHook(name, page)
.then(function(_page) {
page = _page;
return page;
});
};
return Q()
.then(function() {
return _callHook('page');
})
.then(function() {
return page;
});
};
// Generate a template
Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) {
var that = this;
interpolate = interpolate || _.identity;
return Q()
.then(function() {
return that.env.render(
tpl,
_.extend({
gitbook: {
version: pkg.version
},
styles: that.styles,
revision: that.revision,
title: that.options.title,
description: that.options.description,
language: that.book.config.normalizeLanguage(),
innerlanguage: that.book.isSubBook()? that.book.config.get('language') : null,
glossary: that.book.glossary,
summary: that.book.summary,
allNavigation: that.book.navigation,
plugins: {
resources: that.book.plugins.resources(that.namespace)
},
pluginsConfig: JSON.stringify(that.options.pluginsConfig),
htmlSnippet: _.partial(_.partialRight(that.book.plugins.html, that, options), that.namespace),
options: that.options,
basePath: '.',
staticBase: path.join('.', 'gitbook'),
'__': that.book.i18n.bind(that.book)
}, options)
);
})
.then(interpolate)
.then(function(html) {
return fs.writeFile(
output,
html
);
});
};
// Copy assets
Generator.prototype.copyAssets = function() {
var that = this;
// Copy gitbook assets
return fs.copy(
path.join(that.options.theme, 'assets/'+this.namespace),
path.join(that.options.output, 'gitbook')
)
// Copy plugins assets
.then(function() {
return Q.all(
_.map(that.book.plugins.list, function(plugin) {
var pluginAssets = path.join(that.options.output, 'gitbook/plugins/', plugin.name);
return plugin.copyAssets(pluginAssets, that.namespace);
})
);
});
};
module.exports = Generator;
+213 -3
View File
@@ -1,5 +1,215 @@
module.exports = {
parse: require('./parse/'),
generate: require('./generate/')
/* eslint no-console: 0 */
var Q = require('q');
var _ = require('lodash');
var path = require('path');
var tinylr = require('tiny-lr');
var color = require('bash-color');
var Book = require('./book');
var initBook = require('./init');
var Server = require('./utils/server');
var stringUtils = require('./utils/string');
var watch = require('./utils/watch');
var logger = require('./utils/logger');
var LOG_OPTION = {
name: 'log',
description: 'Minimum log level to display',
values: _.chain(logger.LEVELS).keys().map(stringUtils.toLowerCase).value(),
defaults: 'info'
};
var FORMAT_OPTION = {
name: 'format',
description: 'Format to build to',
values: ['website', 'json', 'ebook'],
defaults: 'website'
};
// Export init to gitbook library
Book.init = initBook;
module.exports = {
Book: Book,
LOG_LEVELS: logger.LEVELS,
commands: _.flatten([
{
name: 'build [book] [output]',
description: 'build a book',
options: [
FORMAT_OPTION,
LOG_OPTION
],
exec: function(args, kwargs) {
var input = args[0] || process.cwd();
var output = args[1] || path.join(input, '_book');
var book = new Book(input, _.extend({}, {
'config': {
'output': output
},
'logLevel': kwargs.log
}));
return book.parse()
.then(function() {
return book.generate(kwargs.format);
})
.then(function(){
console.log('');
console.log(color.green('Done, without error'));
});
}
},
_.map(['pdf', 'epub', 'mobi'], function(ebookType) {
return {
name: ebookType+' [book] [output]',
description: 'build a book to '+ebookType,
options: [
LOG_OPTION
],
exec: function(args, kwargs) {
var input = args[0] || process.cwd();
var output = args[1];
var book = new Book(input, _.extend({}, {
'logLevel': kwargs.log
}));
return book.parse()
.then(function() {
return book.generateFile(output, {
ebookFormat: ebookType
});
})
.then(function(){
console.log('');
console.log(color.green('Done, without error'));
});
}
};
}),
{
name: 'serve [book]',
description: 'Build then serve a gitbook from a directory',
options: [
{
name: 'port',
description: 'Port for server to listen on',
defaults: 4000
},
{
name: 'lrport',
description: 'Port for livereload server to listen on',
defaults: 35729
},
{
name: 'watch',
description: 'Enable/disable file watcher',
defaults: true
},
FORMAT_OPTION,
LOG_OPTION
],
exec: function(args, kwargs) {
var input = args[0] || process.cwd();
var server = new Server();
// Init livereload server
var lrServer = tinylr({});
var lrPath;
var generate = function() {
if (server.isRunning()) console.log('Stopping server');
return server.stop()
.then(function() {
var book = new Book(input, _.extend({}, {
'config': {
'defaultsPlugins': ['livereload']
},
'logLevel': kwargs.log
}));
return book.parse()
.then(function() {
return book.generate(kwargs.format);
})
.thenResolve(book);
})
.then(function(book) {
console.log();
console.log('Starting server ...');
return server.start(book.options.output, kwargs.port)
.then(function() {
console.log('Serving book on http://localhost:'+kwargs.port);
if (lrPath) {
// trigger livereload
lrServer.changed({
body: {
files: [lrPath]
}
});
}
if (!kwargs.watch) return;
return watch(book.root)
.then(function(filepath) {
// set livereload path
lrPath = filepath;
console.log('Restart after change in file', filepath);
console.log('');
return generate();
});
});
});
};
return Q.nfcall(lrServer.listen.bind(lrServer), kwargs.lrport)
.then(function() {
console.log('Live reload server started on port:', kwargs.lrport);
console.log('Press CTRL+C to quit ...');
console.log('');
return generate();
});
}
},
{
name: 'install [book]',
description: 'install plugins dependencies',
exec: function(args) {
var input = args[0] || process.cwd();
var book = new Book(input);
return book.config.load()
.then(function() {
return book.plugins.install();
})
.then(function(){
console.log('');
console.log(color.green('Done, without error'));
});
}
},
{
name: 'init [directory]',
description: 'create files and folders based on contents of SUMMARY.md',
exec: function(args) {
return initBook(args[0] || process.cwd())
.then(function(){
console.log('');
console.log(color.green('Done, without error'));
});
}
}
])
};
+83
View File
@@ -0,0 +1,83 @@
var _ = require('lodash');
var Q = require('q');
var path = require('path');
var Book = require('./book');
var fs = require('./utils/fs');
// Initialize folder structure for a book
// Read SUMMARY to created the right chapter
function initBook(root, opts) {
var book = new Book(root, opts);
var extensionToUse = '.md';
var chaptersPaths = function(chapters) {
return _.reduce(chapters || [], function(accu, chapter) {
var o = {
title: chapter.title
};
if (chapter.path) o.path = chapter.path;
return accu.concat(
[o].concat(chaptersPaths(chapter.articles))
);
}, []);
};
book.log.info.ln('init book at', root);
return fs.mkdirp(root)
.then(function() {
book.log.info.ln('detect structure from SUMMARY (if it exists)');
return book.parseSummary();
})
.fail(function() {
return Q();
})
.then(function() {
var summary = book.summaryFile || 'SUMMARY.md';
var chapters = book.summary.chapters || [];
extensionToUse = path.extname(summary);
if (chapters.length === 0) {
chapters = [
{
title: 'Summary',
path: 'SUMMARY'+extensionToUse
},
{
title: 'Introduction',
path: 'README'+extensionToUse
}
];
}
return Q(chaptersPaths(chapters));
})
.then(function(chapters) {
// Create files that don't exist
return Q.all(_.map(chapters, function(chapter) {
if (!chapter.path) return Q();
var absolutePath = path.resolve(book.root, chapter.path);
return fs.exists(absolutePath)
.then(function(exists) {
if(exists) {
book.log.info.ln('found', chapter.path);
return;
} else {
book.log.info.ln('create', chapter.path);
}
return fs.mkdirp(path.dirname(absolutePath))
.then(function() {
return fs.writeFile(absolutePath, '# '+chapter.title+'\n');
});
});
}));
})
.then(function() {
book.log.info.ln('initialization is finished');
});
}
module.exports = initBook;
-8
View File
@@ -1,8 +0,0 @@
module.exports = {
summary: require('./summary'),
langs: require('./langs'),
page: require('./page'),
lex: require('./lex'),
progress: require('./progress'),
navigation: require('./navigation'),
};
-23
View File
@@ -1,23 +0,0 @@
var _ = require("lodash")
var parseSummary = require("./summary");
var parseLangs = function(content) {
var summary = parseSummary(content);
return {
list: _.chain(summary.chapters)
.filter(function(entry) {
return entry.path != null;
})
.map(function(entry) {
return {
title: entry.title,
path: entry.path,
lang: entry.path.replace("/", "")
};
})
.value()
}
};
module.exports = parseLangs;
-74
View File
@@ -1,74 +0,0 @@
var _ = require('lodash');
var marked = require('marked');
// Split a page up into sections (lesson, exercises, ...)
function splitSections(nodes) {
var section = [];
return _.reduce(nodes, function(sections, el) {
if(el.type === 'hr') {
sections.push(section);
section = [];
} else {
section.push(el);
}
return sections;
}, []).concat([section]); // Add remaining nodes
}
// What is the type of this section
function sectionType(nodes, idx) {
var codeNodes = _.filter(nodes, {
type: 'code'
}).length;
if(codeNodes === 3 && (idx % 2) == 1) {
return 'exercise';
}
return 'normal';
}
// Generate a uniqueId to identify this section in our code
function sectionId(section, idx) {
return _.uniqueId('gitbook_');
}
function lexPage(src) {
// Lex file
var nodes = marked.lexer(src);
return _.chain(splitSections(nodes))
.map(function(section, idx) {
// Detect section type
section.type = sectionType(section, idx);
return section;
})
.map(function(section, idx) {
// Give each section an ID
section.id = sectionId(section, idx);
return section;
})
.filter(function(section) {
return !_.isEmpty(section);
})
.reduce(function(sections, section) {
var last = _.last(sections);
// Merge normal sections together
if(last && last.type === section.type && last.type === 'normal') {
last.push.apply(last, [{'type': 'hr'}].concat(section));
} else {
// Add to list of sections
sections.push(section);
}
return sections;
}, [])
.value();
}
// Exports
module.exports = lexPage;
-89
View File
@@ -1,89 +0,0 @@
var _ = require('lodash');
// Cleans up an article/chapter object
// remove 'articles' attributes
function clean(obj) {
return obj && _.omit(obj, ['articles']);
}
// Returns from a summary a map of
/*
{
"file/path.md": {
prev: ...,
next: ...,
},
...
}
*/
function navigation(summary, files) {
// Support single files as well as list
files = _.isArray(files) ? files : (_.isString(files) ? [files] : null);
// Mapping of prev/next for a give path
var mapping = {};
// Special README nav
var README_NAV = {
path: 'README.md',
title: 'Introduction',
};
// Walk the chapter/article tree and create navigation entires
_.each(summary.chapters, function(chapter, idx, chapters) {
// Skip if no path
if(!chapter.path) return;
var currentChapter = clean(chapter);
var prevChapter = (idx-1 < 0) ? README_NAV : chapters[idx-1];
var nextChapter = (idx+1 >= chapters.length) ? null : chapters[idx+1];
var prev = (!prevChapter || _.isEmpty(prevChapter.articles)) ?
prevChapter : _.last(prevChapter.articles);
var next = (!chapter || _.isEmpty(chapter.articles)) ?
nextChapter : _.first(chapter.articles);
// Add chapter mapping
mapping[chapter.path] = {
title: chapter.title,
prev: clean(prev),
next: clean(next),
level: (idx+1).toString(),
};
// Check a chapter's articles
_.each(chapter.articles, function(article, _idx, articles) {
// Skip if no path
if(!article.path) return;
var prev = (_idx-1 < 0) ? currentChapter : clean(articles[_idx-1]);
var next = (_idx+1 >= articles.length) ? nextChapter : clean(articles[_idx+1]);
mapping[article.path] = {
title: article.title,
prev: clean(prev),
next: clean(next),
level: [idx+1, _idx+1].join('.'),
};
});
});
// Hack for README.html
mapping['README.md'] = {
title: README_NAV.title,
prev: null,
next: clean(summary.chapters[0]),
level: '0',
};
// Filter for only files we want
if(files) {
return _.pick(mapping, files);
}
return mapping;
}
// Exports
module.exports = navigation;
-89
View File
@@ -1,89 +0,0 @@
var _ = require('lodash');
var marked = require('marked');
var hljs = require('highlight.js');
var lex = require('./lex');
var renderer = require('./renderer');
var lnormalize = require('../utils/lang').normalize;
// Synchronous highlighting with highlight.js
marked.setOptions({
highlight: function (code, lang) {
try {
return hljs.highlight(lang, code).value;
} catch(e) {
return hljs.highlightAuto(code).value;
}
}
});
// Render a section using our custom renderer
function render(section, _options) {
// Copy section
section = _.toArray(section);
// marked's Render expects this, we don't use it yet
section.links = {};
// Build options using defaults and our custom renderer
var options = _.extend({}, marked.defaults, {
renderer: renderer(null, _options)
});
return marked.parser(section, options);
}
function parsePage(src, options) {
options = options || {};
// Lex if not already lexed
return (_.isArray(src) ? src : lex(src))
.map(function(section) {
// Transform given type
if(section.type === 'exercise') {
var nonCodeNodes = _.reject(section, {
'type': 'code'
});
var codeNodes = _.filter(section, {
'type': 'code'
});
// Languages in code blocks
var langs = _.pluck(codeNodes, 'lang').map(lnormalize);
// Check that they are all the same
var validLangs = _.all(_.map(langs, function(lang) {
return lang && lang === langs[0];
}));
// Main language
var lang = validLangs ? langs[0] : null;
return {
id: section.id,
type: section.type,
content: render(nonCodeNodes),
lang: lang,
code: {
base: codeNodes[0].text,
solution: codeNodes[1].text,
validation: codeNodes[2].text,
}
};
}
// Render normal pages
return {
id: section.id,
type: section.type,
content: render(section, options)
};
});
}
// Exports
module.exports = parsePage;
-94
View File
@@ -1,94 +0,0 @@
var url = require('url');
var inherits = require('util').inherits;
var path = require('path');
var marked = require('marked');
function GitBookRenderer(options, extra_options) {
if(!(this instanceof GitBookRenderer)) {
return new GitBookRenderer(options, extra_options);
}
GitBookRenderer.super_.call(this, options);
this._extra_options = extra_options;
}
inherits(GitBookRenderer, marked.Renderer);
GitBookRenderer.prototype._unsanitized = function(href) {
var prot = '';
try {
prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return true;
}
if(prot.indexOf('javascript:') === 0) {
return true;
}
return false;
};
GitBookRenderer.prototype.link = function(href, title, text) {
// Don't build if it looks malicious
if (this.options.sanitize && this._unsanitized(href)) {
return '';
}
// Parsed version of the url
var parsed = url.parse(href);
var o = this._extra_options;
// Relative link, rewrite it to point to github repo
if(!parsed.protocol && parsed.path[0] != '/' && o && o.repo && o.dir) {
href = 'https://github.com/' + o.repo + '/blob' + path.normalize(path.join(
'/',
o.dir,
href
));
parsed = url.parse(href);
}
// Generate HTML for link
var out = '<a href="' + href + '"';
// Title if no null
if (title) {
out += ' title="' + title + '"';
}
// Target blank if external
if(parsed.protocol) {
out += ' target="_blank"';
}
out += '>' + text + '</a>';
return out;
};
GitBookRenderer.prototype.image = function(href, title, text) {
// Our "fixed" href
var _href = href;
// Parsed version of the url
var parsed = url.parse(href);
// Options
var o = this._extra_options;
// Relative image, rewrite it depending output
if(!parsed.protocol && parsed.path[0] != '/' && o && o.dir && o.outdir) {
_href = path.relative(o.outdir, path.normalize(path.join(
o.dir,
href
)));
}
return GitBookRenderer.super_.prototype.image.call(this, _href, title, text);
};
// Exports
module.exports = GitBookRenderer;
-117
View File
@@ -1,117 +0,0 @@
var _ = require('lodash');
var marked = require('marked');
// Utility function for splitting a list into groups
function splitBy(list, starter, ender) {
var starts = 0;
var ends = 0;
var group = [];
// Groups
return _.reduce(list, function(groups, value) {
// Ignore start and end delimiters in resulted groups
if(starter(value)) {
starts++;
} else if(ender(value)) {
ends++;
}
// Add current value to group
group.push(value);
// We've got a matching
if(starts === ends && starts !== 0) {
// Add group to end groups
// (remove starter and ender token)
groups.push(group.slice(1, -1));
// Reset group
group = [];
}
return groups;
}, []);
}
function listSplit(nodes, start_type, end_type) {
return splitBy(nodes, function(el) {
return el.type === start_type;
}, function(el) {
return el.type === end_type;
});
}
// Get the biggest list
// out of a list of marked nodes
function filterList(nodes) {
return _.chain(nodes)
.toArray()
.rest(function(el) {
// Get everything after list_start
return el.type !== 'list_start';
})
.reverse()
.rest(function(el) {
// Get everything after list_end (remember we're reversed)
return el.type !== 'list_end';
})
.reverse()
.value().slice(1, -1);
}
// Parses an Article or Chapter title
// supports extracting links
function parseTitle(src, nums) {
// Check if it's a link
var matches = marked.InlineLexer.rules.link.exec(src);
var level = nums.join('.');
// Not a link, return plain text
if(!matches) {
return {
title: src,
level: level,
path: null,
};
}
return {
title: matches[1],
level: level,
// Replace .md references with .html
path: matches[2],
};
}
function parseArticle(chapterNum, nodes, idx) {
return parseTitle(_.first(nodes).text, [chapterNum, idx+1]);
}
function parseChapter(nodes, idx) {
return _.extend(parseTitle(_.first(nodes).text, [idx+1]), {
articles: _.map(listSplit(filterList(nodes), 'list_item_start', 'list_item_end'), parseArticle.bind(null, idx+1))
});
}
function parseSummary(src) {
var nodes = marked.lexer(src);
// Get out list of chapters
var chapterList = filterList(nodes);
// Split out chapter sections
var chapters = _.chain(listSplit(chapterList, 'list_item_start', 'list_item_end'))
.map(parseChapter)
.value();
return {
chapters: chapters
};
}
// Exports
module.exports = parseSummary;
+241
View File
@@ -0,0 +1,241 @@
var _ = require('lodash');
var Q = require('q');
var path = require('path');
var url = require('url');
var fs = require('./utils/fs');
var resolve = require('resolve');
var mergeDefaults = require('merge-defaults');
var jsonschema = require('jsonschema');
var jsonSchemaDefaults = require('json-schema-defaults');
var version = require('./version');
var PLUGIN_PREFIX = 'gitbook-plugin-';
// Return an absolute name for the plugin (the one on NPM)
function absoluteName(name) {
if (name.indexOf(PLUGIN_PREFIX) === 0) return name;
return [PLUGIN_PREFIX, name].join('');
}
var Plugin = function(book, name) {
this.book = book;
this.name = absoluteName(name);
this.packageInfos = {};
this.infos = {};
// Bind methods
_.bindAll(this);
_.each([
absoluteName(name),
name
], function(_name) {
// Load from the book
if (this.load(_name, book.root)) return false;
// Load from default plugins
if (this.load(_name, __dirname)) return false;
}, this);
};
// Type of plugins resources
Plugin.RESOURCES = ['js', 'css'];
Plugin.HOOKS = [
'init', 'finish', 'finish:before', 'config', 'page', 'page:before'
];
// Return the reduce name for the plugin
// "gitbook-plugin-test" -> "test"
// Return a relative name for the plugin (the one on GitBook)
Plugin.prototype.reducedName = function() {
return this.name.replace(PLUGIN_PREFIX, '');
};
// Load from a name
Plugin.prototype.load = function(name, baseDir) {
try {
var res = resolve.sync(name+'/package.json', { basedir: baseDir });
this.baseDir = path.dirname(res);
this.packageInfos = require(res);
this.infos = require(resolve.sync(name, { basedir: baseDir }));
this.name = this.packageInfos.name;
return true;
} catch (e) {
this.packageInfos = {};
this.infos = {};
return false;
}
};
Plugin.prototype.normalizeResource = function(resource) {
// Parse the resource path
var parsed = url.parse(resource);
// This is a remote resource
// so we will simply link to using it's URL
if (parsed.protocol) {
return {
'url': resource
};
}
// This will be copied over from disk
// and shipped with the book's build
return { 'path': this.name+'/'+resource };
};
// Return resources
Plugin.prototype._getResources = function(base) {
base = base;
var book = this.infos[base];
// Compatibility with version 1.x.x
if (base == 'website') book = book || this.infos.book;
// Nothing specified, fallback to default
if (!book) {
return Q({});
}
// Dynamic function
if(typeof book === 'function') {
// Call giving it the context of our book
return Q().then(book.bind(this.book));
}
// Plain data object
return Q(_.cloneDeep(book));
};
// Normalize resources and return them
Plugin.prototype.getResources = function(base) {
var that = this;
return this._getResources(base)
.then(function(resources) {
_.each(Plugin.RESOURCES, function(resourceType) {
resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource);
});
return resources;
});
};
// Normalize filters and return them
Plugin.prototype.getFilters = function() {
return this.infos.filters || {};
};
// Normalize blocks and return them
Plugin.prototype.getBlocks = function() {
return this.infos.blocks || {};
};
// Test if it's a valid plugin
Plugin.prototype.isValid = function() {
var that = this;
var isValid = (
this.packageInfos &&
this.packageInfos.name &&
this.packageInfos.engines &&
this.packageInfos.engines.gitbook &&
version.satisfies(this.packageInfos.engines.gitbook)
);
// Valid hooks
_.each(this.infos.hooks, function(hook, hookName) {
if (_.contains(Plugin.HOOKS, hookName)) return;
that.book.log.warn.ln('Hook "'+hookName+'"" used by plugin "'+that.packageInfos.name+'" has been removed or is deprecated');
});
return isValid;
};
// Normalize, validate configuration for this plugin using its schema
// Throw an error when shcema is not respected
Plugin.prototype.validateConfig = function(config) {
var that = this;
return Q()
.then(function() {
var schema = that.packageInfos.gitbook || {};
if (!schema) return config;
// Normalize schema
schema.id = '/pluginsConfig.'+that.reducedName();
schema.type = 'object';
// Validate and throw if invalid
var v = new jsonschema.Validator();
var result = v.validate(config, schema, {
propertyName: 'pluginsConfig.'+that.reducedName()
});
// Throw error
if (result.errors.length > 0) {
throw new Error('Configuration Error: '+result.errors[0].stack);
}
// Insert default values
var defaults = jsonSchemaDefaults(schema);
return mergeDefaults(config, defaults);
});
};
// Resolve file path
Plugin.prototype.resolveFile = function(filename) {
return path.resolve(this.baseDir, filename);
};
// Resolve file path
Plugin.prototype.callHook = function(name, data) {
// Our book will be the context to apply
var context = this.book;
var hookFunc = this.infos.hooks? this.infos.hooks[name] : null;
data = data || {};
if (!hookFunc) return Q(data);
this.book.log.debug.ln('call hook', name);
if (!_.contains(Plugin.HOOKS, name)) this.book.log.warn.ln('hook "'+name+'" used by plugin "'+this.name+'" is deprecated, and will be removed in the coming versions');
return Q()
.then(function() {
return hookFunc.apply(context, [data]);
});
};
// Copy plugin assets fodler
Plugin.prototype.copyAssets = function(out, base) {
var that = this;
return this.getResources(base)
.get('assets')
.then(function(assets) {
// Assets are undefined
if(!assets) return false;
return fs.copy(
that.resolveFile(assets),
out
).then(_.constant(true));
}, _.constant(false));
};
// Get config from book
Plugin.prototype.getConfig = function() {
return this.book.config.get('pluginsConfig.'+this.reducedName(), {});
};
// Set configuration for this plugin
Plugin.prototype.setConfig = function(values) {
return this.book.config.set('pluginsConfig.'+this.reducedName(), values);
};
module.exports = Plugin;
+230
View File
@@ -0,0 +1,230 @@
var _ = require('lodash');
var Q = require('q');
var npmi = require('npmi');
var npm = require('npm');
var semver = require('semver');
var Plugin = require('./plugin');
var version = require('./version');
var initNPM = _.memoize(function() {
return Q.nfcall(npm.load, { silent: true, loglevel: 'silent' });
});
var PluginsList = function(book, plugins) {
this.book = book;
this.log = this.book.log;
// List of Plugin objects
this.list = [];
// List of names of failed plugins
this.failed = [];
// Namespaces
this.namespaces = _.chain(['website', 'ebook'])
.map(function(namespace) {
return [
namespace,
{
html: {},
resources: _.chain(Plugin.RESOURCES)
.map(function(type) {
return [type, []];
})
.object()
.value()
}
];
})
.object()
.value();
// Bind methods
_.bindAll(this);
if (plugins) this.load(plugins);
};
// return count of plugins
PluginsList.prototype.count = function() {
return this.list.length;
};
// Add and load a plugin
PluginsList.prototype.load = function(plugin) {
var that = this;
if (_.isArray(plugin)) {
return _.reduce(plugin, function(prev, p) {
return prev.then(function() {
return that.load(p);
});
}, Q());
}
if (_.isObject(plugin) && !(plugin instanceof Plugin)) plugin = plugin.name;
if (_.isString(plugin)) plugin = new Plugin(this.book, plugin);
that.log.info('load plugin', plugin.name, '....');
if (!plugin.isValid()) {
that.log.info.fail();
that.failed.push(plugin.name);
return Q();
} else {
that.log.info.ok();
// Push in the list
that.list.push(plugin);
}
return Q()
// Validate and normalize configuration
.then(function() {
var config = plugin.getConfig();
return plugin.validateConfig(config);
})
.then(function(config) {
// Update configuration
plugin.setConfig(config);
// Extract filters
that.book.template.addFilters(plugin.getFilters());
// Extract blocks
that.book.template.addBlocks(plugin.getBlocks());
return _.reduce(_.keys(that.namespaces), function(prev, namespaceName) {
return prev.then(function() {
return plugin.getResources(namespaceName)
.then(function(plResources) {
var namespace = that.namespaces[namespaceName];
// Extract js and css
_.each(Plugin.RESOURCES, function(resourceType) {
namespace.resources[resourceType] = (namespace.resources[resourceType] || []).concat(plResources[resourceType] || []);
});
// Map of html resources by name added by each plugin
_.each(plResources.html || {}, function(value, tag) {
// Turn into function if not one already
if (!_.isFunction(value)) value = _.constant(value);
namespace.html[tag] = namespace.html[tag] || [];
namespace.html[tag].push(value);
});
});
});
}, Q());
});
};
// Call a hook
PluginsList.prototype.hook = function(name, data) {
return _.reduce(this.list, function(prev, plugin) {
return prev.then(function(ret) {
return plugin.callHook(name, ret);
});
}, Q(data));
};
// Return a template from a plugin
PluginsList.prototype.template = function(name) {
var withTpl = _.find(this.list, function(plugin) {
return (
plugin.infos.templates &&
plugin.infos.templates[name]
);
});
if (!withTpl) return null;
return withTpl.resolveFile(withTpl.infos.templates[name]);
};
// Return an html snippet
PluginsList.prototype.html = function(namespace, tag, context, options) {
var htmlSnippets = this.namespaces[namespace].html[tag];
return _.map(htmlSnippets || [], function(code) {
return code.call(context, options);
}).join('\n');
};
// Return a resources map for a namespace
PluginsList.prototype.resources = function(namespace) {
return this.namespaces[namespace].resources;
};
// Install plugins from a book
PluginsList.prototype.install = function() {
var that = this;
// Remove defaults (no need to install)
var plugins = _.reject(that.book.options.plugins, {
isDefault: true
});
// Install plugins one by one
that.book.log.info.ln(plugins.length+' plugins to install');
return _.reduce(plugins, function(prev, plugin) {
return prev.then(function() {
var fullname = 'gitbook-plugin-'+plugin.name;
return Q()
// Resolve version if needed
.then(function() {
if (plugin.version) return plugin.version;
that.book.log.info.ln('No version specified, resolve plugin', plugin.name);
return initNPM()
.then(function() {
return Q.nfcall(npm.commands.view, [fullname+'@*', 'engines'], true);
})
.then(function(versions) {
return _.chain(versions)
.pairs()
.map(function(v) {
return {
version: v[0],
gitbook: (v[1].engines || {}).gitbook
};
})
.filter(function(v) {
return v.gitbook && version.satisfies(v.gitbook);
})
.sort(function(v1, v2) {
return semver.lt(v1.version, v2.version)? 1 : -1;
})
.pluck('version')
.first()
.value();
});
})
// Install the plugin with the resolved version
.then(function(version) {
if (!version) {
throw 'Found no satisfactory version for plugin '+plugin.name;
}
that.book.log.info.ln('install plugin', plugin.name, 'from npm ('+fullname+') with version', version);
return Q.nfcall(npmi, {
'name': fullname,
'version': version,
'path': that.book.root,
'npmLoad': {
'loglevel': 'silent',
'loaded': true,
'prefix': that.book.root
}
});
})
.then(function() {
that.book.log.info.ok('plugin', plugin.name, 'installed with success');
});
});
}, Q());
};
module.exports = PluginsList;
+466
View File
@@ -0,0 +1,466 @@
var _ = require('lodash');
var Q = require('q');
var path = require('path');
var nunjucks = require('nunjucks');
var parsers = require('gitbook-parsers');
var escapeStringRegexp = require('escape-string-regexp');
var batch = require('./utils/batch');
var pkg = require('../package.json');
var defaultBlocks = require('./blocks');
var BookLoader = require('./conrefs_loader');
// Normalize result from a block
function normBlockResult(blk) {
if (_.isString(blk)) blk = { body: blk };
return blk;
}
var TemplateEngine = function(book) {
var that = this;
this.book = book;
this.log = this.book.log;
// Template loader
this.loader = new BookLoader(book, {
// Replace shortcuts in imported files
interpolate: function(filepath, source) {
var parser = parsers.get(path.extname(filepath));
var type = parser? parser.name : null;
return that.applyShortcuts(type, source);
}
});
// Nunjucks env
this.env = new nunjucks.Environment(
this.loader,
{
// Escaping is done after by the markdown parser
autoescape: false,
// Tags
tags: {
blockStart: '{%',
blockEnd: '%}',
variableStart: '{{',
variableEnd: '}}',
commentStart: '{###',
commentEnd: '###}'
}
}
);
// List of tags shortcuts
this.shortcuts = [];
// Map of blocks bodies (that requires post-processing)
this.blockBodies = {};
// Map of added blocks
this.blocks = {};
// Bind methods
_.bindAll(this);
// Add default blocks
this.addBlocks(defaultBlocks);
};
// Process the result of block in a context
TemplateEngine.prototype.processBlock = function(blk) {
blk = _.defaults(blk, {
parse: false,
post: undefined
});
blk.id = _.uniqueId('blk');
var toAdd = (!blk.parse) || (blk.post !== undefined);
// Add to global map
if (toAdd) this.blockBodies[blk.id] = blk;
// Parsable block, just return it
if (blk.parse) {
return blk.body;
}
// Return it as a position marker
return '@%@'+blk.id+'@%@';
};
// Replace position markers of blocks by body after processing
// This is done to avoid that markdown/asciidoc processer parse the block content
TemplateEngine.prototype.replaceBlocks = function(content) {
var that = this;
return content.replace(/\@\%\@([\s\S]+?)\@\%\@/g, function(match, key) {
var blk = that.blockBodies[key];
if (!blk) return match;
var body = blk.body;
return body;
});
};
// Bind a function to a context
TemplateEngine.prototype.bindContext = function(func) {
var that = this;
return function() {
var ctx = {
ctx: this.ctx,
book: that.book,
generator: that.book.options.generator
};
return func.apply(ctx, arguments);
};
};
// Add filter
TemplateEngine.prototype.addFilter = function(filterName, func) {
try {
this.env.getFilter(filterName);
this.log.warn.ln('conflict in filters, \''+filterName+'\' is already set');
return false;
} catch(e) {
// Filter doesn't exist
}
this.log.debug.ln('add filter \''+filterName+'\'');
this.env.addFilter(filterName, this.bindContext(function() {
var ctx = this;
var args = Array.prototype.slice.apply(arguments);
var callback = _.last(args);
Q()
.then(function() {
return func.apply(ctx, args.slice(0, -1));
})
.nodeify(callback);
}), true);
return true;
};
// Add multiple filters
TemplateEngine.prototype.addFilters = function(filters) {
_.each(filters, function(filter, name) {
this.addFilter(name, filter);
}, this);
};
// Return nunjucks extension name of a block
TemplateEngine.prototype.blockExtName = function(name) {
return 'Block'+name+'Extension';
};
// Test if a block is defined
TemplateEngine.prototype.hasBlock = function(name) {
return this.env.hasExtension(this.blockExtName(name));
};
// Remove a block
TemplateEngine.prototype.removeBlock = function(name) {
if (!this.hasBlock(name)) return;
// Remove nunjucks extension
this.env.removeExtension(this.blockExtName(name));
// Cleanup shortcuts
this.shortcuts = _.reject(this.shortcuts, {
block: name
});
};
// Add a block
TemplateEngine.prototype.addBlock = function(name, block) {
var that = this, Ext, extName;
if (_.isFunction(block)) block = { process: block };
block = _.defaults(block || {}, {
shortcuts: [],
end: 'end'+name,
process: _.identity,
blocks: []
});
extName = this.blockExtName(name);
if (this.hasBlock(name) && !defaultBlocks[name]) {
this.log.warn.ln('conflict in blocks, \''+name+'\' is already defined');
}
// Cleanup previous block
this.removeBlock(name);
this.log.debug.ln('add block \''+name+'\'');
this.blocks[name] = block;
Ext = function () {
this.tags = [name];
this.parse = function(parser, nodes) {
var body = null;
var lastBlockName = null;
var lastBlockArgs = null;
var allBlocks = block.blocks.concat([block.end]);
var subbodies = {};
var tok = parser.nextToken();
var args = parser.parseSignature(null, true);
parser.advanceAfterBlockEnd(tok.value);
while (1) {
// Read body
var currentBody = parser.parseUntilBlocks.apply(parser, allBlocks);
// Handle body with previous block name and args
if (lastBlockName) {
subbodies[lastBlockName] = subbodies[lastBlockName] || [];
subbodies[lastBlockName].push({
body: currentBody,
args: lastBlockArgs
});
} else {
body = currentBody;
}
// Read new block
lastBlockName = parser.peekToken().value;
if (lastBlockName == block.end) {
break;
}
// Parse signature and move to the end of the block
lastBlockArgs = parser.parseSignature(null, true);
parser.advanceAfterBlockEnd(lastBlockName);
}
parser.advanceAfterBlockEnd();
var bodies = [body];
_.each(block.blocks, function(blockName) {
subbodies[blockName] = subbodies[blockName] || [];
if (subbodies[blockName].length === 0) {
subbodies[blockName].push({
args: new nodes.NodeList(),
body: new nodes.NodeList()
});
}
bodies.push(subbodies[blockName][0].body);
});
return new nodes.CallExtensionAsync(this, 'run', args, bodies);
};
this.run = function(context) {
var args = Array.prototype.slice.call(arguments, 1);
var callback = args.pop();
// Extract blocks
var blocks = args
.concat([])
.slice(-block.blocks.length);
// Eliminate blocks from list
if (block.blocks.length > 0) args = args.slice(0, -block.blocks.length);
// Extract main body and kwargs
var body = args.pop();
var kwargs = _.isObject(_.last(args))? args.pop() : {};
// Extract blocks body
var _blocks = _.map(block.blocks, function(blockName, i){
return {
name: blockName,
body: blocks[i]()
};
});
Q()
.then(function() {
return that.applyBlock(name, {
body: body(),
args: args,
kwargs: kwargs,
blocks: _blocks
}, context);
})
// process the block returned
.then(that.processBlock)
.nodeify(callback);
};
};
// Add the Extension
this.env.addExtension(extName, new Ext());
// Add shortcuts
if (!_.isArray(block.shortcuts)) block.shortcuts = [block.shortcuts];
_.each(block.shortcuts, function(shortcut) {
this.log.debug.ln('add template shortcut from \''+shortcut.start+'\' to block \''+name+'\' for parsers ', shortcut.parsers);
this.shortcuts.push({
block: name,
parsers: shortcut.parsers,
start: shortcut.start,
end: shortcut.end,
tag: {
start: name,
end: block.end
}
});
}, this);
};
// Add multiple blocks
TemplateEngine.prototype.addBlocks = function(blocks) {
_.each(blocks, function(block, name) {
this.addBlock(name, block);
}, this);
};
// Apply a block to some content
// This method result depends on the type of block (async or sync)
TemplateEngine.prototype.applyBlock = function(name, blk, ctx) {
var func, block, r;
block = this.blocks[name];
if (!block) throw new Error('Block not found \''+name+'\'');
if (_.isString(blk)) {
blk = {
body: blk
};
}
blk = _.defaults(blk, {
args: [],
kwargs: {},
blocks: []
});
// Bind and call block processor
func = this.bindContext(block.process);
r = func.call(ctx || {}, blk);
if (Q.isPromise(r)) return r.then(normBlockResult);
else return normBlockResult(r);
};
// Apply a shortcut to a string
TemplateEngine.prototype._applyShortcut = function(parser, content, shortcut) {
if (!_.contains(shortcut.parsers, parser)) return content;
var regex = new RegExp(
escapeStringRegexp(shortcut.start) + '([\\s\\S]*?[^\\$])' + escapeStringRegexp(shortcut.end),
'g'
);
return content.replace(regex, function(all, match) {
return '{% '+shortcut.tag.start+' %}'+ match + '{% '+shortcut.tag.end+' %}';
});
};
// Apply all shortcuts to some template string
TemplateEngine.prototype.applyShortcuts = function(type, content) {
return _.reduce(this.shortcuts, _.partial(this._applyShortcut.bind(this), type), content);
};
// Render a string from the book
TemplateEngine.prototype.renderString = function(content, context, options) {
context = _.extend({}, context, {
// Variables from book.json
book: this.book.options.variables,
// Complete book.json
config: this.book.options,
// infos about gitbook
gitbook: {
version: pkg.version,
generator: this.book.options.generator
}
});
options = _.defaults(options || {}, {
path: null,
type: null
});
if (options.path) options.path = this.book.resolve(options.path);
if (!options.type && options.path) {
var parser = parsers.get(path.extname(options.path));
options.type = parser? parser.name : null;
}
// Replace shortcuts
content = this.applyShortcuts(options.type, content);
return Q.nfcall(this.env.renderString.bind(this.env), content, context, options)
.fail(function(err) {
if (_.isString(err)) err = new Error(err);
err.message = err.message.replace(/^Error: /, '');
throw err;
});
};
// Render a file from the book
TemplateEngine.prototype.renderFile = function(filename) {
var that = this;
return that.book.readFile(filename)
.then(function(content) {
return that.renderString(content, {}, {
path: filename
});
});
};
// Render a page from the book
TemplateEngine.prototype.renderPage = function(page) {
var that = this;
return that.book.statFile(page.path)
.then(function(stat) {
var context = {
// infos about the file
file: {
path: page.path,
mtime: stat.mtime
}
};
return that.renderString(page.content, context, {
path: page.path,
type: page.type
});
});
};
// Post process content
TemplateEngine.prototype.postProcess = function(content) {
var that = this;
return Q(content)
.then(that.replaceBlocks)
.then(function(_content) {
return batch.execEach(that.blockBodies, {
max: 20,
fn: function(blk, blkId) {
return Q()
.then(function() {
if (!blk.post) return Q();
return blk.post();
})
.then(function() {
delete that.blockBodies[blkId];
});
}
})
.thenResolve(_content);
});
};
module.exports = TemplateEngine;
+52
View File
@@ -0,0 +1,52 @@
var Q = require("q");
var _ = require("lodash");
// Execute a method for all element
function execEach(items, options) {
if (_.size(items) === 0) return Q();
var concurrents = 0, d = Q.defer(), pending = [];
options = _.defaults(options || {}, {
max: 100,
fn: function() {}
});
function startItem(item, i) {
if (concurrents >= options.max) {
pending.push([item, i]);
return;
}
concurrents++;
Q()
.then(function() {
return options.fn(item, i);
})
.then(function() {
concurrents--;
// Next pending
var next = pending.shift();
if (concurrents === 0 && !next) {
d.resolve();
} else if (next) {
startItem.apply(null, next);
}
})
.fail(function(err) {
pending = [];
d.reject(err);
});
}
_.each(items, startItem);
return d.promise;
}
module.exports = {
execEach: execEach
};
+193
View File
@@ -0,0 +1,193 @@
var _ = require('lodash');
var Q = require('q');
var tmp = require('tmp');
var path = require('path');
var fs = require('graceful-fs');
var fsExtra = require('fs-extra');
var Ignore = require('fstream-ignore');
var fsUtils = {
tmp: {
file: function(opt) {
return Q.nfcall(tmp.file.bind(tmp), opt).get(0);
},
dir: function() {
return Q.nfcall(tmp.dir.bind(tmp)).get(0);
}
},
list: listFiles,
stat: Q.denodeify(fs.stat),
readdir: Q.denodeify(fs.readdir),
readFile: Q.denodeify(fs.readFile),
writeFile: writeFile,
writeStream: writeStream,
mkdirp: Q.denodeify(fsExtra.mkdirp),
copy: Q.denodeify(fsExtra.copy),
remove: Q.denodeify(fsExtra.remove),
symlink: Q.denodeify(fsExtra.symlink),
exists: function(path) {
var d = Q.defer();
fs.exists(path, d.resolve);
return d.promise;
},
findFile: findFile,
existsSync: fs.existsSync.bind(fs),
readFileSync: fs.readFileSync.bind(fs),
clean: cleanFolder,
getUniqueFilename: getUniqueFilename
};
// Write a file
function writeFile(filename, data, options) {
var d = Q.defer();
try {
fs.writeFileSync(filename, data, options);
} catch(err) {
d.reject(err);
}
d.resolve();
return d.promise;
}
// Write a stream to a file
function writeStream(filename, st) {
var d = Q.defer();
var wstream = fs.createWriteStream(filename);
wstream.on('finish', function () {
d.resolve();
});
wstream.on('error', function (err) {
d.reject(err);
});
st.on('error', function(err) {
d.reject(err);
});
st.pipe(wstream);
return d.promise;
}
// Find a filename available
function getUniqueFilename(base, filename) {
if (!filename) {
filename = base;
base = '/';
}
filename = path.resolve(base, filename);
var ext = path.extname(filename);
filename = path.join(path.dirname(filename), path.basename(filename, ext));
var _filename = filename+ext;
var i = 0;
while (fs.existsSync(filename)) {
_filename = filename+'_'+i+ext;
i = i + 1;
}
return path.relative(base, _filename);
}
// List files in a directory
function listFiles(root, options) {
options = _.defaults(options || {}, {
ignoreFiles: [],
ignoreRules: []
});
var d = Q.defer();
// Our list of files
var files = [];
var ig = Ignore({
path: root,
ignoreFiles: options.ignoreFiles
});
// Add extra rules to ignore common folders
ig.addIgnoreRules(options.ignoreRules, '__custom_stuff');
// Push each file to our list
ig.on('child', function (c) {
files.push(
c.path.substr(c.root.path.length + 1) + (c.props.Directory === true ? '/' : '')
);
});
ig.on('end', function() {
// Normalize paths on Windows
if(process.platform === 'win32') {
return d.resolve(files.map(function(file) {
return file.replace(/\\/g, '/');
}));
}
// Simply return paths otherwise
return d.resolve(files);
});
ig.on('error', d.reject);
return d.promise;
}
// Clean a folder without removing .git and .svn
// Creates it if non existant
function cleanFolder(root) {
if (!fs.existsSync(root)) return fsUtils.mkdirp(root);
return listFiles(root, {
ignoreFiles: [],
ignoreRules: [
// Skip Git and SVN stuff
'.git/',
'.svn/'
]
})
.then(function(files) {
var d = Q.defer();
_.reduce(files, function(prev, file, i) {
return prev.then(function() {
var _file = path.join(root, file);
d.notify({
i: i+1,
count: files.length,
file: _file
});
return fsUtils.remove(_file);
});
}, Q())
.then(function() {
d.resolve();
}, function(err) {
d.reject(err);
});
return d.promise;
});
}
// Find a file in a folder (case incensitive)
// Return the real filename
function findFile(root, filename) {
return Q.nfcall(fs.readdir, root)
.then(function(files) {
return _.find(files, function(file) {
return (file.toLowerCase() == filename.toLowerCase());
});
});
}
module.exports = fsUtils;
+127
View File
@@ -0,0 +1,127 @@
var Q = require('q');
var _ = require('lodash');
var path = require('path');
var crc = require('crc');
var exec = Q.denodeify(require('child_process').exec);
var URI = require('urijs');
var pathUtil = require('./path');
var fs = require('./fs');
var GIT_PREFIX = 'git+';
var GIT_TMP = null;
// Check if an url is a git dependency url
function checkGitUrl(giturl) {
return (giturl.indexOf(GIT_PREFIX) === 0);
}
// Validates a SHA in hexadecimal
function validateSha(str) {
return (/[0-9a-f]{40}/).test(str);
}
// Parse and extract infos
function parseGitUrl(giturl) {
var ref, uri, fileParts, filepath;
if (!checkGitUrl(giturl)) return null;
giturl = giturl.slice(GIT_PREFIX.length);
uri = new URI(giturl);
ref = uri.fragment() || 'master';
uri.fragment(null);
// Extract file inside the repo (after the .git)
fileParts =uri.path().split('.git');
filepath = fileParts.length > 1? fileParts.slice(1).join('.git') : '';
if (filepath[0] == '/') filepath = filepath.slice(1);
// Recreate pathname without the real filename
uri.path(_.first(fileParts)+'.git');
return {
host: uri.toString(),
ref: ref || 'master',
filepath: filepath
};
}
// Clone a git repo from a specific ref
function cloneGitRepo(host, ref) {
var isBranch = false;
ref = ref || 'master';
if (!validateSha(ref)) isBranch = true;
return Q()
// Create temporary folder to store git repos
.then(function() {
if (GIT_TMP) return;
return fs.tmp.dir()
.then(function(_tmp) {
GIT_TMP = _tmp;
});
})
// Return or clone the git repo
.then(function() {
// Unique ID for repo/ref combinaison
var repoId = crc.crc32(host+'#'+ref).toString(16);
// Absolute path to the folder
var repoPath = path.resolve(GIT_TMP, repoId);
return fs.exists(repoPath)
.then(function(doExists) {
if (doExists) return;
// Clone repo
return exec('git clone '+host+' '+repoPath)
.then(function() {
return exec('git checkout '+ref, { cwd: repoPath });
});
})
.thenResolve(repoPath);
});
}
// Get file from a git repo
function resolveFileFromGit(giturl) {
if (_.isString(giturl)) giturl = parseGitUrl(giturl);
if (!giturl) return Q(null);
// Clone or get from cache
return cloneGitRepo(giturl.host, giturl.ref)
.then(function(repo) {
// Resolve relative path
return path.resolve(repo, giturl.filepath);
});
}
// Return root of git repo from a filepath
function resolveGitRoot(filepath) {
var relativeToGit, repoId;
// No git repo cloned, or file is not in a git repository
if (!GIT_TMP || !pathUtil.isInRoot(GIT_TMP, filepath)) return null;
// Extract first directory (is the repo id)
relativeToGit = path.relative(GIT_TMP, filepath);
repoId = _.first(relativeToGit.split(path.sep));
if (!repoId) return;
// Return an absolute file
return path.resolve(GIT_TMP, repoId);
}
module.exports = {
checkUrl: checkGitUrl,
parseUrl: parseGitUrl,
resolveFile: resolveFileFromGit,
resolveRoot: resolveGitRoot
};
+80
View File
@@ -0,0 +1,80 @@
var _ = require('lodash');
var path = require('path');
var fs = require('fs');
var i18n = require('i18n');
var I18N_PATH = path.resolve(__dirname, '../../theme/i18n/');
var DEFAULT_LANGUAGE = 'en';
var LOCALES = _.map(fs.readdirSync(I18N_PATH), function(lang) {
return path.basename(lang, '.json');
});
i18n.configure({
locales: LOCALES,
directory: I18N_PATH,
defaultLocale: DEFAULT_LANGUAGE,
updateFiles: false
});
function compareLocales(lang, locale) {
var langMain = _.first(lang.split('-'));
var langSecond = _.last(lang.split('-'));
var localeMain = _.first(locale.split('-'));
var localeSecond = _.last(locale.split('-'));
if (locale == lang) return 100;
if (localeMain == langMain) return 50;
if (localeSecond == langSecond) return 20;
return 0;
}
var normalizeLanguage = _.memoize(function(lang) {
var language = _.chain(LOCALES)
.values()
.map(function(locale) {
return {
locale: locale,
score: compareLocales(lang, locale)
};
})
.filter(function(lang) {
return lang.score > 0;
})
.sortBy('score')
.pluck('locale')
.last()
.value();
return language || lang;
});
function translate(locale, phrase) {
var args = Array.prototype.slice.call(arguments, 2);
return i18n.__.apply({}, [{
locale: locale,
phrase: phrase
}].concat(args));
}
function getCatalog(locale) {
locale = normalizeLanguage(locale);
return i18n.getCatalog(locale);
}
function getLocales() {
return LOCALES;
}
function hasLocale(locale) {
return _.contains(LOCALES, locale);
}
module.exports = {
__: translate,
normalizeLanguage: normalizeLanguage,
getCatalog: getCatalog,
getLocales: getLocales,
hasLocale: hasLocale
};
+37
View File
@@ -0,0 +1,37 @@
var _ = require("lodash");
var Q = require("q");
var fs = require("./fs");
var spawn = require("spawn-cmd").spawn;
// Convert a svg file
var convertSVG = function(source, dest, options) {
if (!fs.existsSync(source)) return Q.reject(new Error("File doesn't exist: "+source));
var d = Q.defer();
options = _.defaults(options || {}, {
});
//var command = shellescape(["svgexport", source, dest]);
var child = spawn("svgexport", [source, dest]);
child.on("error", function(error) {
if (error.code == "ENOENT") error = new Error("Need to install \"svgexport\" using \"npm install svgexport -g\"");
return d.reject(error);
});
child.on("close", function(code) {
if (code === 0 && fs.existsSync(dest)) {
d.resolve();
} else {
d.reject(new Error("Error converting "+source+" into "+dest));
}
});
return d.promise;
};
module.exports = {
convertSVG: convertSVG,
INVALID: [".svg"]
};
-3
View File
@@ -1,3 +0,0 @@
module.exports = {
lang: require('./lang'),
};
-16
View File
@@ -1,16 +0,0 @@
var MAP = {
'py': 'python',
'js': 'javascript',
'rb': 'ruby',
};
function normalize(lang) {
var lower = lang.toLowerCase();
return MAP[lower] || lower;
}
// Exports
module.exports = {
normalize: normalize,
MAP: MAP
};
+82
View File
@@ -0,0 +1,82 @@
var url = require("url");
var path = require("path");
// Is the link an external link
var isExternal = function(href) {
try {
return Boolean(url.parse(href).protocol);
} catch(err) { }
return false;
};
// Return true if the link is relative
var isRelative = function(href) {
try {
var parsed = url.parse(href);
return !!(!parsed.protocol && parsed.path);
} catch(err) {}
return true;
};
// Return true if the link is an achor
var isAnchor = function(href) {
try {
var parsed = url.parse(href);
return !!(!parsed.protocol && !parsed.path && parsed.hash);
} catch(err) {}
return false;
};
// Normalize a path to be a link
var normalizeLink = function(s) {
return s.replace(/\\/g, "/");
};
// Relative to absolute path
// dir: directory parent of the file currently in rendering process
// outdir: directory parent from the html output
var toAbsolute = function(_href, dir, outdir) {
if (isExternal(_href)) return _href;
// Path "_href" inside the base folder
var hrefInRoot = path.normalize(path.join(dir, _href));
if (_href[0] == "/") hrefInRoot = path.normalize(_href.slice(1));
// Make it relative to output
_href = path.relative(outdir, hrefInRoot);
// Normalize windows paths
_href = normalizeLink(_href);
return _href;
};
// Join links
var join = function() {
var _href = path.join.apply(path, arguments);
return normalizeLink(_href);
};
// Change extension
var changeExtension = function(filename, newext) {
return path.join(
path.dirname(filename),
path.basename(filename, path.extname(filename))+newext
);
};
module.exports = {
isAnchor: isAnchor,
isRelative: isRelative,
isExternal: isExternal,
toAbsolute: toAbsolute,
join: join,
changeExtension: changeExtension,
normalize: normalizeLink
};
+102
View File
@@ -0,0 +1,102 @@
var _ = require("lodash");
var util = require("util");
var color = require("bash-color");
var LEVELS = {
DEBUG: 0,
INFO: 1,
WARN: 2,
ERROR: 3,
DISABLED: 10
};
var COLORS = {
DEBUG: color.purple,
INFO: color.cyan,
WARN: color.yellow,
ERROR: color.red
};
module.exports = function(_write, logLevel) {
var logger = {};
var lastChar = "\n";
if (_.isString(logLevel)) logLevel = LEVELS[logLevel.toUpperCase()];
// Write a simple message
logger.write = function(msg) {
msg = msg.toString();
lastChar = _.last(msg);
return _write(msg);
};
// Format a message
logger.format = function() {
return util.format.apply(util, arguments);
};
// Write a line
logger.writeLn = function(msg) {
return this.write((msg || "")+"\n");
};
// Write a message with a certain level
logger.log = function(level) {
if (level < logLevel) return;
var levelKey = _.findKey(LEVELS, function(v) { return v == level; });
var args = Array.prototype.slice.apply(arguments, [1]);
var msg = logger.format.apply(logger, args);
if (lastChar == "\n") {
msg = COLORS[levelKey](levelKey.toLowerCase()+":")+" "+msg;
}
return logger.write(msg);
};
logger.logLn = function() {
if (lastChar != "\n") logger.write("\n");
var args = Array.prototype.slice.apply(arguments);
args.push("\n");
logger.log.apply(logger, args);
};
// Write a OK
logger.ok = function(level) {
var args = Array.prototype.slice.apply(arguments, [1]);
var msg = logger.format.apply(logger, args);
if (arguments.length > 1) {
logger.logLn(level, color.green(">> ") + msg.trim().replace(/\n/g, color.green("\n>> ")));
} else {
logger.log(level, color.green("OK"), "\n");
}
};
// Write an "FAIL"
logger.fail = function(level) {
return logger.log(level, color.red("ERROR")+"\n");
};
_.each(_.omit(LEVELS, "DISABLED"), function(level, levelKey) {
levelKey = levelKey.toLowerCase();
logger[levelKey] = _.partial(logger.log, level);
logger[levelKey].ln = _.partial(logger.logLn, level);
logger[levelKey].ok = _.partial(logger.ok, level);
logger[levelKey].fail = _.partial(logger.fail, level);
logger[levelKey].promise = function(p) {
return p.
then(function(st) {
logger[levelKey].ok();
return st;
}, function(err) {
logger[levelKey].fail();
throw err;
});
};
});
return logger;
};
module.exports.LEVELS = LEVELS;
module.exports.COLORS = COLORS;
+79
View File
@@ -0,0 +1,79 @@
var _ = require("lodash");
// Cleans up an article/chapter object
// remove "articles" attributes
function clean(obj) {
return obj && _.omit(obj, ["articles"]);
}
function flattenChapters(chapters) {
return _.reduce(chapters, function(accu, chapter) {
return accu.concat([clean(chapter)].concat(flattenChapters(chapter.articles)));
}, []);
}
// Returns from a summary a map of
/*
{
"file/path.md": {
prev: ...,
next: ...,
},
...
}
*/
function navigation(summary, files) {
// Support single files as well as list
files = _.isArray(files) ? files : (_.isString(files) ? [files] : null);
// List of all navNodes
// Flatten chapters
var navNodes = flattenChapters(summary.chapters);
// Mapping of prev/next for a give path
var mapping = _.chain(navNodes)
.map(function(current, i) {
var prev = null, next = null;
// Skip if no path
if(!current.exists) return null;
// Find prev
prev = _.chain(navNodes.slice(0, i))
.reverse()
.find(function(node) {
return node.exists && !node.external;
})
.value();
// Find next
next = _.chain(navNodes.slice(i+1))
.find(function(node) {
return node.exists && !node.external;
})
.value();
return [current.path, {
index: i,
title: current.title,
introduction: current.introduction,
prev: prev,
next: next,
level: current.level,
}];
})
.compact()
.object()
.value();
// Filter for only files we want
if(files) {
return _.pick(mapping, files);
}
return mapping;
}
// Exports
module.exports = navigation;
+394
View File
@@ -0,0 +1,394 @@
var Q = require('q');
var _ = require('lodash');
var url = require('url');
var path = require('path');
var cheerio = require('cheerio');
var domSerializer = require('dom-serializer');
var request = require('request');
var crc = require('crc');
var slug = require('github-slugid');
var links = require('./links');
var imgUtils = require('./images');
var fs = require('./fs');
var batch = require('./batch');
var parsableExtensions = require('gitbook-parsers').extensions;
// Map of images that have been converted
var imgConversionCache = {};
// Render a cheerio dom as html
function renderDom($, dom, options) {
if (!dom && $._root && $._root.children) {
dom = $._root.children;
}
options = options|| dom.options || $._options;
return domSerializer(dom, options);
}
function replaceText($, el, search, replace, text_only ) {
return $(el).each(function(){
var node = this.firstChild,
val,
new_val,
// Elements to be removed at the end.
remove = [];
// Only continue if firstChild exists.
if ( node ) {
// Loop over all childNodes.
while (node) {
// Only process text nodes.
if ( node.nodeType === 3 ) {
// The original node value.
val = node.nodeValue;
// The new value.
new_val = val.replace( search, replace );
// Only replace text if the new value is actually different!
if ( new_val !== val ) {
if ( !text_only && /</.test( new_val ) ) {
// The new value contains HTML, set it in a slower but far more
// robust way.
$(node).before( new_val );
// Don't remove the node yet, or the loop will lose its place.
remove.push( node );
} else {
// The new value contains no HTML, so it can be set in this
// very fast, simple way.
node.nodeValue = new_val;
}
}
}
node = node.nextSibling;
}
}
// Time to remove those elements!
if (remove.length) $(remove).remove();
});
}
function pregQuote( str ) {
return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
}
// Adapt an html snippet to be relative to a base folder
function normalizeHtml(src, options) {
var $ = cheerio.load(src, {
// We should parse html without trying to normalize too much
xmlMode: false,
// SVG need some attributes to use uppercases
lowerCaseAttributeNames: false,
lowerCaseTags: false
});
var toConvert = [];
var svgContent = {};
var outputRoot = options.book.options.output;
imgConversionCache[outputRoot] = imgConversionCache[outputRoot] || {};
// Find svg images to extract and process
if (options.convertImages) {
$('svg').each(function() {
var content = renderDom($, $(this));
var svgId = _.uniqueId('svg');
var dest = svgId+'.svg';
// Generate filename
dest = '/'+fs.getUniqueFilename(outputRoot, dest);
svgContent[dest] = '<?xml version="1.0" encoding="UTF-8"?>'+content;
$(this).replaceWith($('<img>').attr('src', dest));
});
}
// Generate ID for headings
$('h1,h2,h3,h4,h5,h6').each(function() {
if ($(this).attr('id')) return;
$(this).attr('id', slug($(this).text()));
});
// Find images to normalize
$('img').each(function() {
var origin;
var src = $(this).attr('src');
if (!src) return;
var isExternal = links.isExternal(src);
// Transform as relative to the bases
if (links.isRelative(src)) {
src = links.toAbsolute(src, options.base, options.output);
}
// Convert if needed
if (options.convertImages) {
// If image is external and ebook, then downlaod the images
if (isExternal) {
origin = src;
src = '/'+crc.crc32(origin).toString(16)+path.extname(url.parse(origin).pathname);
src = links.toAbsolute(src, options.base, options.output);
isExternal = false;
}
var ext = path.extname(src);
var srcAbs = links.join('/', options.base, src);
// Test image extension
if (_.contains(imgUtils.INVALID, ext)) {
if (imgConversionCache[outputRoot][srcAbs]) {
// Already converted
src = imgConversionCache[outputRoot][srcAbs];
} else {
// Not converted yet
var dest = '';
// Replace extension
dest = links.join(path.dirname(srcAbs), path.basename(srcAbs, ext)+'.png');
dest = dest[0] == '/'? dest.slice(1) : dest;
// Get a name that doesn't exists
dest = fs.getUniqueFilename(outputRoot, dest);
options.book.log.debug.ln('detect invalid image (will be converted to png):', srcAbs);
// Add to cache
imgConversionCache[outputRoot][srcAbs] = '/'+dest;
// Push to convert
toConvert.push({
origin: origin,
content: svgContent[srcAbs],
source: isExternal? srcAbs : path.join('./', srcAbs),
dest: path.join('./', dest)
});
src = links.join('/', dest);
}
// Reset as relative to output
src = links.toAbsolute(src, options.base, options.output);
}
else if (origin) {
// Need to downlaod image
toConvert.push({
origin: origin,
source: path.join('./', srcAbs)
});
}
}
$(this).attr('src', src);
});
// Normalize links
$('a').each(function() {
var href = $(this).attr('href');
if (!href) return;
if (links.isAnchor(href)) {
// Keep it as it is
} else if (links.isRelative(href)) {
var parts = url.parse(href);
var absolutePath = links.join(options.base, parts.pathname);
var anchor = parts.hash || '';
// If is in navigation relative: transform as content
if (options.navigation[absolutePath]) {
absolutePath = options.book.contentLink(absolutePath);
}
// If md/adoc/rst files is not in summary
// or for ebook, signal all files that are outside the summary
else if (_.contains(parsableExtensions, path.extname(absolutePath)) ||
_.contains(['epub', 'pdf', 'mobi'], options.book.options.generator)) {
options.book.log.warn.ln('page', options.input, 'contains an hyperlink to resource outside spine \''+href+'\'');
}
// Transform as absolute
href = links.toAbsolute('/'+absolutePath, options.base, options.output)+anchor;
} else {
// External links
$(this).attr('target', '_blank');
}
// Transform extension
$(this).attr('href', href);
});
// Highlight code blocks
$('code').each(function() {
// Normalize language
var lang = _.chain(
($(this).attr('class') || '').split(' ')
)
.map(function(cl) {
// Markdown
if (cl.search('lang-') === 0) return cl.slice('lang-'.length);
// Asciidoc
if (cl.search('language-') === 0) return cl.slice('language-'.length);
return null;
})
.compact()
.first()
.value();
var source = $(this).text();
var blk = options.book.template.applyBlock('code', {
body: source,
kwargs: {
language: lang
}
});
if (blk.html === false) $(this).text(blk.body);
else $(this).html(blk.body);
});
// Replace glossary terms
var glossary = _.sortBy(options.glossary, function(term) {
return -term.name.length;
});
_.each(glossary, function(term) {
var r = new RegExp( '\\b(' + pregQuote(term.name.toLowerCase()) + ')\\b' , 'gi' );
var includedInFiles = false;
$('*').each(function() {
// Ignore codeblocks
if (_.contains(['code', 'pre', 'a', 'script'], this.name.toLowerCase())) return;
replaceText($, this, r, function(match) {
// Add to files index in glossary
if (!includedInFiles) {
includedInFiles = true;
term.files = term.files || [];
term.files.push(options.navigation[options.input]);
}
return '<a href=\''+links.toAbsolute('/GLOSSARY.html', options.base, options.output) + '#' + term.id+'\' class=\'glossary-term\' title=\''+_.escape(term.description)+'\'>'+match+'</a>';
});
});
});
return {
html: renderDom($),
images: toConvert
};
}
// Convert svg images to png
function convertImages(images, options) {
if (!options.convertImages) return Q();
var downloaded = [];
options.book.log.debug.ln('convert ', images.length, 'images to png');
return batch.execEach(images, {
max: 100,
fn: function(image) {
var imgin = path.resolve(options.book.options.output, image.source);
return Q()
// Write image if need to be download
.then(function() {
if (!image.origin && !_.contains(downloaded, image.origin)) return;
options.book.log.debug('download image', image.origin, '...');
downloaded.push(image.origin);
return options.book.log.debug.promise(fs.writeStream(imgin, request(image.origin)))
.fail(function(err) {
if (!_.isError(err)) err = new Error(err);
err.message = 'Fail downloading '+image.origin+': '+err.message;
throw err;
});
})
// Write svg if content
.then(function() {
if (!image.content) return;
return fs.writeFile(imgin, image.content);
})
// Convert
.then(function() {
if (!image.dest) return;
var imgout = path.resolve(options.book.options.output, image.dest);
options.book.log.debug('convert image', image.source, 'to', image.dest, '...');
return options.book.log.debug.promise(imgUtils.convertSVG(imgin, imgout));
});
}
})
.then(function() {
options.book.log.debug.ok(images.length+' images converted with success');
});
}
// Adapt page content to be relative to a base folder
function normalizePage(sections, options) {
options = _.defaults(options || {}, {
// Current book
book: null,
// Do we need to convert svg?
convertImages: false,
// Current file path
input: '.',
// Navigation to use to transform path
navigation: {},
// Directory parent of the file currently in rendering process
base: './',
// Directory parent from the html output
output: './',
// Glossary terms
glossary: []
});
// List of images to convert
var toConvert = [];
sections = _.map(sections, function(section) {
if (section.type != 'normal') return section;
var out = normalizeHtml(section.content, options);
toConvert = toConvert.concat(out.images);
section.content = out.html;
return section;
});
return Q()
.then(function() {
toConvert = _.uniq(toConvert, 'source');
return convertImages(toConvert, options);
})
.thenResolve(sections);
}
module.exports = {
normalize: normalizePage
};
+40
View File
@@ -0,0 +1,40 @@
var _ = require("lodash");
var path = require("path");
// Return true if file path is inside a folder
function isInRoot(root, filename) {
filename = path.normalize(filename);
return (filename.substr(0, root.length) === root);
}
// Resolve paths in a specific folder
// Throw error if file is outside this folder
function resolveInRoot(root) {
var input, result, err;
input = _.chain(arguments)
.toArray()
.slice(1)
.reduce(function(current, p) {
// Handle path relative to book root ("/README.md")
if (p[0] == "/" || p[0] == "\\") return p.slice(1);
return current? path.join(current, p) : path.normalize(p);
}, "")
.value();
result = path.resolve(root, input);
if (!isInRoot(root, result)) {
err = new Error("EACCESS: \"" + result + "\" not in \"" + root + "\"");
err.code = "EACCESS";
throw err;
}
return result;
}
module.exports = {
isInRoot: isInRoot,
resolveInRoot: resolveInRoot
};
@@ -1,19 +1,24 @@
var _ = require("lodash");
var _ = require('lodash');
// Returns from a navigation and a current file, a snapshot of current detailed state
var calculProgress = function(navigation, current) {
function calculProgress(navigation, current) {
var n = _.size(navigation);
var percent = 0, prevPercent = 0, currentChapter = null;
var done = true;
var chapters = _.chain(navigation)
// Transform as array
.map(function(nav, path) {
nav.path = path;
return nav;
})
// Sort entries
.sortBy(function(nav) {
return nav.level;
return nav.index;
})
.map(function(nav, i) {
// Calcul percent
nav.percent = (i * 100) / Math.max((n - 1), 1);
@@ -27,7 +32,7 @@ var calculProgress = function(navigation, current) {
} else if (done) {
prevPercent = nav.percent;
}
return nav;
})
.value();
@@ -47,4 +52,4 @@ var calculProgress = function(navigation, current) {
};
}
module.exports = calculProgress;
module.exports = calculProgress;
+94
View File
@@ -0,0 +1,94 @@
var Q = require("q");
var events = require("events");
var http = require("http");
var send = require("send");
var util = require("util");
var url = require("url");
var Server = function() {
this.running = null;
this.dir = null;
this.port = 0;
this.sockets = [];
};
util.inherits(Server, events.EventEmitter);
// Return true if the server is running
Server.prototype.isRunning = function() {
return !!this.running;
};
// Stop the server
Server.prototype.stop = function() {
var that = this;
if (!this.isRunning()) return Q();
var d = Q.defer();
this.running.close(function(err) {
that.running = null;
that.emit("state", false);
if (err) d.reject(err);
else d.resolve();
});
for (var i = 0; i < this.sockets.length; i++) {
this.sockets[i].destroy();
}
return d.promise;
};
Server.prototype.start = function(dir, port) {
var that = this, pre = Q();
port = port || 8004;
if (that.isRunning()) pre = this.stop();
return pre
.then(function() {
var d = Q.defer();
that.running = http.createServer(function(req, res){
// Render error
function error(err) {
res.statusCode = err.status || 500;
res.end(err.message);
}
// Redirect to directory"s index.html
function redirect() {
res.statusCode = 301;
res.setHeader("Location", req.url + "/");
res.end("Redirecting to " + req.url + "/");
}
// Send file
send(req, url.parse(req.url).pathname)
.root(dir)
.on("error", error)
.on("directory", redirect)
.pipe(res);
});
that.running.on("connection", function (socket) {
that.sockets.push(socket);
socket.setTimeout(4000);
socket.on("close", function () {
that.sockets.splice(that.sockets.indexOf(socket), 1);
});
});
that.running.listen(port, function(err) {
if (err) return d.reject(err);
that.port = port;
that.dir = dir;
that.emit("state", true);
d.resolve();
});
return d.promise;
});
};
module.exports = Server;
+27
View File
@@ -0,0 +1,27 @@
var _ = require("lodash");
function escapeShellArg(arg) {
var ret = "";
ret = arg.replace(/"/g, '\\"');
return "\"" + ret + "\"";
}
function optionsToShellArgs(options) {
return _.chain(options)
.map(function(value, key) {
if (value === null || value === undefined || value === false) return null;
if (value === true) return key;
return key+"="+escapeShellArg(value);
})
.compact()
.value()
.join(" ");
}
module.exports = {
escapeShellArg: escapeShellArg,
optionsToShellArgs: optionsToShellArgs,
toLowerCase: String.prototype.toLowerCase.call.bind(String.prototype.toLowerCase)
};
+40
View File
@@ -0,0 +1,40 @@
var Q = require("q");
var _ = require("lodash");
var path = require("path");
var chokidar = require("chokidar");
var parsers = require("gitbook-parsers");
function watch(dir) {
var d = Q.defer();
dir = path.resolve(dir);
var toWatch = [
"book.json", "book.js"
];
_.each(parsers.extensions, function(ext) {
toWatch.push("**/*"+ext);
});
var watcher = chokidar.watch(toWatch, {
cwd: dir,
ignored: "_book/**",
ignoreInitial: true
});
watcher.once("all", function(e, filepath) {
watcher.close();
d.resolve(filepath);
});
watcher.once("error", function(err) {
watcher.close();
d.reject(err);
});
return d.promise;
}
module.exports = watch;
+19
View File
@@ -0,0 +1,19 @@
var semver = require('semver');
var pkg = require('../package.json');
var VERSION = pkg.version;
var VERSION_STABLE = VERSION.replace(/\-(\S+)/g, '');
// Test if current current gitbook version satisfies a condition
// We can't directly use samver.satisfies since it will break all plugins when gitbook version is a prerelease (beta, alpha)
function satisfies(condition) {
// Test with real version
if (semver.satisfies(VERSION, condition)) return true;
// Test with future stable release
return semver.satisfies(VERSION_STABLE, condition);
}
module.exports = {
satisfies: satisfies
};
+70 -23
View File
@@ -1,47 +1,94 @@
{
"name": "gitbook",
"version": "0.1.2",
"version": "2.6.6",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
"dependencies": {
"q": "1.0.1",
"lodash": "2.4.1",
"marked": "0.3.2",
"marked-text-renderer": "0.0.1",
"lunr": "0.5.2",
"swig": "1.3.2",
"lodash": "3.10.1",
"graceful-fs": "3.0.5",
"resolve": "0.6.3",
"fs-extra": "0.16.5",
"fstream-ignore": "1.0.2",
"gitbook-parsers": "0.8.9",
"gitbook-plugin-highlight": "1.0.3",
"gitbook-plugin-sharing": "1.0.1",
"gitbook-plugin-search": "1.1.0",
"gitbook-plugin-fontsettings": "1.0.2",
"nunjucks": "2.2.0",
"nunjucks-autoescape": "1.0.0",
"nunjucks-filter": "1.0.0",
"i18n": "0.5.0",
"semver": "5.0.1",
"npmi": "0.1.1",
"cheerio": "0.19.0",
"gitbook-plugin-livereload": "0.0.1",
"chokidar": "~1.0.5",
"send": "0.2.0",
"fstream-ignore": "0.0.7",
"commander": "2.2.0",
"fs-extra": "0.8.1",
"highlight.js": "8.0.0",
"tmp": "0.0.23"
"tiny-lr": "0.2.1",
"tmp": "0.0.24",
"crc": "3.2.1",
"bash-color": "0.0.3",
"urijs": "1.17.0",
"request": "2.51.0",
"npm": "2.4.1",
"dom-serializer": "0.1.0",
"spawn-cmd": "0.0.2",
"escape-string-regexp": "1.0.3",
"juice": "1.5.0",
"jsonschema": "1.0.2",
"json-schema-defaults": "0.1.1",
"merge-defaults": "0.2.1",
"github-slugid": "1.0.0"
},
"devDependencies": {
"mocha": "1.18.2",
"grunt": "~0.4.2",
"grunt-cli": "0.1.11",
"grunt-contrib-less": "~0.5.0",
"grunt-contrib-requirejs": "0.4.1"
"eslint": "1.5.0",
"mocha": "2.3.2",
"should": "7.1.0",
"should-promised": "0.3.1",
"gulp": "^3.8.11",
"gulp-rename": "^1.2.2",
"gulp-uglify": "1.1.0",
"gulp-less": "3.0.2",
"gulp-minify-css": "1.0.0",
"gulp-util": "3.0.6",
"browserify": "11.0.1",
"merge-stream": "0.1.7",
"vinyl-source-stream": "1.1.0",
"jquery": "2.1.4",
"mousetrap": "1.5.3",
"font-awesome": "4.1.0",
"gitbook-markdown-css": "1.0.1"
},
"scripts": {
"test": "export TESTING=true; mocha --reporter list"
},
"bin": {
"gitbook": "./bin/gitbook.js"
"test": "node_modules/.bin/mocha --reporter spec --timeout 15000"
},
"repository": {
"type": "git",
"url": "https://github.com/GitbookIO/gitbook.git"
},
"bin": {
"gitbook": "./bin/gitbook.js"
},
"keywords": [
"git",
"book",
"gitbook"
],
"author": "Aaron O'Mullan <aaron.omullan@friendco.de>",
"license": "Apache 2",
"author": "FriendCode Inc. <contact@gitbook.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/GitbookIO/gitbook/issues"
}
},
"contributors": [
{
"name": "Aaron O'Mullan",
"email": "aaron@gitbook.com"
},
{
"name": "Samy Pessé",
"email": "samy@gitbook.com"
}
]
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 227 KiB

+69
View File
@@ -0,0 +1,69 @@
var _ = require('lodash');
var fs = require('fs');
var path = require('path');
var should = require('should');
var cheerio = require('cheerio');
require('should-promised');
should.Assertion.add('file', function(file, description) {
this.params = { actual: this.obj.toString(), operator: 'have file ' + file, message: description };
this.obj.should.have.property('options').which.is.an.Object();
this.obj.options.should.have.property('output').which.is.a.String();
this.assert(fs.existsSync(path.resolve(this.obj.options.output, file)));
});
should.Assertion.add('jsonfile', function(file, description) {
this.params = { actual: this.obj.toString(), operator: 'have valid jsonfile ' + file, message: description };
this.obj.should.have.property('options').which.is.an.Object();
this.obj.options.should.have.property('output').which.is.a.String();
this.assert(JSON.parse(fs.readFileSync(path.resolve(this.obj.options.output, file), { encoding: 'utf-8' })));
});
should.Assertion.add('html', function(rules, description) {
this.params = { actual: 'HTML string', operator: 'valid html', message: description };
var $ = cheerio.load(this.obj);
_.each(rules, function(validations, query) {
validations = _.defaults(validations || {}, {
// Select a specific element in the list of matched elements
index: null,
// Check that there is the correct count of elements
count: 1,
// Check attribute values
attributes: {},
// Trim inner text
trim: false,
// Check inner text
text: undefined
});
var $el = $(query);
// Select correct element
if (_.isNumber(validations.index)) $el = $($el.get(validations.index));
// Test number of elements
$el.length.should.be.equal(validations.count);
// Test text
if (validations.text !== undefined) {
var text = $el.text();
if (validations.trim) text = text.trim();
text.should.be.equal(validations.text);
}
// Test attributes
_.each(validations.attributes, function(value, name) {
var attr = $el.attr(name);
should(attr).be.ok();
attr.should.be.equal(value);
});
});
});
+3
View File
@@ -0,0 +1,3 @@
# Readme
Default description for the book.
+1
View File
@@ -0,0 +1 @@
# Summary
+1
View File
@@ -0,0 +1 @@
# Readme
+1
View File
@@ -0,0 +1 @@
# Summary
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
"title": "js-config"
};
+1
View File
@@ -0,0 +1 @@
# Readme
+1
View File
@@ -0,0 +1 @@
# Summary
+3
View File
@@ -0,0 +1,3 @@
{
"title": "json-config"
}
+15
View File
@@ -0,0 +1,15 @@
# Readme
<p id="test-plugin-block-shortcuts-1">$$test_block1$$</p>
<p id="test-plugin-block-shortcuts-2">{% include "./block.md" %}</p>
### Relative
<p id="t1">{% include "./hello.md" %}</p>
<p id="t2">{% include "/hello.md" %}</p>
### Git
<p id="t3">{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}</p>
<p id="t4">{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}</p>
<p id="t5">{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test3.md" %}</p>
+1
View File
@@ -0,0 +1 @@
# Summary
+1
View File
@@ -0,0 +1 @@
$$test_block2$$
+1
View File
@@ -0,0 +1 @@
Hello World
+13
View File
@@ -0,0 +1,13 @@
# Glossary
## test
Just a simple and easy to understand test.
## hakunamatata
This word is not present in the content.
## test long
This is a test with a longer text that the first entry to test order.
+10
View File
@@ -0,0 +1,10 @@
# Readme
The word test should be replaced by a glossary link.
```
But the word test should not be replaced in code blocks
```
The two words test long should be replaced by the correct glossary links.
+3
View File
@@ -0,0 +1,3 @@
# Summary
* [Page](folder/PAGE.md)
+3
View File
@@ -0,0 +1,3 @@
# Page
Just a page in a sub-directory to test relative link to glossary.
+3
View File
@@ -0,0 +1,3 @@
# Hello World
## Hello {#hello-custom}
View File
+16
View File
@@ -0,0 +1,16 @@
# Readme
Block without language
```
test 1
```
Block with a language
```lang
test 2
```
Inline code: `test 3`
Inline code with html: `<test>`
+1
View File
@@ -0,0 +1 @@
# Summary
+18
View File
@@ -0,0 +1,18 @@
# Tests for Images
# SVG relative image
### Convert SVG to PNG
![test.svg](test.svg)
### Should only convert it once
![test.svg](test.svg)
### Download remote images
![remote image](http://upload.wikimedia.org/wikipedia/commons/b/b0/NewTux.svg)
### Remote images with same filename
![youtube1](http://img.youtube.com/vi/9bZkp7q19f0/0.jpg)
![youtube2](http://img.youtube.com/vi/IkV2HQLAKHY/0.jpg)
+3
View File
@@ -0,0 +1,3 @@
# Summary
* [Page](./folder/PAGE.md)
+3
View File
@@ -0,0 +1,3 @@
### Images from other folder
![test.svg](../test.svg)
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<svg version="1.1" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360">
<title id="test-title">basic SVG tiny doc</title>
<g id="test-body-content">
<text font-family="Arial" font-size="14" text-anchor="middle" x="225" y="25">hello world</text>
</g>
<text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">Revision: 1.1</text>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
</svg>

After

Width:  |  Height:  |  Size: 730 B

+3
View File
@@ -0,0 +1,3 @@
*
!SUMMARY.md
!.gitignore
+9
View File
@@ -0,0 +1,9 @@
# Summary
* [Hello](hello.md)
* [Hello 2](hello2.md)
* Hello 3
* [Hello 4](hello3/hello4.md)
* Hello 5
* [Hello 6](hello3/hello5/hello6.md)
+4
View File
@@ -0,0 +1,4 @@
# Language
* [English](en)
* [French](fr)
+1
View File
@@ -0,0 +1 @@
# Readme
+1
View File
@@ -0,0 +1 @@
Hello
+1
View File
@@ -0,0 +1 @@
# Summary
+1
View File
@@ -0,0 +1 @@
Bonjour
+1
View File
@@ -0,0 +1 @@
# Summary
+1
View File
@@ -0,0 +1 @@
# Readme
+4
View File
@@ -0,0 +1,4 @@
# Summary
* [Folder1](folder1/README.md)
* [Folder2](folder2/README.md)

Some files were not shown because too many files have changed in this diff Show More