feat: Add more demacros#39
Conversation
von/strparse.py
Outdated
| text = re.sub(r"\\textbf{([^}]*)}", r"[b]\1[/b]", text) | ||
| text = re.sub( | ||
| r"\\paragraph{([^}]*)}", DIVIDER + r"[color=blue][b]\1[/b][/color]", text | ||
| r"\\paragraph{([^}]*)}", DIVIDER + r"[color=blue][b]\1[/b][/solor]", text |
von/strparse.py
Outdated
| return charpos | ||
|
|
||
|
|
||
| def derv_demacro(text: str) -> str: |
There was a problem hiding this comment.
i think we can take out derv_demacro for the public von
von/strparse.py
Outdated
| # return "\n".join(paragraphs) | ||
|
|
||
|
|
||
| if __name__ == "__main__": |
There was a problem hiding this comment.
i don't think in the public version we should have additional pyperclip dependency or this block
von/strparse.py
Outdated
| # " ".join([line.strip() for line in paragraph.splitlines()]).strip() | ||
| # for paragraph in text.split("\n\n") | ||
| # ] | ||
| # return "\n".join(paragraphs) |
There was a problem hiding this comment.
should revert, this was intentional. aops wraps newlines differently
There was a problem hiding this comment.
which converts \n\n to \n since this essentially joins the paragraph together which defeats the sense of creating paragraphs in the TeX document.
that's not true. What this does is so that a paragraph that looks like
Lorem ipsum
dolor sit
amet.
Consecutur
adisciping elit.
gets rewritten to
Lorem ipsum dolor sit amet.
Consecutur adisciping elit.
which is necessary for AOPS. Otherwise the wrapping on AoPS will be weird.
You could argue that it should be
Lorem ipsum dolor sit amet.
Consecutur adisciping elit.
I think I thought about this a long time ago and decided I preferred the more compact one, but I don't remember why. Either way, though, deleting this block is definitely wrong for AOPS.
von/strparse.py
Outdated
| (r"\RR", r"{\mathbb R}"), | ||
| (r"\QQ", r"{\mathbb Q}"), | ||
| (r"\FF", r"{\mathbb F}"), | ||
| # (r"\NN", r"{\mathbb N}"), |
von/strparse.py
Outdated
| return text | ||
|
|
||
|
|
||
| def comm_demacro(text: str) -> str: |
There was a problem hiding this comment.
i think this one should just be called demacro because it's used by other components
vEnhance
left a comment
There was a problem hiding this comment.
cool, we can try this out, thanks.
Add more de-macros
Here is the description that I wrote in the mail.
\NNto{\mathbb N}conversion. My script converts\NNto\mathbb{N}. I don't understand the significance of the curly braces around\mathbb N. Thus I have commented out the lines from 102–107. Moreover, the additional command demacros (dedicated for my sty file) have been placed after a comment saying# Bubu additions. This block may be removed.derv_demacrowhich convert commands like\dd[n]{y}{x}to\frac{\mathrm{d}^{n} y}{\mathrm{d} x^{n}}. I have noticed thatevan.stydoes not have this command. So this function may be removed as it is independent from the rest of the code (except the part where the function is being called).oper_demacroconverts\floor{\ceil{x}}to\left\lfloor \left\lceil x \right\rceil \right\rfloor. This also converts other commands like"\\anbr": (" \\left\\langle ", " \\right\\rangle "),. All these tuples definitions are placed in a dictionary calledoper_macros. The additional conversions (based on evan.sty) can be removed without breaking the working of the function.\n\nto\nsince this essentially joins the paragraph together which defeats the sense of creating paragraphs in the TeX document. This code can be uncommented to get back the previous functionality.