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

The four extensions in one package "extras" #18

Merged
merged 34 commits into from
May 3, 2024

Conversation

bowman2001
Copy link
Contributor

Closes #12

@jmooring
Copy link
Member

jmooring commented Mar 21, 2024

The example from the README contains this:

Hydrogen (H) is the 1^st^ element in the periodic table.

Water (H~2~O) is a liquid.

Water (H~2~O) is a ++transparent++ liquid.

The subscripts are failing.

This works:

x H~2~O

This does not:

x H~2~O x

The Hugo integration bit is here:
gohugoio/hugo#12294

You'll need to change the replacement path in go.mod. That will, of course, go away once this is merged.

extras/subscript.go Outdated Show resolved Hide resolved
extras/subscript.go Outdated Show resolved Hide resolved
extras/subscript.go Outdated Show resolved Hide resolved
@bowman2001
Copy link
Contributor Author

bowman2001 commented Mar 22, 2024

Yes, @bep, the only difference between Superscript and Subscript are the markers (a single '^' or '~'). All the other variables, functions, or methods only have different names. This redundancy could surly be removed.

The insert doesn’t need to watch out for whitespace and has the same logic as strong emphasis.

But first I need to address the problem @jmooring mentioned. My unit tests did not cover the cases x H~2~O x or x foo^3^bar x until now. They both fail, and I obviously missed something I need to figure out.

extras/go.mod Outdated Show resolved Hide resolved
The look-ahead for whitespace characters in super- in subscripts was meant for an edge case. LaTeX-like notation `x^2 + x^3` leads to a senseless formatting `x<sup>2 + x</sup>3`. But the look-ahead had the side effect to fail perfectly normal Markdown like `H~2~O text`.
The look-ahead for whitespace characters in super- and subscripts is essential because a caret or a tilde may also be used for other markup or literally. The enabled extensions shouldn’t force a user to escape all existing literal characters or interfere with other markup. Edge cases may remain.
This is a preliminary version. The goal is to create one NodeKind "inlineTag" for all simple inline tags. But I am not sure if it’s going to work out, so I want to leave this on record.
@bowman2001
Copy link
Contributor Author

Sorry for the delay, I had to attend to a lot of changes in my life in the last weeks. Coming month my new full-time Job is going to start.

I want to finish the extras package with the requested changes in the next days.

@bowman2001
Copy link
Contributor Author

bowman2001 commented May 1, 2024

There are new unit tests for the problem @jmooring found, and it's gone. The redundancy in the extensions is also gone. Only the necessary general structures for an inline tag remain which can be used for different tags. I have added a new mark tag because it was so easy: ==marked== -> <mark>marked</mark>.

The configuration follows now the same concept as passthrough without any additional configuration data, as @bep requested.

I also changed config.go and convert.go in my Hugo fork and wrote some integration tests in goldmark_integration_test.go. Everything looks good.

I noticed that I am not as proficient with the Go workflow as I would like. I had to change the module path to my personal repo to integrate.

@jmooring jmooring changed the title The three extensions in one package "extras" The four extensions in one package "extras" May 3, 2024
@jmooring
Copy link
Member

jmooring commented May 3, 2024

To simplify integration testing I am merging this without tagging a release. The repository is still described as "Work in progress".

@jmooring jmooring merged commit 234f8fa into gohugoio:main May 3, 2024
6 checks passed
@bowman2001 bowman2001 deleted the extras branch June 14, 2024 17:04
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.

Add extras extension package for insert, mark, subscript, and superscript
3 participants