Giter Site home page Giter Site logo

Comments (8)

SichangHe avatar SichangHe commented on June 10, 2024 1

Sorry for the delay. I am not a fan of this change because either users will lose some customizability or we will have to deal with all the weird delimiters people use/don't use.

I think for your original problem, it would be much easier to write a script to replace delimiters in your source file to unify all delimiters.

from mdbook-katex.

SichangHe avatar SichangHe commented on June 10, 2024

Why don't you ask ChatGPT to do that?

from mdbook-katex.

ayoubelmhamdi avatar ayoubelmhamdi commented on June 10, 2024

Not every GPT is powerful, and when we have a complex or lengthy prompt, the GPT may not follow all instructions correctly, but the programming language (like Rust) generates text very consistently

from mdbook-katex.

ayoubelmhamdi avatar ayoubelmhamdi commented on June 10, 2024

My temporary solution is to calculate the dominance between the two situations.

set -e

file="file.md"

left="$(grep -o -e '\\(\(\([^\]*\)[^)]\+\))' -e '\\\[\(\([^\]*\)[^]]\+\)]' "$file" | wc -l)"
dollar="$(grep -o '\$\+\([^$]\+\)\$\+' "$file" | wc -l)"

if [ "$dollar" -gt "$left" ];then
  cat book_dollar.toml > book.toml
else
  cat book_left.toml > book.toml
fi

from mdbook-katex.

SichangHe avatar SichangHe commented on June 10, 2024

Hello @ayoubelmhamdi, was your problem solved?

I do not plan to support multiple different delimiters because 1. it would complicate the code in a way that I do not find worthy and 2. it would encourage people to commit crimes on using many inconsistent delimiters.

However, if you would like to implement this feature, here is where you need to look at:

mdbook-katex/src/scan.rs

Lines 121 to 129 in 5302e96

match byte {
b if b == self.block_delimiter.first() || b == self.inline_delimiter.first() => {
self.index -= 1;
if self.block_delimiter.match_left(&self.bytes[self.index..]) {
self.process_delimit(false)?;
} else if self.inline_delimiter.match_left(&self.bytes[self.index..]) {
self.process_delimit(true)?;
} else {
self.inc();

Hope this helps :D.

from mdbook-katex.

ayoubelmhamdi avatar ayoubelmhamdi commented on June 10, 2024

thinks @SichangHe.

I think we don't have many delimiters. Is it acceptable to set a fixed number of delimiters that is already supported, so that it automatically handles these default delimiters without requiring the user to specify which delimiter to use?

This approach would eliminate the need for users to think about which delimiter to use.

from mdbook-katex.

SichangHe avatar SichangHe commented on June 10, 2024

I did not understand what you mean by "set a fixed number of delimiters that is already supported". Do you mean that we hardcode several delimiter pairs? Also, the default delimiters are dollar signs.

from mdbook-katex.

ayoubelmhamdi avatar ayoubelmhamdi commented on June 10, 2024

@SichangHe
I mean, we should not accept any delimiters from the user. The user should not worry about delimiters because there is a list of supported delimiters.

[preprocessor.katex]
after = ["links"]
block-delimiter = None # not supported anymore
inline-delimiter = None # not supported anymore

mdbook-katex supports only a list of delimiters, like

for the left [ "\\[",  "$", "<math>"]
for the right [ "\\]",  "$", "</math>"]

If you think there is another delimiter that is very useful, you could add it to the list.
What do you think?

from mdbook-katex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.