Commit Graph

1994 Commits

Author SHA1 Message Date
Michael Howell abc29e2c7d Rebase onto current main branch 2022-08-15 14:05:47 -07:00
Michael Howell 9235cbf683 Fix console syntax to only see prompts at the beginning of a line
A hash or dollar in the middle of a line is not a prompt.
2022-08-15 14:03:09 -07:00
Michael Howell d78a75d5f5 Fix compile error 2022-08-15 14:03:09 -07:00
Michael Howell 2051b29b88 Brighten the blue on tag names in ayu 2022-08-15 14:03:09 -07:00
Michael Howell af917d346b Brighten the blue on tag names in ayu 2022-08-15 14:03:09 -07:00
Michael Howell dcf8e3f284 Add syntaxes.spdx 2022-08-15 14:03:09 -07:00
Michael Howell 51d8f15f8c Add syntax-themes.spdx 2022-08-15 14:03:09 -07:00
Michael Howell b42bbbdd1a Fix broken language in syntaxes README
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
2022-08-15 14:03:09 -07:00
Michael Howell 1de4ab8939 fix(init): avoid TOCTTOU bug on syntax CSS dir
Fixes https://github.com/rust-lang/mdBook/pull/1652#discussion_r717622169
2022-08-15 14:03:09 -07:00
Michael Howell 048042ff59 fix(docs): added note for where the handlebars syntax came from 2022-08-15 14:03:09 -07:00
Michael Howell 129b56012c Put the "syntect" class on the code
This way, playground buttons don't scroll along with the code.
2022-08-15 14:03:09 -07:00
Michael Howell 0dd350d3d1 Fix formatting 2022-08-15 14:03:09 -07:00
Michael Howell 924b4bfc2e Fix incorrectly ordered classes 2022-08-15 14:03:09 -07:00
Michael Howell 6075bd1930 Add scroll bar for big code blocks 2022-08-15 14:03:09 -07:00
Michael Howell 7feee33abd Add background and border around code blocks 2022-08-15 14:03:09 -07:00
Michael Howell f38c6e6b10 Add new syntaxes to guide 2022-08-15 14:03:09 -07:00
Michael Howell 67cd22a5aa Add TOML syntax
It's used by the Rust book, and old mdBook supported it.
2022-08-15 14:03:09 -07:00
Michael Howell 5efaec85b1 Fix build error on no default features 2022-08-15 14:03:09 -07:00
Michael Howell cf2b2af54c Make the highlighting closer to before 2022-08-15 14:03:09 -07:00
Michael Howell 8266ea9f9c Add the cache generator subcommand and docs for custom syntaxes 2022-08-15 14:03:09 -07:00
Michael Howell b1e3e5692d Detect runs of "boring" lines
This significantly reduces the amount of generated HTML in code that uses this feature heavily,
with only minor perf impact.
2022-08-15 14:03:09 -07:00
Michael Howell 85d45509c8 Fix line endings
Before this change, samples in the Rust book looked like this:

fn main() {

    println!("hello world!");

}

Afterward, it looks like this, which is correct,

fn main() {
    println!("hello world");
}

Basically, when you use parse_line, syntect implicitly inserts the line breaks.
2022-08-15 14:03:09 -07:00
Michael Howell 1fe86a5a0c Move Playground and comma/space class normalization into a pulldown-cmark filter
This avoids scanning over all the HTML with a regex, so it should be faster.
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 83e4915ab2 Remove profiling release profile 2022-08-15 14:03:09 -07:00
ThePuzzlemaker 8d8c103eca Use syntect instead of highlight.js 2022-08-15 14:03:09 -07:00
Eric Huss fff067b2a8
Merge pull request #1836 from mgeisler/trim-trailing-whitespace
Avoid empty last line in editable code blocks
2022-08-10 19:55:06 -07:00
Martin Geisler 217546c2a0 Trim trailing whitespace in Rust code blocks
Before, a code block would always end with a final newline. The
newline was added unconditionally by `hide_lines`.

When the code block is syntax highlighted by highlight.js, this is not
a problem, no empty line is added for a final trailing `\n` character.
However, when the code block is editable and thus handled by the ACE
editor, a trailing newline _is_ significant. I believe this issue is
most closely described by https://github.com/ajaxorg/ace/issues/2083
in the upstream repository.

