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

Allow math to interpret content within {} as a (sub)superscript #412

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

NoahStoryM
Copy link
Contributor

See #411.

@sorawee
Copy link
Contributor

sorawee commented Mar 6, 2024

@NoahStoryM
Copy link
Contributor Author

I don't know how to test in manual.scrbl that math interprets superscript and subscript correctly, maybe I should directly test that pregexp is correct?

@sorawee
Copy link
Contributor

sorawee commented Mar 6, 2024

You can write some content using math in the Scribble file, and then render it to text (https://github.com/racket/scribble/blob/master/scribble-test/tests/scribble/docs/manual.txt) and see if that's the result that you expect. If so, save the change. This will become the expected result that the test runner will compare against.

(list (make-element 'italic (list i)))])]
[(eq? i 'rsquo) (list 'prime)]
(match i
[(or (pregexp #px"^(.*)(_|\\^)\\{(.*)\\}(.*)$"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually skeptical now that you can do this properly with regexp, since braces are supposed to be balanced.

Take A_{B^{C}} as an example. With the current regexp, you would get "A_{B" as the first part and "C}" as the second part.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 1 file in this pull request and found no issues.

@NoahStoryM
Copy link
Contributor Author

I just realized that we can achieve similar functionality by defining functions:

(define ^ (compose superscript math))
(define _ (compose subscript math))

I'm not sure if this PR is necessary, feel free to close it.

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

2 participants