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

add support for \[ and \] math blocks #13

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

Conversation

ecstrema
Copy link

@ecstrema ecstrema commented Feb 5, 2022

When copy pasting text from/to latex, one of the main pain is to change all $$ ... $$ blocks to [ ... ]

Not that although I opened this PR, there are a few questions and things to resolve before it can be merged.

I'll leave them as comments and mark the pr as draft for now.

When copy pasting text from/to latex, one of the main pain is to change all $$ ... $$ blocks to \[ ... \]
@@ -106,18 +106,24 @@ function math_block(state, start, end, silent){
max = state.eMarks[start]

if(pos + 2 > max){ return false; }
if(state.src.slice(pos,pos+2)!=='$$'){ return false; }

/** @type {readonly ['$$', '\\['} */
Copy link
Author

Choose a reason for hiding this comment

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

are type annotations accepted? Should I remove them?

lastPos = state.src.slice(0,max).lastIndexOf('$$');
lastLine = state.src.slice(pos,lastPos);
found = true;
for (const delim of rightDelimiters) {
Copy link
Author

Choose a reason for hiding this comment

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

is the usage of for-of prohibited for browser compat?

See the support table

@@ -148,7 +156,7 @@ function math_block(state, start, end, silent){
+ state.getLines(start + 1, next, state.tShift[start], true)
+ (lastLine && lastLine.trim() ? lastLine : '');
token.map = [ start, state.line ];
token.markup = '$$';
token.markup = startDelim;
Copy link
Author

Choose a reason for hiding this comment

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

what happens to the token markup when the start and end character isn't the same. Is it even supported?

See the api documentation

@ecstrema
Copy link
Author

ecstrema commented Feb 5, 2022

Note that this coding style is quite foreign to me, so I hope I have put the spaces where needed.

wdhongtw pushed a commit to wdhongtw/markdown-it-katex that referenced this pull request Jul 24, 2024
Fix nested begin/end for inline bare block
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.

1 participant