Commit Graph

143 Commits

Author SHA1 Message Date
Michael Howell
8266ea9f9c Add the cache generator subcommand and docs for custom syntaxes 2022-08-15 14:03:09 -07:00
Michael Howell
14250259ef Scope splitting syntect "boring" implementation
This PR attempts to get a syntect implementation that actually works,
by manipulating the scope stack directly instead of trying to post-process
the HTML.

It takes strings like this:

    let _t = "interesting string
    \# boring string
    ";

And produces DOMs that look like this:

    <span class="syn-source syn-rust">
        <span class="syn-storage syn-type syn-rust">let</span>
        _t
        <span class="syn-keyword syn-operator syn-assignment syn-rust">=</span>
        <span class="syn-string syn-quoted syn-double syn-rust">
            <span class="syn-punctuation syn-definition syn-string syn-begin syn-rust">&quot;</span>
            interesting string
        </span>
    </span>
    <span class="boring">
        <span class="syn-source syn-rust">
            <span class="syn-string syn-quoted syn-double syn-rust">boring string</span>
        </span>
    </span>
    <span class="syn-source syn-rust">
        <span class="syn-string syn-quoted syn-double syn-rust">
            <span class="syn-punctuation syn-definition syn-string syn-end syn-rust">&quot;</span>
        </span>
        <span class="syn-punctuation syn-terminator syn-rust">;</span>
    </span>

In other words, it splits it up the same way a WYSIWYG editor might if you tried to apply a block
style to a deeply-nested selection; it maintains the styles, but always ensures "boring" is top-level.
It doesn't produce optimal HTML, but it should always work.
2022-08-15 14:03:09 -07:00
ThePuzzlemaker
8d8c103eca Use syntect instead of highlight.js 2022-08-15 14:03:09 -07:00
ISSOtm
fa5f32c7fd Make link to first chapter active in index page
Makes both pages more consistent, and also the previous test pass

Co-authored-by: Eric Huss <eric@huss.org>
2022-06-29 23:51:18 +02:00
ISSOtm
a91e888575 Add test for index page 2022-06-29 08:48:49 +02:00
Matthew Woodcraft
000a93dc77 Test that long words are omitted from the search index.
Note they do appear in the 'docs' part of searchindex.json (so they will be
visible in search teasers).
2022-06-26 12:22:52 +01:00
Dylan DPC
a5f861bf2b
Revert "Omit words longer than 80 characters from the search index" 2022-06-22 13:31:16 +02:00
Matthew Woodcraft
00a55b35a8 Test that long words are omitted from the search index.
Note they do appear in the 'docs' part of searchindex.json (so they will be
visible in search teasers).
2022-05-22 14:02:54 +01:00
Clark
fe8bb38ec1 add a test: Ensure building fails if [output.html].theme points to a non-existent directory 2022-04-28 13:13:58 +08:00
Eric Huss
ceff050bb4 Don't try to render summary links as markdown. 2022-04-14 20:35:39 -07:00
Sergei Trofimovich
2a2b51c8ab tests/cli: ignore user's RUST_LOG= environment variable in tests
nixpkgs build system sets `RUST_LOG=` (empty value) by default.
This switches `mdBook` into warnings+ mode (instead of info+).

This causes the following tests to fail:

    $ RUST_LOG= cargo test --test cli_tests
    ...
    cli::test::mdbook_cli_can_correctly_test_a_passing_book
    cli::test::mdbook_cli_detects_book_with_failing_tests
    cli::build::mdbook_cli_dummy_book_generates_index_html

The change drops RUST_LOG= entry.
2022-04-01 08:15:18 +01:00
Eric Huss
a5fddfa468
Merge pull request #1749 from tommilligan/unique-search-anchors
search: fix anchor ids for duplicate headers
2022-03-28 12:44:20 -07:00
Shogo Takata
0dca4d9b9f
add tests 2022-03-26 15:34:07 +09:00
Tom Milligan
972c61fa76
search: fix anchor ids for duplicate headers 2022-02-18 16:20:05 +00:00
Michael Howell
9bede85efa Move cli tests to their own subdir 2021-09-26 11:29:36 -07:00
Michael Howell
11b1e86187 Fix path dumps under windows 2021-09-26 11:29:36 -07:00
Michael Howell
10d30a2dc0 Add CLI tests
Part of #1568
2021-09-26 11:29:35 -07:00
Eric Huss
d22299d998
Merge pull request #1631 from benarmstead/master
Format better, remove unnecessary borrows, and update depends
2021-09-03 10:15:16 -07:00
Michael Howell
2a8af1c21d Include chapters with no headers in the search index 2021-08-31 12:48:21 -07:00
Ben Armstead
8a82f6336a Format with cargo correctly 2021-08-24 08:48:24 +01:00
Ben Armstead
1700783594 Format better and remove unnecessary borrows 2021-08-24 08:45:06 +01:00
josh rotenberg
60aaa7ae31 use book_config.src for edit path
use book_config.src for edit path

use book_config.src for edit path

fmt

