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

Added most symbols to cmd_symbols for concealment #386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

superle3
Copy link
Contributor

@superle3 superle3 commented Feb 4, 2025

Added most symbols from mathjax's Charactermaps to the concealments.
Some symbols used in the concealments were different then the ones in mathjax.
I think the ones from mathjax are more accurate and should be used, but I can revert if need be.
I sorted it case insensitive to preserve git history somewhat but its still not a full match so the differences between
mathjax and the original are shown below.
the left object is from mathjax and the right from the current map.

edit: not all mappings work like \Subset. Not sure why
edit2: almost fixed it. unicode is not fully supported.
for example

\defa{hello world}`
a

becomes hello worlda (github markdown doesn't seem to support \def).
where as \def\aä does work normally.

But to avoid regex taking \S over \Subset for the string \Subset I added a negative lookahead for any letter (\\pu{L})
and this doesn't account for when the previous character is a special letter and the next is a normal letter.
But this already so niche that I don't think we're ever gonna encounter that.

edit3: sorted the keys by length instead. Forgot that lookahead is not supported yet on ios.
It should now fully work for every macro.

{
	"amalg": [{ "\u2a3f": "⨿" }, { "\u2210": "∐" }],
	"bigcap": [{ "\u22c2": "⋂" }, { "\u2229": "∩" }],
	"bigcirc": [{ "\u25ef": "◯" }, { "\u25cb": "○" }],
	"bigcup": [{ "\u22c3": "⋃" }, { "\u222a": "∪" }],
	"bigodot": [{ "\u2a00": "⨀" }, { "\u2299": "⊙" }],
	"bigoplus": [{ "\u2a01": "⨁" }, { "\u2295": "⊕" }],
	"bigotimes": [{ "\u2a02": "⨂" }, { "\u2297": "⊗" }],
	"bigsqcup": [{ "\u2a06": "⨆" }, { "\u2294": "⊔" }],
	"bigtriangledown": [{ "\u25bd": "▽" }, { "\u2207": "∇" }],
	"bigtriangleup": [{ "\u25b3": "△" }, { "\u2206": "∆" }],
	"bullet": [{ "\u2219": "∙" }, { "\u2022": "•" }],
	"cdot": [{ "\u22c5": "⋅" }, { "\u00b7": "·" }],
	"emptyset": [{ "\u2205": "∅" }, { "\u00d8": "Ø" }],
	"frown": [{ "\u2322": "⌢" }, { "\u2054": "⁔" }],
	"geqslant": [{ "\u2a7e": "⩾" }, { "\u2265": "≥" }],
	"gg": [{ "\u226b": "≫" }, { "\u27eb": "⟫" }],
	"imath": [{ "\u0131": "ı" }, { "\u0269": "ɩ" }],
	"jmath": [{ "\u0237": "ȷ" }, { "\u1d6a5": "𝚥" }],
	"lhd": [{ "\u22b2": "⊲" }, { "\u25c1": "◁" }],
	"parallel": [{ "\u2225": "∥" }, { "\u2551": "║" }],
	"rhd": [{ "\u22b3": "⊳" }, { "\u25b7": "▷" }],
	"setminus": [{ "\u2216": "∖" }, { "\u29f5": "⧵" }],
	"simeq": [{ "\u2243": "≃" }, { "\u22cd": "⋍" }],
	"smile": [{ "\u2323": "⌣" }, { "\u203f": "‿" }],
	"sqrt": "√",
	"square": [{ "\u25fb": "◻" }, { "\u25a1": "□" }],
	"star": [{ "\u22c6": "⋆" }, { "\u272b": "✫" }],
	"triangle": [{ "\u25b3": "△" }, { "\u2206": "∆" }],
	"triangleleft": [{ "\u25c3": "◃" }, { "\u22b2": "⊲" }],
	"triangleright": [{ "\u25b9": "▹" }, { "\u22b3": "⊳" }],
// non characters that are in the cmd_symbols map
	"P": "¶",
	",": " ",
	":": " ",
	";": " ",
	"neqslant": "≠", // not available in obsidian
	"right": "",
	"qquad": " ",
	"quad": " ",
	"rceil": "⌉",
	"implies": "⇒",
	"iff": "⇔",
	"lceil": "⌈",
	"left": "",
	"lmoustache": "╭",
	"middle": "",
	"rmoustache": "╮",
	"uparrow": "↑",
	"Uparrow": "⇑",
	"updownarrow": "↕",
	"Updownarrow": "⇕",
	"choose": "C",
	"coloneqq": "≔",
	"copyright": "©",
	"displaystyle": " ",
	"dots": "…",
	"downarrow": "↓",
	"Downarrow": "⇓"
}

@superle3 superle3 force-pushed the extra-conceal branch 4 times, most recently from 6d0b253 to f0edbc8 Compare February 5, 2025 16:08
@llakala
Copy link
Contributor

llakala commented Feb 6, 2025

Does Mathjax have a \not symbol in their charactermaps? I ran into the lack of a conceal for it recently, and don't see it here. Could be nice to add.

Edit: guess not.

@superle3
Copy link
Contributor Author

superle3 commented Feb 6, 2025

They do. https://github.com/mathjax/MathJax-src/blob/master/ts/input/tex/base/BaseMappings.ts
It's the last map called not_remap.

Yeah wasn't sure how to implement bug/hack free yet.

First thought was to add another variable to the conceal_maps.ts with format not\s*\\${command}, and add it to ALL_SYMBOLS
But not sure about \s*.

Also have to convert their unicode back into Tex commands but that shouldn't be a problem.

@superle3 superle3 force-pushed the extra-conceal branch 2 times, most recently from 09cde21 to 40ee73d Compare February 6, 2025 17:05
@superle3
Copy link
Contributor Author

superle3 commented Feb 6, 2025

using not[ \t]*\\${command} instead. Obsidian doesn't like it when newlines get concealed. May come back to it, but don't think its important.

edit:
https://discuss.codemirror.net/t/preferred-way-to-create-multi-line-widget/4865/3 yeah thats not worth bothering.

added almost all macros from mathjax that can be concealed.
inf was added back since now the next character is checked for a alphabet character.
@superle3
Copy link
Contributor Author

superle3 commented Feb 9, 2025

okay I think I have tracked down all the commands that can be concealed with the current format.
I also added inf back in since #101 doesn't happen anymore,
because the next character gets checked if its not in [a-zA-Z].

@superle3 superle3 marked this pull request as ready for review February 9, 2025 15:44
@artisticat1
Copy link
Owner

Thank you for your work! I'll try to take a look soon.

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.

3 participants