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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent text divergence with glue #3

Open
bethac07 opened this issue Apr 6, 2023 · 1 comment
Open

Prevent text divergence with glue #3

bethac07 opened this issue Apr 6, 2023 · 1 comment

Comments

@bethac07
Copy link
Member

bethac07 commented Apr 6, 2023

In theory, anywhere where we have duplicated text (like in the intros software page, which copies from the software content on another page), we can glue to allow duplication.

So in the initial MD file, you'd add this to the top to make it an executable MD file

---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

Then your intros would be done like this

```{code-cell} ipython3
:tags: ["remove-cell"]
from myst_nb import glue
from IPython.display import Markdown
IJ="is an imaging processing program that is capable of operating on a variety of images including multichannel, 3D and time series. It provides a variety of basic imaging processing operations, but it can be complemented with a variety of plugins for more complex tasks."
glue("imagej_intro_md", Markdown(IJ))
glue("imagej_intro",IJ)```

The page text then just ends up becoming where the intro previously was

[ImageJ](https://imagej.net/) {glue:md}`imagej_intro_md`

And on the other page, you use

Some other text {glue}`RelpathToFile.md::imagej_intro` some other text

OR (less good for text)

```{glue} imagej_intro
:doc: RelpathToFile.md```

BUT, cross-page gluing is still finicky - AFAICT in testing, {glue:md} straightup just doesn't work, {glue:text} only works for NUMBERS on cross-page glues, it just doesn't embed anything if you try to use it on a string. {glue} alone on a text string within the same page puts the text in normal font etc, but just encloses it in quotes, but across to another page, you get the text as if it was enclosed in code ticks - it's not in a normal font (the exact flavor of weird is different for the two options, but neither is right).

I've already spent about 100X as long on this as I should have, because ultimately copying-and-pasting small amounts of text would have taken 10 seconds, but we always try to avoid this because ultimately the text is going to diverge, it just will. Hopefully future versions of glue will work better (and I will try to remember to write up an MWE to file an issue there), and if so, then hopefully these breadcrumbs will make it super fast to get this done when that day shows up.

@rsenft1
Copy link
Collaborator

rsenft1 commented Apr 6, 2023

Yeah glue is like a dream that never quite got fully realized. It SOUNDS like it should do so much and fix all the problems I have with reusing variables but I find it almost never works as expected when the use case gets even a little complicated.

bethac07 added a commit that referenced this issue Apr 11, 2023
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

No branches or pull requests

2 participants