-
Notifications
You must be signed in to change notification settings - Fork 25
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
add handling of double underscores in generated html #160
Conversation
I've added some comments, but that's a lot of different changes.
I've tested it successfully with HTML mode, but it does not work for TEX as the whole thing seems to be skipped at line 1941 with a test on the |
needs a test |
Added Thierry's fix and tests. |
As for the tex: the |
src/mmwtex.c
Outdated
pos1 ++; /* Adjust for 1 extra char '_' */ | ||
} else { /* LaTeX */ | ||
let(&cmt, cat(left(cmt, pos1 - 1), | ||
"\texttt{\_}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My compiler did not like this: \t
is a tab, \_
is an unknown escape.
You have to escape the backslashes, as in "\\texttt{\\_}"
src/mmwtex.c
Outdated
let(&cmt, cat(left(cmt, pos1), | ||
"", | ||
seg(cmt, pos1 + 1, pos1 + 2), /* Skip (delete) "_" */ | ||
"", right(cmt, pos1 + 2), NULL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cat
is a concatenation.
Here you concatenate:
- a left part,
- an empty string (?)
- additional characters which include the second underscore and the character right after it,
- another empty string (?)
- the right part
That seems to be too much. We only need:
- a left part, including one underscore,
- the right part, after the second underscore.
src/mmwtex.c
Outdated
/* Double-underscore handling: double-underscores are "escaped | ||
underscores", so replace a double-underscore with a single | ||
underscore and do not modify italic or subscript. */ | ||
if (cmt[pos1 + 1] == '_') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you have to use cmt[pos1]
here, without the +1
.
That one is probably best left aside for now. This is not directly related with this PR. |
This reverts commit 77bc06f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@digama0 does it look good to you ? By the way: if we keep |
@digama0 does it look good to you ? |
LGTM, I didn't check the replacement logic in detail but I'm happy to follow up with bugfixes if we find any issues later. This should be replicated in metamath-knife if it hasn't been done already. |
Not to my knowledge... and I'm not that fluent in Rust. Maybe @tirix knows/can add it ? |
The first part is in metamath/metamath-knife#127. |
Almost certainly buggy since I don't know the codebase nor the language. Also, probably inefficient since I copied code from a more complex case than just replacing
__
with_
. This is more like pseudocode than anything else, actually, but I wanted to get the ball rolling since the need for this feature was emphasized in metamath/set.mm#3389 (comment) by @avekens (i.e., we want to display command names likeMINIMIZE_WITH
andTRACE_BACK
without triggering italics or subscripts in the generated html).Help would be appreciated (it may be simpler to start another PR). Maybe from @digama0 or @wlammen or @tirix ?