openstax_kitchen 4.1.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/changelog.yml +24 -0
- data/.github/workflows/rubocop.yml +28 -0
- data/CHANGELOG.md +60 -0
- data/Gemfile.lock +15 -6
- data/README.md +16 -0
- data/codecov.yaml +1 -0
- data/docker/rubocop +24 -0
- data/lib/kitchen/book_document.rb +1 -1
- data/lib/kitchen/chapter_element.rb +2 -2
- data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
- data/lib/kitchen/composite_page_element.rb +19 -2
- data/lib/kitchen/config.rb +7 -0
- data/lib/kitchen/directions/bake_appendix.rb +3 -1
- data/lib/kitchen/directions/bake_chapter_introductions.rb +22 -15
- data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
- data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_references/main.rb +1 -2
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +26 -12
- data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +2 -2
- data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +2 -1
- data/lib/kitchen/directions/bake_chapter_solutions/main.rb +11 -0
- data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +37 -0
- data/lib/kitchen/directions/bake_chapter_summary.rb +13 -6
- data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
- data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
- data/lib/kitchen/directions/bake_equations.rb +1 -1
- data/lib/kitchen/directions/bake_example.rb +4 -1
- data/lib/kitchen/directions/bake_figure.rb +13 -0
- data/lib/kitchen/directions/bake_first_elements.rb +7 -1
- data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
- data/lib/kitchen/directions/bake_footnotes/v1.rb +11 -8
- data/lib/kitchen/directions/bake_further_research.rb +2 -0
- data/lib/kitchen/directions/bake_index/v1.rb +3 -14
- data/lib/kitchen/directions/bake_inline_lists.rb +22 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +43 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +37 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +25 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +32 -0
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +3 -2
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +10 -1
- data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +29 -0
- data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -0
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -24
- data/lib/kitchen/directions/bake_numbered_table/v2.rb +31 -0
- data/lib/kitchen/directions/bake_preface/main.rb +2 -2
- data/lib/kitchen/directions/bake_preface/v1.rb +3 -2
- data/lib/kitchen/directions/bake_references/main.rb +7 -0
- data/lib/kitchen/directions/bake_references/v2.rb +35 -0
- data/lib/kitchen/directions/bake_toc.rb +3 -1
- data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +9 -0
- data/lib/kitchen/directions/book_answer_key_container/main.rb +2 -2
- data/lib/kitchen/directions/book_answer_key_container/v1.rb +4 -3
- data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +3 -3
- data/lib/kitchen/directions/chapter_review_container/main.rb +2 -2
- data/lib/kitchen/directions/chapter_review_container/v1.rb +4 -2
- data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +13 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +10 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +49 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +6 -2
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +27 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +84 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +2 -2
- data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +11 -7
- data/lib/kitchen/document.rb +19 -52
- data/lib/kitchen/element_base.rb +48 -12
- data/lib/kitchen/element_enumerator_base.rb +24 -1
- data/lib/kitchen/element_enumerator_factory.rb +19 -7
- data/lib/kitchen/exercise_element.rb +2 -2
- data/lib/kitchen/id_tracker.rb +68 -0
- data/lib/kitchen/oven.rb +5 -1
- data/lib/kitchen/page_element.rb +7 -5
- data/lib/kitchen/patches/array.rb +15 -0
- data/lib/kitchen/patches/i18n.rb +34 -0
- data/lib/kitchen/patches/integer.rb +24 -0
- data/lib/kitchen/patches/nokogiri.rb +22 -0
- data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
- data/lib/kitchen/search_query.rb +6 -0
- data/lib/kitchen/selector.rb +2 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +2 -1
- data/lib/locales/es.yml +33 -0
- data/lib/locales/pl.yml +4 -2
- data/lib/openstax_kitchen.rb +1 -5
- data/openstax_kitchen.gemspec +1 -0
- metadata +41 -7
- data/.github/config.yml +0 -14
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +0 -51
- data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +0 -9
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +0 -19
- data/lib/kitchen/transliterations.rb +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43191e77a90ff1979ef567be7b5ab17d0eeac503ead1294d8d329e18d6740c75
|
|
4
|
+
data.tar.gz: ae55a2aa093d942166c41502c2019b327ccaf4eab1fd383773acd94827122524
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6bcc9edf90d94f61582668e6bae0c39a42dd6d4535f944d7566eb4d17cd85ed1e5712b9e51b6ed5cf71d5928d90b211c26ac6134a356246a41ea379c4a3af73b
|
|
7
|
+
data.tar.gz: ea31d5248fec4947d06d53f2555c71ff36274c9a174976b6751dd9894a41eb949601e77c2116227374573cbdf823e9c7fc94142ce9d3341d9159d8d7d03074a2
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CHANGELOG.md
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
exists:
|
|
8
|
+
timeout-minutes: 10
|
|
9
|
+
runs-on: ubuntu-18.04
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0
|
|
15
|
+
- name: Check for CHANGELOG.md in this PR
|
|
16
|
+
# https://dev.to/scienta/get-changed-files-in-github-actions-1p36
|
|
17
|
+
run: |
|
|
18
|
+
if [[ $(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep CHANGELOG.md) ]]; then
|
|
19
|
+
echo "CHANGELOG.md is included in the pull request! Way to go!"
|
|
20
|
+
exit 0
|
|
21
|
+
else
|
|
22
|
+
echo "CHANGELOG.md was not modified in this pull request. Boo!"
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Rubocop
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
timeout-minutes: 10
|
|
12
|
+
runs-on: ubuntu-18.04
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v2
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
- uses: actions/cache@v2
|
|
19
|
+
with:
|
|
20
|
+
path: vendor/bundle
|
|
21
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
|
22
|
+
restore-keys: |
|
|
23
|
+
${{ runner.os }}-gems-
|
|
24
|
+
- name: Build docker image and run rubocop within it
|
|
25
|
+
# See https://docs.codecov.io/docs/testing-with-docker
|
|
26
|
+
run: |
|
|
27
|
+
./docker/build --ci
|
|
28
|
+
./docker/rubocop ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,66 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
## [7.0.0] - 2021-06-21
|
|
11
|
+
|
|
12
|
+
* Changed selector expected by `default strategy` in `move_solutions_to_answer_key` to optimize search (major)
|
|
13
|
+
* Fix Rubocop GitHub Action's regular expression used to select files to lint (patch)
|
|
14
|
+
* Added monkey patch for array to be able to add a prefix: `%w[multiple-choice true-false].prefix('section.')` (minor)
|
|
15
|
+
|
|
16
|
+
## [6.1.0] - 2021-06-21
|
|
17
|
+
|
|
18
|
+
* Create a `BakeReferences` V2 for unnumbered section references (minor)
|
|
19
|
+
* Don't check for CHANGELOG when merge a PR to main (patch)
|
|
20
|
+
* Added `BakeInlineLists` (minor)
|
|
21
|
+
|
|
22
|
+
## [6.0.0] - 2021-06-15
|
|
23
|
+
|
|
24
|
+
* Allow `BakeChapterSummary` to skip pages where there is no summary (minor)
|
|
25
|
+
* Change `PageElement#summary` to return nil instead of raise an error if no matches (major?)
|
|
26
|
+
* Fix bug in `BakeNumberedNotes:::V3` when there are multiple os-numbers (minor)
|
|
27
|
+
* Add Rubocop and a working CHANGELOG check to GitHub actions (patch)
|
|
28
|
+
* Allow `BakeFootnotes` to number footnotes with Roman numerals (minor)
|
|
29
|
+
* Create V2 for `BakeNumberedTables` (minor)
|
|
30
|
+
* Remove extraneous title in `BakeChapterSectionExercises` (minor)
|
|
31
|
+
* Create V2 for `BookAnswerKeyContainer` and `MoveSolutionsToEOC` with singular option for wrapper class (minor)
|
|
32
|
+
* Delete `abstract` and `description` elements from preface in `BakePreface` (minor)
|
|
33
|
+
* Stop deleting the first `<strong>` tag in `BakeNumberedNotes` (major)
|
|
34
|
+
* Allow `BakeFigure` to bake unnumbered splash figures (minor)
|
|
35
|
+
* Extend `ChapterReviewContainer` to accept other classes (major?)
|
|
36
|
+
* Add a `Strategy` for Precalculus (minor)
|
|
37
|
+
* Create a `BakeNumberedNotes` V2 (minor)
|
|
38
|
+
* Added a version of `BakeChapterIntroductions` without a chapter outline (minor)
|
|
39
|
+
* Add `BakeChapterSolutions` which bakes the free response solutions at the eoc (minor)
|
|
40
|
+
* Changed locale `eoc_answer_key_title` to `answer_key_title` as it was only used in eob (major)
|
|
41
|
+
* Added spec for translations (minor)
|
|
42
|
+
* Remove summary attribute from numbered tables, add option to pass title element to `BakePreface` (minor)
|
|
43
|
+
* Renamed `American Government` strategy to `Default` inside `move_solutions_to_answer_key` for other books to use it with a sent in classname (major)
|
|
44
|
+
* Adds `#previous` method to note_elements to find the immediately previous element (minor)
|
|
45
|
+
* Adds `BakeNumberedNotes` V3 (minor)
|
|
46
|
+
* Added line that puts the classname `has-footnote` in the footnote ref's parent element (major)
|
|
47
|
+
* Added a condition into `BakeChapterSummary` so it doesn't bake the title if it already includes the respective number in it
|
|
48
|
+
* Create v3 of MoveExercisesToEOC which differs from v1 by the presence of a section title
|
|
49
|
+
and from v2 the lack of additional "os-section-area" and os-#{@klass} wrapper (minor)
|
|
50
|
+
* Add a condition in BakeNumberedExercise to make it possible to suppress even solutions in the Answer Key (minor)
|
|
51
|
+
* Fix BakeFurtherResearch baking with main bake script error by breaking the loop if further research sections are not present (minor)
|
|
52
|
+
* Rework v1 of `BakeChapterReferences` to bake references also from introduction pages (major)
|
|
53
|
+
* Fix for `BakeIndex` for words that start with a number to be grouped as symbols and for first letters with accent marks to be grouped with regular letters in alphabetic order (major)
|
|
54
|
+
|
|
55
|
+
## [5.0.0] - 2021-06-02
|
|
56
|
+
|
|
57
|
+
* Reditributed duplicated id logic across `#record_id_copied`, `#record_id_cut`, `#record_id_pasted`, added a couple more tests for `#copy`, `#cut`, and `#paste`, created a new class `IdTracker` and moved `#record_id_copied`, `#record_id_cut`, `#record_id_pasted`, and `modified_id_to_paste` into the new class (major)
|
|
58
|
+
* Moved selectors from recipe to kitchen on `BakeFirstElements` Direction (minor)
|
|
59
|
+
* Auto-detect language based on document; force output encoding to UTF-8 (major)
|
|
60
|
+
* Switched to using a library to sort strings in a language-specific way (patch)
|
|
61
|
+
* Remove summary attribute from `BakeNumberedTable` (major)
|
|
62
|
+
|
|
63
|
+
## [4.1.1] - 2021-05-24
|
|
64
|
+
|
|
65
|
+
* Adds low level Nokogiri caching, disabled by default (patch)
|
|
66
|
+
* Cache Selector objects since they don't change (patch)
|
|
67
|
+
* Use more specific selectors when to reduce bake time (patch)
|
|
68
|
+
|
|
9
69
|
## [4.1.0] - 2021-05-18
|
|
10
70
|
|
|
11
71
|
* Fixed performance problem with element class detection (patch)
|
data/Gemfile.lock
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
openstax_kitchen (
|
|
4
|
+
openstax_kitchen (7.0.0)
|
|
5
5
|
activesupport
|
|
6
6
|
i18n
|
|
7
7
|
nokogiri
|
|
8
8
|
rainbow
|
|
9
|
+
twitter_cldr
|
|
9
10
|
|
|
10
11
|
GEM
|
|
11
12
|
remote: https://rubygems.org/
|
|
@@ -18,12 +19,14 @@ GEM
|
|
|
18
19
|
zeitwerk (~> 2.3)
|
|
19
20
|
ast (2.4.1)
|
|
20
21
|
byebug (11.1.2)
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
camertron-eprun (1.1.1)
|
|
23
|
+
cldr-plurals-runtime-rb (1.1.0)
|
|
24
|
+
codecov (0.5.2)
|
|
25
|
+
simplecov (>= 0.15, < 0.22)
|
|
23
26
|
coderay (1.1.3)
|
|
24
|
-
concurrent-ruby (1.1.
|
|
27
|
+
concurrent-ruby (1.1.9)
|
|
25
28
|
diff-lcs (1.3)
|
|
26
|
-
docile (1.
|
|
29
|
+
docile (1.4.0)
|
|
27
30
|
i18n (1.8.10)
|
|
28
31
|
concurrent-ruby (~> 1.0)
|
|
29
32
|
inch (0.8.0)
|
|
@@ -83,10 +86,12 @@ GEM
|
|
|
83
86
|
rubocop (~> 1.0)
|
|
84
87
|
rubocop-ast (>= 1.1.0)
|
|
85
88
|
ruby-progressbar (1.10.1)
|
|
86
|
-
simplecov (0.
|
|
89
|
+
simplecov (0.21.2)
|
|
87
90
|
docile (~> 1.1)
|
|
88
91
|
simplecov-html (~> 0.11)
|
|
92
|
+
simplecov_json_formatter (~> 0.1)
|
|
89
93
|
simplecov-html (0.12.3)
|
|
94
|
+
simplecov_json_formatter (0.1.3)
|
|
90
95
|
sparkr (0.4.1)
|
|
91
96
|
sync (0.5.0)
|
|
92
97
|
tdiff (0.3.4)
|
|
@@ -94,6 +99,10 @@ GEM
|
|
|
94
99
|
tins (~> 1.0)
|
|
95
100
|
tins (1.26.0)
|
|
96
101
|
sync
|
|
102
|
+
twitter_cldr (6.6.0)
|
|
103
|
+
camertron-eprun
|
|
104
|
+
cldr-plurals-runtime-rb (~> 1.1)
|
|
105
|
+
tzinfo
|
|
97
106
|
tzinfo (2.0.4)
|
|
98
107
|
concurrent-ruby (~> 1.0)
|
|
99
108
|
unicode-display_width (1.7.0)
|
data/README.md
CHANGED
|
@@ -641,6 +641,22 @@ expect(book_1).to match_normalized_html("some string of HTML here")
|
|
|
641
641
|
expect(book_1).to match_html_nodes("some string of HTML here")
|
|
642
642
|
```
|
|
643
643
|
|
|
644
|
+
### Profiling
|
|
645
|
+
|
|
646
|
+
If you set the `PROFILE` environment variable to something before you run specs or a recipe, search query profile data will be collected and printed, e.g.
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
%> PROFILE=1 rspec
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### Caching
|
|
653
|
+
|
|
654
|
+
There's a low-level CSS query caching tool that saves repeated queries. In some tests, it saves 15% of query time. It is disabled by default (because we aren't super sure that it is completely safe) but can be turned on with
|
|
655
|
+
|
|
656
|
+
```ruby
|
|
657
|
+
doc.config.enable_search_cache = true
|
|
658
|
+
```
|
|
659
|
+
|
|
644
660
|
### VSCode
|
|
645
661
|
|
|
646
662
|
1. Visit `vscode:extension/ms-vscode-remote.remote-containers` in a browser
|
data/codecov.yaml
CHANGED
data/docker/rubocop
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# set -x
|
|
4
|
+
|
|
5
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
6
|
+
|
|
7
|
+
commit_range="${1:-main}"
|
|
8
|
+
if [ ! -z "$2" ]; then
|
|
9
|
+
commit_range="$commit_range..$2"
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
echo "Checking $commit_range"
|
|
13
|
+
|
|
14
|
+
# https://dev.to/scienta/get-changed-files-in-github-actions-1p36
|
|
15
|
+
changed_ruby_files=$(git diff --name-only --diff-filter=ACMRT $commit_range | grep -E "(lib\/|spec\/).*\.rb$" | xargs)
|
|
16
|
+
|
|
17
|
+
if [[ -z "${changed_ruby_files// }" ]]; then
|
|
18
|
+
echo "No files to lint with Rubocop"
|
|
19
|
+
else
|
|
20
|
+
docker run -v $DIR/..:/code \
|
|
21
|
+
-w /code \
|
|
22
|
+
openstax/kitchen.ci:latest \
|
|
23
|
+
/bin/bash -c "bundle config path vendor/bundle; bundle install; bundle exec rubocop $changed_ruby_files --disable-pending-cops"
|
|
24
|
+
fi
|
|
@@ -41,7 +41,7 @@ module Kitchen
|
|
|
41
41
|
# @return [Element, nil]
|
|
42
42
|
#
|
|
43
43
|
def introduction_page
|
|
44
|
-
pages('
|
|
44
|
+
pages('$.introduction').first
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# Returns an enumerator for the glossaries
|
|
@@ -65,7 +65,7 @@ module Kitchen
|
|
|
65
65
|
# @return [ElementEnumerator]
|
|
66
66
|
#
|
|
67
67
|
def abstracts
|
|
68
|
-
search('[data-type="abstract"]')
|
|
68
|
+
search('div[data-type="abstract"]')
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kitchen
|
|
4
|
+
# An enumerator for composite page elements
|
|
5
|
+
#
|
|
6
|
+
class CompositeChapterElementEnumerator < ElementEnumeratorBase
|
|
7
|
+
|
|
8
|
+
# Returns a factory for this enumerator
|
|
9
|
+
#
|
|
10
|
+
# @return [ElementEnumeratorFactory]
|
|
11
|
+
#
|
|
12
|
+
def self.factory
|
|
13
|
+
ElementEnumeratorFactory.new(
|
|
14
|
+
default_css_or_xpath: Selector.named(:composite_chapter),
|
|
15
|
+
sub_element_class: CompositeChapterElement,
|
|
16
|
+
enumerator_class: self
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -43,13 +43,30 @@ module Kitchen
|
|
|
43
43
|
has_class?('os-index-container')
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
#
|
|
46
|
+
# In books we can find two types of EOB References.
|
|
47
|
+
#
|
|
48
|
+
# One of them has form similar to footnotes. There are citation links in the text that provides
|
|
49
|
+
# to the reference note at the end of the book.
|
|
50
|
+
#
|
|
51
|
+
# Second one is a section with references on the Introduction page that is moved to the EOB.
|
|
52
|
+
#
|
|
53
|
+
# Difference in classes is important.
|
|
54
|
+
|
|
55
|
+
# Returns true if this page is a book citation reference
|
|
47
56
|
#
|
|
48
57
|
# @return [Boolean]
|
|
49
58
|
#
|
|
50
|
-
def
|
|
59
|
+
def is_citation_reference?
|
|
51
60
|
has_class?('os-reference-container')
|
|
52
61
|
end
|
|
53
62
|
|
|
63
|
+
# Returns true if this page is a book section reference
|
|
64
|
+
#
|
|
65
|
+
# @return [Boolean]
|
|
66
|
+
#
|
|
67
|
+
def is_section_reference?
|
|
68
|
+
has_class?('os-references-container')
|
|
69
|
+
end
|
|
70
|
+
|
|
54
71
|
end
|
|
55
72
|
end
|
data/lib/kitchen/config.rb
CHANGED
|
@@ -17,6 +17,12 @@ module Kitchen
|
|
|
17
17
|
#
|
|
18
18
|
attr_accessor :enable_all_namespaces
|
|
19
19
|
|
|
20
|
+
# @!attribute [rw] enable_search_cache
|
|
21
|
+
#
|
|
22
|
+
# @return [Boolean]
|
|
23
|
+
#
|
|
24
|
+
attr_accessor :enable_search_cache
|
|
25
|
+
|
|
20
26
|
# Creates a new config from a file (not implemented)
|
|
21
27
|
#
|
|
22
28
|
def self.new_from_file(_file)
|
|
@@ -28,6 +34,7 @@ module Kitchen
|
|
|
28
34
|
def initialize(hash: {}, selectors: nil)
|
|
29
35
|
@selectors = selectors || Kitchen::Selectors::Standard1.new
|
|
30
36
|
@enable_all_namespaces = hash[:enable_all_namespaces] || true
|
|
37
|
+
@enable_search_cache = hash[:enable_search_cache] || false
|
|
31
38
|
@hash = hash
|
|
32
39
|
end
|
|
33
40
|
end
|
|
@@ -17,7 +17,9 @@ module Kitchen
|
|
|
17
17
|
|
|
18
18
|
# Make a section with data-depth of X have a header level of X+1
|
|
19
19
|
page.search('section').each do |section|
|
|
20
|
-
title = section.first
|
|
20
|
+
title = section.titles.first
|
|
21
|
+
next unless title.present?
|
|
22
|
+
|
|
21
23
|
title.name = "h#{section['data-depth'].to_i + 1}"
|
|
22
24
|
end
|
|
23
25
|
end
|
|
@@ -3,21 +3,31 @@
|
|
|
3
3
|
module Kitchen
|
|
4
4
|
module Directions
|
|
5
5
|
module BakeChapterIntroductions
|
|
6
|
-
def self.v1(book:)
|
|
6
|
+
def self.v1(book:, bake_chapter_objectives: true)
|
|
7
7
|
book.chapters.each do |chapter|
|
|
8
|
-
|
|
9
|
-
next if page.is_introduction?
|
|
8
|
+
chapter_outline_html = ''
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
10
|
+
if bake_chapter_objectives
|
|
11
|
+
outline_items_html = chapter.non_introduction_pages.map do |page|
|
|
12
|
+
|
|
13
|
+
<<~HTML
|
|
14
|
+
<div class="os-chapter-objective">
|
|
15
|
+
<a class="os-chapter-objective" href="##{page.title[:id]}">
|
|
16
|
+
<span class="os-number">#{chapter.count_in(:book)}.#{page.count_in(:chapter)}</span>
|
|
17
|
+
<span class="os-divider"> </span>
|
|
18
|
+
<span data-type="" itemprop="" class="os-text">#{page.title.children[0].text}</span>
|
|
19
|
+
</a>
|
|
20
|
+
</div>
|
|
21
|
+
HTML
|
|
22
|
+
end.join('')
|
|
23
|
+
|
|
24
|
+
chapter_outline_html = <<~HTML
|
|
25
|
+
<div class="os-chapter-outline">
|
|
26
|
+
<h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
|
|
27
|
+
#{outline_items_html}
|
|
18
28
|
</div>
|
|
19
29
|
HTML
|
|
20
|
-
end
|
|
30
|
+
end
|
|
21
31
|
|
|
22
32
|
introduction_page = chapter.introduction_page
|
|
23
33
|
|
|
@@ -33,10 +43,7 @@ module Kitchen
|
|
|
33
43
|
introduction_page.append(child:
|
|
34
44
|
<<~HTML
|
|
35
45
|
<div class="intro-body">
|
|
36
|
-
|
|
37
|
-
<h3 class="os-title">#{I18n.t(:chapter_outline)}</h3>
|
|
38
|
-
#{outline_items_html}
|
|
39
|
-
</div>
|
|
46
|
+
#{chapter_outline_html}
|
|
40
47
|
<div class="intro-text">
|
|
41
48
|
#{title.paste}
|
|
42
49
|
#{intro_content.paste}
|
|
File without changes
|
|
@@ -19,7 +19,7 @@ module Kitchen::Directions::BakeChapterKeyConcepts
|
|
|
19
19
|
key_concepts.each do |key_concept|
|
|
20
20
|
key_concept.prepend(child: title)
|
|
21
21
|
key_concept.wrap("<div class='os-section-area'>")
|
|
22
|
-
page.search('.os-section-area').first.cut(to: key_concepts_clipboard)
|
|
22
|
+
page.search('div.os-section-area').first.cut(to: key_concepts_clipboard)
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|