diff --git a/404.html b/404.html index 1e7a37e..5fde966 100644 --- a/404.html +++ b/404.html @@ -1,6 +1,6 @@ --- layout: default -title: Page not found +title: 404 permalink: /404 nav_exclude: true search_exclude: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5f0ddae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM ruby:2.6 + +ENV LC_ALL C.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US.UTF-8 + +WORKDIR /usr/src/app + +COPY Gemfile just-the-docs.gemspec ./ +RUN gem install bundler && bundle install + +EXPOSE 4000 + diff --git a/README.md b/README.md index 90dfb6f..4d1c1e8 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ Or install it yourself as: $ gem install just-the-docs +Alternatively, you can run it inside Docker while developing your site + + $ docker-compose up + ## Usage [View the documentation](https://pmarsceill.github.io/just-the-docs/) for usage information. diff --git a/_config.yml b/_config.yml index 20bf8a1..ad42809 100644 --- a/_config.yml +++ b/_config.yml @@ -19,7 +19,15 @@ baseurl: "/just-the-docs" # the subpath of your site, e.g. /blog url: "https://pmarsceill.github.io" # the base hostname & protocol for your site, e.g. http://example.com permalink: pretty -exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "package.json", "package-lock.json", "script/", "LICENSE.txt", "lib/", "bin/", "README.md", "Rakefile"] +exclude: ["node_modules/", "*.gemspec", "*.gem", "Gemfile", "Gemfile.lock", "package.json", "package-lock.json", "script/", "LICENSE.txt", "lib/", "bin/", "README.md", "Rakefile" +, "docs/tests/" +] + +# Regression tests +# By default, the pages in /docs/tests are excluded when the ste is built. +# To include them, comment-out the relevant line above. +# Uncommenting the following line doesn't work - see https://github.com/jekyll/jekyll/issues/4791 +# include: ["docs/tests/"] # Set a path/url to a logo that will be displayed instead of the title #logo: "/assets/images/just-the-docs.png" @@ -33,13 +41,13 @@ search: heading_level: 2 # Maximum amount of previews per search result # Default: 3 - previews: 3 + previews: 2 # Maximum amount of words to display before a matched word in the preview # Default: 5 - preview_words_before: 5 + preview_words_before: 3 # Maximum amount of words to display after a matched word in the preview # Default: 10 - preview_words_after: 10 + preview_words_after: 3 # Set the search token separator # Default: /[\s\-/]+/ # Example: enable support for hyphenated search words @@ -63,8 +71,8 @@ aux_links: aux_links_new_tab: false # Sort order for navigation links -nav_sort: case_insensitive # default, equivalent to nil -# nav_sort: case_sensitive # Capital letters sorted before lowercase +# nav_sort: case_insensitive # default, equivalent to nil +nav_sort: case_sensitive # Capital letters sorted before lowercase # Footer content # appears at the bottom of every page's main content @@ -86,6 +94,7 @@ gh_edit_link: true # show or hide edit this page link gh_edit_link_text: "Edit this page on GitHub" gh_edit_repository: "https://github.com/pmarsceill/just-the-docs" # the github URL for your repo gh_edit_branch: "master" # the branch that your docs is served from +# gh_edit_source: docs # the source that your files originate from gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately # Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define @@ -99,6 +108,11 @@ ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings (t plugins: - jekyll-seo-tag +kramdown: + syntax_highlighter_opts: + block: + line_numbers: false + compress_html: clippings: all comments: all @@ -106,3 +120,5 @@ compress_html: startings: [] blanklines: false profile: false + # ignore: + # envs: all diff --git a/_includes/fix_linenos.html b/_includes/fix_linenos.html new file mode 100644 index 0000000..6243fb0 --- /dev/null +++ b/_includes/fix_linenos.html @@ -0,0 +1,65 @@ +{%- comment -%} +This file can be used to fix the HTML produced by Jekyll for highlighted +code with line numbers. + +It works with `{% highlight some_language linenos %}...{% endhighlight %}` +and with the Kramdown option to add line numbers to fenced code. + +The implementation was derived from the workaround provided by +Dmitry Hrabrov (DeXP) at +https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901 + +EXPLANATION + +The HTML produced by Rouge highlighting with lie numbers is of the form +`code table`. Jekyll (<= 4.1.1) always wraps the highlighted HTML +with `pre`. This wrapping is not only unnecessary, but also transforms +the conforming HTML produced by Rouge to non-conforming HTML, which +results in HTML validation error reports. + +The fix removes the outer `pre` tags whenever they contain the pattern +``. + +Apart from avoiding HTML validation errors, the fix allows the use of +the [Jekyll layout for compressing HTML](http://jch.penibelst.de), +which relies on `pre` tags not being nested, according to +https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-172069842 + +USAGE + +(Any names can be used for `some_var` and `some_language`.) + +{% capture some_var %} +{% highlight some_language linenos %} +Some code +{% endhighlight %} +{% endcapture %} +{% include fix_linenos.html code=some_var %} + +For code fences: + +{% capture some_var %} +```some_language +Some code +``` +{% endcapture %} +{% assign some_var = some_var | markdownify %} +{% include fix_linenos.html code=some_var %} + +CAVEATS + +The above does not work when `Some code` happens to contain the matched string +`
`. + +The use of this file overwrites the variable `fix_linenos_code` with `nil`. + +{%- endcomment -%} + +{% assign fix_linenos_code = include.code %} +{% if fix_linenos_code contains '
' %} + {% assign fix_linenos_code = fix_linenos_code | replace: '
', '
' %}
+  {% assign fix_linenos_code = fix_linenos_code | replace: "
", "" %} +{% endif %} +{{ fix_linenos_code }} +{% assign fix_linenos_code = nil %} diff --git a/_includes/head.html b/_includes/head.html index 4f22497..c0f73d7 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -10,9 +10,9 @@ {% endif %} {% endunless %} - + - + {% if site.ga_tracking != nil %} @@ -27,9 +27,9 @@ {% endif %} {% if site.search_enabled != false %} - + {% endif %} - + diff --git a/_includes/nav.html b/_includes/nav.html index f2ec7e5..976dbbd 100644 --- a/_includes/nav.html +++ b/_includes/nav.html @@ -1,55 +1,100 @@ diff --git a/_includes/vendor/anchor_headings.html b/_includes/vendor/anchor_headings.html index 985f448..e9ca862 100755 --- a/_includes/vendor/anchor_headings.html +++ b/_includes/vendor/anchor_headings.html @@ -1,18 +1,44 @@ {% capture headingsWorkspace %} {% comment %} - Version 1.0.3 + Copyright (c) 2018 Vladimir "allejo" Jimenez + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. + {% endcomment %} + {% comment %} + Version 1.0.7 https://github.com/allejo/jekyll-anchor-headings "Be the pull request you wish to see in the world." ~Ben Balter Usage: - {% include anchor_headings.html html=content %} + {% include anchor_headings.html html=content anchorBody="#" %} Parameters: * html (string) - the HTML of compiled markdown generated by kramdown in Jekyll Optional Parameters: * beforeHeading (bool) : false - Set to true if the anchor should be placed _before_ the heading's content + * anchorAttrs (string) : '' - Any custom HTML attributes that will be added to the `` tag; you may NOT use `href`, `class` or `title`; + the `%heading%` and `%html_id%` placeholders are available * anchorBody (string) : '' - The content that will be placed inside the anchor; the `%heading%` placeholder is available * anchorClass (string) : '' - The class(es) that will be used for each anchor. Separate multiple classes with a space * anchorTitle (string) : '' - The `title` attribute that will be used for anchors @@ -42,17 +68,22 @@ {% assign nextChar = node | replace: '"', '' | strip | slice: 0, 1 %} {% assign headerLevel = nextChar | times: 1 %} - + {% if headerLevel == 0 %} - {% if nextChar != '<' and nextChar != '' %} + + {% assign firstChunk = node | split: '>' | first %} + + + {% unless firstChunk contains '<' %} {% capture node %}{% endcapture %} + {% assign _workspace = node | split: _closingTag %} {% assign _idWorkspace = _workspace[0] | split: 'id="' %} {% assign _idWorkspace = _idWorkspace[1] | split: '"' %} {% assign html_id = _idWorkspace[0] %} @@ -64,7 +95,7 @@ {% capture anchor %}{% endcapture %} {% if html_id and headerLevel >= minHeader and headerLevel <= maxHeader %} - {% capture anchor %}href="#{{ html_id}}" aria-labelledby="{{ html_id}}"{% endcapture %} + {% capture anchor %}href="#{{ html_id }}"{% endcapture %} {% if include.anchorClass %} {% capture anchor %}{{ anchor }} class="{{ include.anchorClass }}"{% endcapture %} @@ -74,6 +105,10 @@ {% capture anchor %}{{ anchor }} title="{{ include.anchorTitle | replace: '%heading%', header }}"{% endcapture %} {% endif %} + {% if include.anchorAttrs %} + {% capture anchor %}{{ anchor }} {{ include.anchorAttrs | replace: '%heading%', header | replace: '%html_id%', html_id }}{% endcapture %} + {% endif %} + {% capture anchor %}{{ include.anchorBody | replace: '%heading%', header | default: '' }}{% endcapture %} @@ -93,8 +128,17 @@ {{ header }}{{ anchor }} {% endif %} {{ include.bodySuffix }} - {% endcapture %} + + + {% assign chunkCount = _workspace | size %} + {% if chunkCount > 1 %} + {% capture new_heading %}{{ new_heading }}{{ _workspace | last }}{% endcapture %} + {% endif %} + {% capture edited_headings %}{{ edited_headings }}{{ new_heading }}{% endcapture %} {% endfor %} {% endcapture %}{% assign headingsWorkspace = '' %}{{ edited_headings | strip }} diff --git a/_layouts/default.html b/_layouts/default.html index 8a98f21..b60b08e 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -48,7 +48,22 @@ layout: table_wrappers