Skip to content

Commit

Permalink
ready for ver1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wshito committed Feb 27, 2021
1 parent 104d3df commit ce73222
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Splits asciidoc book's single HTML file generated by Asciidoctor into chunks by

## News

- [Ver 1.0.0 pre-release available.](https://github.com/wshito/asciidoctor-chunker/releases)
- 2020/2/27 [Ver 1.0.0 Released!](https://github.com/wshito/asciidoctor-chunker/releases)
- Non opinionated page navigation at the bottom of each page is available.
- You can insert custom css from the command line with `--css` option.
- If you have any custom elements inserted in the source html, they are handled in non-strict mode by setting `--no-strictMode` option.
- Gives warning if no relative links are available in tocs.
- The current page toc is highlighted and scrolled into view.
- 2020/2/20 Ver 0.9 is released! This is a complete re-write from the previous Lisp version. **It is re-implemented in JavaScript!** So it is super easy to setup with NodeJS! The fine tuned split options are available. Oh, and it runs a lot faster than the previous version!😊
- 2021/2/10 Started work on the more enhanced version in `javascript` branch. Please wait a couple of weeks. The new version can control any depth of sections to split. And even more, each chapter can have a different depth extraction level. The new version is written in JavaScript so it will be a lot easier to install!
- 2018/7/11 Locally linked files with `link` and `script` tags with relative paths are copied to the destination directory keeping the structure of the relative path. So the custom CSS and script files should be properly copied by `asciidoctor-chunker`.
Expand All @@ -23,6 +24,8 @@ Asciidoctor-Chunker generates chunked HTML from a single HTML generated by Ascii
1. Re-writes the relative links in order to point to the appropriate chunked files.
1. Copies the local images and linked files (with `link`, `script` and `img` tags) whose paths are relative, to the directory relative to the chunked html output. Files are only copied if they are new or modified compared to the previously copied one.
1. Adds a titlepage link in the toc and page navigation at the bottom of each page.
1. Adds non-opinionated page navigation.
1. Highlights the current page toc items and they get scrolled into the viewport.

Here is [the sample output](http://www.seinan-gu.ac.jp/~shito/asciidoctor/html_chunks/index.html) created from the [Asciidoctor User Manual](https://asciidoctor.org/docs/user-manual/). The footer on the sample page is added by setting the asciidoctor attribute and is not added by asciidoctor-chunker.

Expand Down
2 changes: 1 addition & 1 deletion dist/asciidoctor-chunker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asciidoctor-chunker",
"version": "1.0.0-alpha.1",
"version": "1.0.0",
"description": "Splits asciidoc book's single HTML file generated by Asciidoctor into chunks by chapters, sections, and subsections.",
"main": "index.mjs",
"scripts": {
Expand Down
17 changes: 13 additions & 4 deletions src/DOM.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -747,16 +747,25 @@ const cssLink$ = (outdir, cssFile) => {
const insertScript = (rootNode) => {
rootNode.find('html').append(`
<script>
function isInViewport(element) {
const rect = element.getBoundingClientRect();
function isInViewport(ele) {
const rect = ele.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
);
}
function yPosition (ele) {
const rect = ele.getBoundingClientRect();
return (rect.top - 20); // 20px above
}
let curr = document.getElementsByClassName('current');
if (!isInViewport(curr[curr.length - 1]))
curr[0].scrollIntoView({behavior: "smooth"});
if (!isInViewport(curr[curr.length - 1])) {
document.getElementById('toc').scrollTo({
top: yPosition(curr[0]),
left: 0,
behavior: 'smooth'
});
}
</script>
`);
return rootNode;
Expand Down

0 comments on commit ce73222

Please sign in to comment.