GithubHelp home page GithubHelp logo

Comments (4)

medwatt avatar medwatt commented on September 2, 2024 3

snippet ^.*\)/ "() Fraction" A
let stripped = m[0].substring(0, m[0].length - 1); let depth = 0; let i = stripped.length - 1; while (i >= 0) { if (stripped[i] == ')') depth += 1; if (stripped[i] == '(') depth -= 1 if (depth == 0) break; i -= 1 } rv = `${stripped.substring(0, i)}\\frac{${stripped.substring(i + 1, stripped.length - 1)}}`;{$1}$0
endsnippet

Thanks !!

from hsnips.

draivin avatar draivin commented on September 2, 2024

Hi there, I believe the default language mode for .tex files is latex, so could you try creating a latex.hsnips file and checking if it works?

from hsnips.

medwatt avatar medwatt commented on September 2, 2024

Hi there, I believe the default language mode for .tex files is latex, so could you try creating a latex.hsnips file and checking if it works?

Thanks for your swift reply. That worked. I have one more question if you don't mind. I'm trying to set up vscode to type my documents. I came across this guy who uses ultsnips. That's how I came across your extension.

Is it possible to do something like the code shown below:

snippet '^.*\)/' "() Fraction" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
	if stripped[i] == ')': depth += 1
	if stripped[i] == '(': depth -= 1
	if depth == 0: break;
	i -= 1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet

from hsnips.

draivin avatar draivin commented on September 2, 2024

Sure, I believe the equivalent code would be this:

snippet `^.*\)/` "() Fraction" A
``
let stripped = m[0].substring(0, m[0].length - 1);
let depth = 0;
let i = stripped.length - 1;
while (i >= 0) {
	if (stripped[i] == ')') depth += 1;
	if (stripped[i] == '(') depth -= 1
	if (depth == 0) break;
    i -= 1
}
rv = `${stripped.substring(0, i)}\\frac{${stripped.substring(i + 1, stripped.length - 1)}}`;
``{$1}$0
endsnippet

from hsnips.

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.