Commit Graph

48 Commits

Author SHA1 Message Date
Matt Ickstadt
b2ad669c61 Search with Elasticlunr, updated (#604)
* Add search with elasticlunr.js

This commit adds search functionality to mdBook, based on work done by @phaiax. The in-browser search code uses elasticlunr.js to execute the search, using an index generated at book build time by elasticlunr-rs.

* Add generator comment
Someone on Reddit was wondering how the rust book was generated and said they checked the source. Thought I'd put this here. Might be a good idea to have a little footer "made with mdBook", but this'll do for now.

* Remove search/editor file override behavior

* Use for loop for book iterator

* Improve HTML regex

* Fix search CORS in file URIs

* Use ammonia to sanitize HTML

* Filter html5ever log messages
2018-03-07 21:02:06 +08:00
Michael Bryan
5379a0bdf8
Made the logging a lot quieter by default (#569) 2018-01-23 01:28:37 +08:00
Sorin Davidoi
61fad2786b Improve accessibility (#535)
* fix(theme/index): Use nav element for Table of Content

* fix(renderer/html_handlebars/helpers/toc): Use ol instead of ul

Chapters and sections are ordered, so we should use the appropriate HTML tag.

* fix(renderer/html_handlebars/helpers/toc): Hide section number from screen readers

Screen readers have this functionality build-in, no need to present this. Ideally, this should not even be in the DOM tree, since the numbers can be shown by using CSS.

* fix(theme/index): Remove tabIndex="-1" from .page

Divs are not focusable by default

* fix(theme): Make sidebar accessible

Using aria-hidden (together with tabIndex) takes the links out of the tab order.
http://heydonworks.com/practical_aria_examples/#progressive-collapsibles

* fix(theme/index): Wrap content inside main tag

The main tag helps users skip additional content on the page.

* fix(theme/book): Don't focus .page on page load

The main content is identified by the main tag, not by auto-focusing it on page load.

* fix(theme/index): Make page controls accessible

* fix: Make theme selector accessible

- Use ul and li (since it is a list)
- Add aria-expanded and aria-haspopup to the toggle button
- Use button instead of div (buttons are accessible by default)
- Handle Esc key (close popup)
- Adjust CSS to keep same visual style

* fix(theme/stylus/sidebar): Make link clickable area wider

Links now expand to fill the entire row.

* fix(theme): Wrap header buttons and improve animation performance

Previously, the header had a fixed height, which meant that sometimes the print button was not visible. Animating the left property is expensive, which lead to laggy animations - transform is much cheaper and has the same effect.

* fix(theme/stylus/theme-popup): Theme button inherits color

Bug introduced while making the popup accessible

* fix(theme/book): Handle edge case when toggling sidebar

Bug introduced when switching from animating left to using transform.
2018-01-15 21:26:53 +08:00
vabc3
e825357848 Add option to disable section label in html (#533) 2018-01-08 00:31:46 +08:00
Jacob Wahlgren
3d5eb48e32 Refactor navigation helpers (#465)
* Refactor navigation helpers

* Target::find: take previous_item by reference

This makes more sense for find as an interface, though it causes a
second clone in some cases. Maybe rustc is smart here?

* Test next and previous navigation helpers

* Add more next/previous tests
2017-11-18 19:17:26 +08:00
Pratik Karki
382fc4139b run rustfmt on the repository #398(Updated) (#438)
rustfmt the repository #398
2017-10-03 13:40:23 +02:00
Mathieu David
ef5895fa78 Update all dependencies 2017-09-11 19:38:10 +02:00
Michal Budzynski
f3f6b40ea9 Moved playpen.rs renderer helper to preprocess/links.rs module 2017-08-01 13:50:12 +02:00
Michal Budzynski
b3c9ba4555 Correct clippy nits 2017-06-27 09:08:58 +02:00
Mathieu David
5e93decf6e Merge pull request #328 from sunng87/feature/handlebars-upgrade
Update handlebars and some helpers
2017-06-23 11:16:52 +02:00
Mathieu David
28afebdca2 Merge branch 'minor_refactor' of https://github.com/budziq/mdBook into budziq-minor_refactor 2017-06-23 01:09:26 +02:00
projektir
73160877b3 Creating markdown code from playpen files instead of HTML #345 2017-06-21 09:33:41 -04:00
Michal Budzynski
e8908e32c9 Minor cleanup
- removing need to explicitly use `Path::new` all over the place
- removed warnings from doctests (normally invisible unless `cargo test -- --nocapture`)
- no doctests are norun/ignore now
- updated docs both in book-example and in docs not to refer to nonexisting API's
2017-06-14 21:55:42 +02:00
Ning Sun
e890579141 (fix) some merge issue 2017-06-13 20:53:25 +08:00
Ning Sun
6ee6da074e (refactor) rework helpers based on new handlebars api
Signed-off-by: Ning Sun <sunng@about.me>
2017-06-13 20:43:17 +08:00
Ning Sun
2bb274d424 Merge branch 'master' of github.com:azerupi/mdBook 2017-06-13 20:40:46 +08:00
Michal Budzynski
75bbd55128 Changes made with rustfmt including use_try_shorthand
Updated the project rustfmt.toml to include `use_try_shorthand = true`.
Run rustfmt on all rust sources.
2017-05-19 13:04:37 +02:00
Ning Sun
d1f9174e7f
(feat) adopt new handlebars navigate api
Signed-off-by: Ning Sun <sunng@about.me>
2017-05-05 08:41:50 +08:00
CrazyMerlyn
65d7e86024 Remove the extra run button on runnable rust files
The playpen helper now uses a simple pre block instead of a pre block
with class playpen as it led to nested playpens.
2017-04-16 18:17:59 +05:30
mthh
df5472ab5a Should fix sections created with chapter of more than two digits 2017-04-07 12:46:28 +02:00
mthh
d768963c30 Revert "should fix sections created with chapter of more than two digits"
This reverts commit 8e7ec6e1fd.
2017-04-07 10:47:45 +02:00
mthh
8e7ec6e1fd should fix sections created with chapter of more than two digits 2017-04-07 02:37:46 +02:00
Corey Farwell
95fd292b4f Address warnings found by rust-clippy.
https://github.com/Manishearth/rust-clippy
2017-02-16 16:55:28 -05:00
Corey Farwell
152ebba762 Bump serde, serde_json, and handlebars crates. 2017-02-15 23:31:05 -05:00
Gambhiro
f67ae7c71a update dependency versions 2016-12-23 08:10:42 +00:00
Mathieu David
67aee5c192 Switch from rustc_serialize to serde. Closes #18 2016-11-03 01:58:42 +01:00
Gambhiro
db11ff27f4 use warn 2016-08-14 14:40:08 +01:00
Gambhiro
b584f6eb9c use macros from the log crate, issue #151 2016-08-14 13:34:02 +01:00
Mathieu David
5350d62591 Update all dependencies to latest version 2016-08-01 14:06:08 +02:00
Ian Thompson
b0e5f375ba Make sure <ul><li> and </li></ul> are balanced 2016-07-16 10:23:22 -04:00
Mathieu David
15d6227a11 Attempt to fix #119 replace \ with / in paths, so that Windows also uses / as separator (ugly hack) 2016-04-25 17:02:47 +02:00
Mathieu David
15d26befcc Refactor: Move extern crate definitions to lib.rs 2016-03-27 18:22:17 +02:00
Mathieu David
ad0794a0bd Add a rustfmt config and run rustfmt on the code base 2016-03-17 22:31:28 +01:00
Mathieu David
2a7463c45b #29 Add a way to escape {{#playpen ... } using a backslash in front: \{{#playpen ... }} 2016-01-01 01:40:37 +01:00
Mathieu David
0ac0301d72 Continue #29, Rust files can now be loaded with {{#playpen file.rs}}, they will be displayed as other code snippets included with markdown backticks except they have a playpen css class 2015-12-31 19:25:02 +01:00
Mathieu David
38b2dee17e Continue #29 Check that the rust file exists and read to string 2015-12-31 14:14:56 +01:00
Mathieu David
0cb234de5d Add tests for find_playpens 2015-12-31 12:02:25 +01:00
Mathieu David
ee4a7fb35c Start implementing #29 support for embedding playpen, implemented the function that parses the markdown to find playpen links 2015-12-30 22:40:23 +01:00
Mathieu David
e40b293336 Fix #70 render inline code blocks in the sidebar 2015-12-30 00:46:55 +01:00
Mathieu David
4ca6693a48 Update handlebars from 0.11.x to 0.12.x 2015-12-15 18:58:34 +01:00
mdinger
b164e0709b Fix many minor warnings found by clippy 2015-09-16 22:48:01 -04:00
Mathieu David
a050d9c4ad Big refactoring, now using enum for different book items (Chapter, Affix, Spacer, ...) Closes #9 2015-09-11 20:52:55 +02:00
Mathieu David
d03ae79765 Added a page containing the whole book for printing purposes, closes #41 + cleaning root path 2015-09-05 17:26:32 +02:00
Mathieu David
10d756eff0 Fix #40 where next helper returned a link to the current chapter instead of the next 2015-08-12 19:22:53 +02:00
Mathieu David
0932bfd576 Big clean-up, reduced the unwrap's to 2 in the library part! Closes #36 The unwraps where replaced with more diverse error messages #14 2015-08-11 22:55:51 +02:00
Mathieu David
a0040733e9 Fixed rust example in doc + some tweaks for html validation 2015-08-06 14:09:55 +02:00
Mathieu David
05ab31d882 Fix #34 2015-08-06 13:58:27 +02:00
Mathieu David
bca6a7aa13 [Clean-up] Reorganize structure in handlebars renderer 2015-08-04 15:15:36 +02:00