Giter Site home page Giter Site logo

Comments (5)

bring-shrubbery avatar bring-shrubbery commented on May 29, 2024 1

I really hoped I chose the right repo to open the issue on 🤦‍♀️

Interesting, I've hoped that it could become part of the parser, but I do agree that adding features just because some company made up their own syntax is far from the optimal solution.

I did want to keep the backticks in the docs, but just remove them when I deploy Docusaurus to GitLab pages, so manual replace wouldn't work here. I think adding it to the tree parsing is trivial, since syntax here is very deterministic, so I think a simple regex will do for me. I believe we can close this issue then!

Just as a note for people who might need to do a similar thing, this is the replace function regex I used to successfully replace backticks in my project. I've put this into .js file and I'm just running it in CI as an npm script before building the site, so the changes are not committed into the repo itself, and still editable on Gitlab.

.replace(/\$+[^`$]{0,1}\`([^\$]+)\`[^`$]{0,1}\$+/gim, "$$$1$$")

from mdast-util-math.

bring-shrubbery avatar bring-shrubbery commented on May 29, 2024 1

@github-actions Common agreement was reached.

from mdast-util-math.

wooorm avatar wooorm commented on May 29, 2024

Hey

Parsing is done by micromark: https://github.com/micromark/micromark-extension-math. This project deals with ASTs. It’s a bridge between the tokens that micromark emits and mdast.

GitLab math is not a priority to me. There is no math in markdown spec. And the one they use is rather different from some of the others (around backticks but also for in the “block” form). I believe that it is bad for markdown that products dreams up their own markdown extensions and I don’t think it’s manageable for me to reverse-engineer whatever they came up with.

If you want to support GitLab math, and “support” for you here means:
a) Remove the backticks
(potentially: b) Add support for block math)

Then you can do it at the tree level:

import {visit} from 'unist-util-visit'

/** @type {import('unified').Plugin<Array<void>, import('mdast').Root, import('mdast').Root>} */
export default function remarkMathGitLab() {
  return function (tree) {
    visit(tree, (node, index, parent) => {
      if (node.type === 'inlineMath') {
        node.value = node.value.replace(/^`|`$/g, '')
      }

      if (node.type === 'code' && node.lang === 'math') {
        parent.children[index] = {
          type: 'math',
          value: node.value
        }
      }
    })
  }
}

from mdast-util-math.

github-actions avatar github-actions commented on May 29, 2024

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

from mdast-util-math.

github-actions avatar github-actions commented on May 29, 2024

Hi team! Could you describe why this has been marked as wontfix?

Thanks,
— bb

from mdast-util-math.

Related Issues (1)

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.