concat the path, this is a url
2021-05-27 21:54:58 -07:00
Eric Huss
45d41eac5f Fix some issues with fragment scrolling and linking. 2021-02-12 16:37:07 -08:00
Eric Huss
9b4ab72a80
Merge pull request #1418 from ehuss/relative-renderer-command
Fix relative paths for renderer commands.
2021-01-14 17:01:41 -08:00
Eric Huss
77e7cfd22b
Change init --theme to place theme in root. (#1432) 2021-01-07 01:29:38 +01:00
Eric Huss
9a65c8ab92 Fix relative paths for renderer commands. 2020-12-30 17:46:29 -08:00
avitex
1038f0b7f5
Fix search index tests 2020-11-26 09:02:11 +11:00
Sergey Golovin
7c0ddff96a allow to serialize the "build" section 2020-11-12 19:32:32 +03:00
Camelid
b77942d3c8
Rename book-example to guide (#1336)
`book-example` is a bit of a strange name given that it's not just an
example.
2020-09-23 03:16:09 +02:00
Eric Huss
9a97f0a096
Fix init creating empty [rust] table. (#1233) 2020-06-22 16:36:37 +02:00
Eric Huss
bc23d08fa5
Rename playpen to playground. (#1241)
looks good
2020-06-22 16:34:25 +02:00
Michael-F-Bryan
ebc01dbb71
Updated the test to follow our docs 2020-05-30 04:15:24 +08:00
Michael-F-Bryan
7b3e945a27
Updated the test to reflect how redirect keys should be absolute 2020-05-30 04:11:11 +08:00
Michael-F-Bryan
5907caa732
I should have used a more realistic example 2020-05-27 03:19:24 +08:00
Michael-F-Bryan
4c2318922f
Added integration tests to make sure files are redirected as intended 2020-05-27 02:43:01 +08:00
Eric Huss
6c4c3448e3
Update dependencies. (#1211)
* Removed the itertools dependency

* Removed an unused feature flag

* Stubbed out a toml_query replacement

* Update dependencies.

* Bump env_logger.

* Use warp instead of iron for http server.

Iron does not appear to be maintained anymore. warp/hyper seems to be
reasonably maintained. Unfortunately this takes a few seconds more
to compile, but shouldn't be too bad.

One benefit is that there is no longer a need for a separate websocket
port, which makes it easier to run multiple servers at once.

* Update pulldown-cmark to 0.7

* Switch from error-chain to anyhow.

* Bump MSRV to 1.39.

* Update elasticlunr-rs.

Co-authored-by: Michael Bryan <michaelfbryan@gmail.com>
2020-05-20 23:32:00 +02:00
Kim Hermansson
6b550cb4bb Make missing backends optional. 2020-04-21 15:13:14 -07:00
Eric Huss
2f59943c04 rustfmt with 1.40
Some slight changes in formatting in 1.40.
2019-12-31 16:23:25 -08:00
Dylan DPC
1f505c2b2e
Revert "Add support for Rust edition 2018 in playpens (#1086)" (#1093)
This reverts commit a7b3aa0444.
2019-11-11 13:24:13 +01:00
Gabriel Majeri
a7b3aa0444 Add support for Rust edition 2018 in playpens (#1086)
* Add support for Rust edition 2018 in playpens

* Add Rust edition support to rustdoc

* Run rustfmt

* Fix enum variant reference
2019-11-11 12:42:24 +01:00
Eric Huss
21d8f394ae Fix "next chapter" spacer handling. (#1075) 2019-10-25 17:33:21 +02:00
Weihang Lo
6af6219e5b [Feature] expandable sidebar sections (ToC collapse) (#1027)
* render(toc): render expandable toc toggle

* ui(toc): js/css logic to toggle toc

* test: update rendered output css selector

* config: add `html.fold.[enable|level]`

* renderer: fold according to configs

* doc: add `output.html.fold`

* refactor: tidy fold config

- Derive default for `Fold`.
- Use `is_empty` instead of checking the length of chapters.
2019-10-19 09:56:08 +02:00
Benedikt Werner
84a2ab0dba Reapply: Move hiding of boring lines into static content (#846) (#1065)
* Move hiding of boring lines into static content (#846)

* Fix test for hidden code
2019-10-16 11:27:14 +02:00
Carol (Nichols || Goulding)
ac1749ff2f Implement a rustdoc_include preprocessor (#1003)
* Allow underscores in the link type name

* Add some tests for include anchors

* Include parts of Rust files and hide the rest

Fixes #618.

* Increase min supported Rust version to 1.35

* Add a test for a behavior of rustdoc_include I want to depend on

At first I thought this was a bug, but then I looked at some use cases
we have in TRPL and decided this was a feature that I'd like to use.
2019-10-06 00:27:03 +02:00
Carol (Nichols || Goulding)
f9f9785839
When this test fails, print out why to assist in debugging 2019-08-12 09:50:54 -04:00
Eric Huss
6199e4df79 Bump elasticlunr. 2019-07-12 09:53:11 -07:00
Eric Huss
228e99ba11 Fix even more print page links. (#963) 2019-07-01 17:52:25 +02:00
Carol (Nichols || Goulding)
b83c55f7ef
Switch to the standard library's fs::read_to_string 2019-06-19 22:49:18 -04:00
Eric Huss
07830f7f11
Merge pull request #891 from integer32llc/include-before-test
Write preprocessed content to file before testing with rustdoc
2019-06-12 15:01:58 -07:00
Eric Huss
2497e77bf1 Support strikethrough and tasklists. (#952) 2019-06-12 17:02:03 +02:00