The effect of the way ACE handles newlines is that a code block like

    <pre>
      Some code
    </pre>

will create an editor with _two_ lines, not just one.

By trimming trailing whitespace, we ensure that we don’t accidentally
create more lines in the ACE editor than necessary.
2022-08-10 03:11:08 +02:00
Eric Huss 40c06f5e77
Merge pull request #1863 from ehuss/bump-version
Update to 0.4.21
2022-07-22 11:06:12 -07:00
Eric Huss bb09caa9a3 Update to 0.4.21 2022-07-22 10:54:53 -07:00
Eric Huss 8f01d0234f
Merge pull request #1861 from mitchmindtree/nightly-borrowcheck-err-workaround
Workaround rust nightly borrowcheck error (#1860)
2022-07-22 07:26:28 -07:00
mitchmindtree 13035baeae Workaround rust nightly borrowcheck error (#1860)
Surprisingly, this fixes the error filed at #1860!

This seems suspicious, perhaps indicative of a bug in Rust's non-lexical
lifetime handling?

The lifetimes in the `handlebars::Renderable::render` method signature
are quite complicated, and its unclear to me whether or not Rust is
catching some new safety edge-case that wasn't previously handled
correctly...

Possibly related to `drop` order, which I *think* is related to the
order of binding statements?
2022-07-22 15:15:12 +10:00
Eric Huss 92afe9bd3c
Merge pull request #1857 from ehuss/bump-version
Update to 0.4.20
2022-07-14 14:26:20 -07:00
Eric Huss 4c1aca0abb Update to 0.4.20 2022-07-14 13:46:56 -07:00
Eric Huss da166e051d
Merge pull request #1855 from stevenengler/code-fmt
Fix code padding in headings
2022-07-13 18:06:49 -07:00
Steven Engler 6a4ba95926 Fixed code padding in headings 2022-07-13 19:12:33 -04:00
Eric Huss 6688bd8d7b
Merge pull request #1849 from FauconFan/fix_author(s)_in_user_guide
authors -> author in user guide
2022-07-09 13:55:51 -07:00
Dylan DPC 01313a39cc
Merge pull request #1851 from FauconFan/revert-1848-remove_non_exhaustive
Revert "remove __non_exhaustive members, add non_exhaustive attribute instead"
2022-07-09 21:51:04 +05:30
Joseph Priou f92911b8aa
Revert "remove __non_exhaustive members, add non_exhaustive attribute instead" 2022-07-09 17:43:17 +02:00
Dylan DPC 42d6fd5804
Merge pull request #1848 from FauconFan/remove_non_exhaustive
remove __non_exhaustive members, add non_exhaustive attribute instead
2022-07-09 19:18:25 +05:30
Fauconfan a8a45a5fbe authors -> author in user guide 2022-07-09 15:31:00 +02:00
Fauconfan 11781f0c1b remove __non_exhaustive members, add non_exhaustive attribute instead 2022-07-09 15:05:06 +02:00
Eric Huss 53055e0345
Merge pull request #1840 from ehuss/fix-lock
Fix Cargo.lock for version bump.
2022-07-01 15:46:36 -07:00
Eric Huss 1af6d4b0ec Fix Cargo.lock for version bump. 2022-07-01 15:44:18 -07:00
Eric Huss 3e311dc975
Merge pull request #1838 from ehuss/bump-version
Update to 0.4.19
2022-07-01 15:23:01 -07:00
Eric Huss 04e31eb07b Update to 0.4.19 2022-07-01 14:55:25 -07:00
Eric Huss eb82ddca0b
Merge pull request #1837 from ehuss/serve-info
Always show the "serving on" info for `mdbook serve`.
2022-07-01 14:54:04 -07:00
Eric Huss 1d2b720ebe Always show the "serving on" info for `mdbook serve`. 2022-07-01 14:36:18 -07:00
Eric Huss 4c303c3b1d
Merge pull request #1830 from ISSOtm/serve
Always open index page with `serve --open`
2022-07-01 13:18:47 -07:00
ISSOtm 42129c6181 Always open index page with `serve --open` 2022-07-01 09:01:25 +02:00