-
-
Save juananpe/9046b86f5671fd87260d4bcbeb58bd89 to your computer and use it in GitHub Desktop.
Dynamic data in Overleaf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ace = document.querySelector(".ace_editor"); | |
// ace.env.editor.session.getLength(); // number of lines | |
let previousRow = 0 | |
let r = ace.env.editor.find('\\get\{(.*?)\}\{(.*?)\}',{ | |
backwards: false, | |
wrap: false, | |
caseSensitive: false, | |
wholeWord: false, | |
regExp: true | |
}); | |
while (r?.end.row >= previousRow){ | |
previousRow = r.end.row | |
const original = ace.env.editor.getSelectedText(); | |
const values = original.match(/\{.*?\}/g) | |
const jsonvalue = await fetch(values[0].substring(1, values[0].length-1)) | |
const cell = await jsonvalue.json() | |
const newValue = parseFloat(cell.entry.content.$t) | |
const range = ace.env.editor.selection.getRange(); | |
ace.env.editor.session.replace(range, `\get${values[0]}{${newValue}}`); | |
r = ace.env.editor.find('\\get\{(.*?)\}\{(.*?)\}',{ | |
backwards: false, | |
wrap: false, | |
caseSensitive: false, | |
wholeWord: false, | |
regExp: true | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment