Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃搼 Add literalinclude directive #610

Merged
merged 4 commits into from
Sep 19, 2023
Merged

馃搼 Add literalinclude directive #610

merged 4 commits into from
Sep 19, 2023

Conversation

rowanc1
Copy link
Member

@rowanc1 rowanc1 commented Sep 19, 2023

This supports a new directive, literalinclude as well as all of the additional options across RST and Sphinx.

RST documentation:

Sphinx documentation:

See executablebooks/jupyterlab-myst#189 and https://github.com/orgs/executablebooks/discussions/1026

There are a few more tweaks that will be necessary to bring this to jupyterlab-myst to expose the transform and extend to not having to read from disk, etc.

cc @nthiery @matthewfeickert @fperez who were asking for this over the last few months.

Comment on lines +30 to +31
const showLineNumbers =
options?.linenos || options?.['lineno-start'] || options?.['lineno-match'] || numberLines
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a portion of the bug in:

Line number is now turned on if lineno-start is included.

@rowanc1 rowanc1 requested a review from fwkoch September 19, 2023 19:37
Copy link
Member

@fwkoch fwkoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - I didn't dig through all the logic around line numbers, etc, in detail, but testing and documentation both look thorough 馃憤

Despite all the logic complexity added, there was nice simplification around previously duplicated options/directives. My only comments are non-critical.

docs/code.md Outdated Show resolved Hide resolved
docs/code.md Outdated Show resolved Hide resolved
packages/myst-cli/src/transforms/include.ts Outdated Show resolved Hide resolved
packages/myst-cli/src/transforms/include.ts Show resolved Hide resolved
packages/myst-directives/src/code.ts Outdated Show resolved Hide resolved
packages/myst-directives/src/code.ts Show resolved Hide resolved
@rowanc1 rowanc1 merged commit 392ba77 into main Sep 19, 2023
3 checks passed
@rowanc1 rowanc1 deleted the feat/include branch September 19, 2023 20:16
@nthiery
Copy link

nthiery commented Sep 19, 2023

I confirm that the dev version of myst supports smoothly the literalincludes
in my documents.

Since I could not yet test it with JupyterLab, I actually started mystmd for the
first time on a real project of mine. Wow, this is sooo fast. True real time
rendering. This a game changer for authoring.

Guys, it's amazing what you are building!!!

Can't wait to switch over from Jupyter-book for my whole toolchain.

@rowanc1
Copy link
Member Author

rowanc1 commented Sep 19, 2023

鈿★笍馃挩馃殌

Really glad you are up and running with the CLI -- we will get it over to Jupyter soon!

@fperez
Copy link

fperez commented Sep 20, 2023

Pinging also @minrk who may have content using these.

Haven't had a chance to test it yet, but wanted to thank @rowanc1 & team for listening to our input! This is looking wonderful, will provide concrete feedback as soon as I have any. Hugely apreciated!

@nthiery
Copy link

nthiery commented Sep 22, 2023

Dear @rowanc1,

There seems to be a little glitch in the tex export when literal-including indented code.
Here is an example:

I have a file mystere-correction.cpp containing:

void mystereTest() {
    /// BEGIN mystereTests
    CHECK( mystere(0) == ""             );
    CHECK( mystere(1) == "*\n"          );
    CHECK( mystere(2) == "*\n**\n"      );
    CHECK( mystere(3) == "*\n**\n***\n" );
    /// END mystereTests
}

It's included as such:

:::{literalinclude} mystere-correction.cpp
:start-after: BEGIN mystereTests
:end-before: END mystereTests
:::

The generated TeX looks as such; mind the indentation of the first line:

\begin{verbatim}
CHECK( mystere(0) == ""             );
    CHECK( mystere(1) == "*\n"          );
    CHECK( mystere(2) == "*\n**\n"      );
    CHECK( mystere(3) == "*\n**\n***\n" );
\end{verbatim}

Let me know if more detailed instructions to reproduce would be helpful.

The generated html is fine.

@fwkoch
Copy link
Member

fwkoch commented Sep 22, 2023

@nthiery - I pulled your above comment to a separate issue so it wasn't lost: #614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants