Skip to content

Commit 26da9c5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into main
2 parents b03cf9b + ce3c756 commit 26da9c5

5 files changed

Lines changed: 100 additions & 5 deletions

File tree

_includes/ace-editor.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{% if page.path contains "-" or page.path contains "help" %}
22
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.min.js"></script>
3+
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.js"></script>
34
<script src="includes/buttons.js"></script>
5+
<script>runlatex.completionsURI="{{ "/assets/scripts/latexcmds.json" | relative_url}}";</script>
46
{% endif %}

assets/css/style.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,12 @@ pre {
988988
overflow: auto;
989989
padding: 0 .4rem;
990990
background-color: #F5F5F5;
991+
code {
992+
font-family: var(--font_default-mono-regular);
993+
font-size: .8rem;
994+
line-height: 1.2rem;
991995
}
996+
}
992997

993998

994999

assets/scripts/latexcmds.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
{
3+
"latex":[
4+
"documentclass",
5+
"begin",
6+
"begin{document}",
7+
"begin{enumerate}",
8+
"begin{itemize}",
9+
"begin{figure}",
10+
"begin{table}",
11+
"begin{equation}",
12+
"begin{equation*}",
13+
"end",
14+
"end{document}",
15+
"end{enumerate}",
16+
"end{itemize}",
17+
"end{figure}",
18+
"end{table}",
19+
"end{equation}",
20+
"end{equation*}",
21+
"frac",
22+
"item",
23+
"usepackage",
24+
"section",
25+
"subsection"
26+
],
27+
"book":[
28+
"chapter"
29+
],
30+
"amsmath": [
31+
"tfrac",
32+
"dfrac",
33+
"begin{align}",
34+
"begin{align*}",
35+
"begin{gather}",
36+
"begin{gather*}",
37+
"begin{aligned}",
38+
"end{align}",
39+
"end{align*}",
40+
"end{gather}",
41+
"end{gather*}",
42+
"end{aligned}"
43+
]
44+
}

assets/scripts/runlatex.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ runlatex.adddefaultpreamble=false;
2626
runlatex.adddefaultengine=false;
2727
runlatex.usecaptions=false;
2828
runlatex.minrunlines=0;
29+
runlatex.completionsURI="";
2930

3031
// debug by using https://httpbin.org/post
3132
// set to null to omit from interface
@@ -65,7 +66,43 @@ var packageregex = [
6566
[ /pspicture/, "\\usepackage{pstricks}\n" ]
6667
];
6768

69+
70+
var latexcompetions="";
71+
72+
73+
var customCompleter = {
74+
getCompletions: function(editor, session, pos, prefix, callback) {
75+
var startToken = session.getTokenAt(pos.row, pos.column).value;
76+
if (startToken.startsWith("\\")){
77+
var cmplts=[];
78+
var s=0;
79+
for (let pkg in latexcompletions) {
80+
var cs=latexcompletions[pkg];
81+
s=s-1;
82+
for(let i=0;i<cs.length;i++){
83+
if(cs[i].startsWith(prefix)){
84+
cmplts.push({name: cs[i], value:cs[i],score: s, meta: pkg});
85+
}
86+
}
87+
}
88+
callback(null, cmplts);
89+
} else {
90+
callback(null, []);
91+
return
92+
}
93+
}
94+
}
95+
6896
function llexamples() {
97+
if(runlatex.completionsURI != ""){
98+
let request = new XMLHttpRequest();
99+
request.open('GET', runlatex.completionsURI);
100+
request.responseType = 'json';
101+
request.onload = function() {
102+
latexcompletions = request.response;
103+
}
104+
request.send();
105+
}
69106
var p = document.getElementsByTagName("pre");
70107
var editor;
71108
var acemode;
@@ -127,13 +164,21 @@ function llexamples() {
127164
}
128165
}
129166
p[i].textContent=pretext.replace(/\s+$/,'');
130-
editor = ace.edit(p[i]);
131167
ace.config.set('basePath', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12') ;
168+
editor = ace.edit(p[i]);
132169
editor.setTheme(rlacetheme);
133170
editor.getSession().setMode(acemode);
134-
editor.setOption("minLines",1);
171+
editor.setOption("minLines",runlatex);
135172
editor.setOption("maxLines",runlatex.editorlines);
136173
editor.setShowPrintMargin(false);
174+
if(runlatex.completionsURI != ""){
175+
langTools=ace.require("ace/ext/language_tools");
176+
langTools.setCompleters([customCompleter]);
177+
editor.setOptions({
178+
enableBasicAutocompletion: true,
179+
enableLiveAutocompletion: true
180+
});
181+
}
137182
editor.resize();
138183
editors["pre" + i]=editor;
139184
}

en/help.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ project with the code. You may then edit it in
7878
Overleaf which will simultaneously run LaTeX on your code showing
7979
the resulting output or error log.
8080

81-
The editing features in Overleaf are far more extensive than on this
82-
site, and you may save your project in your Overleaf account and
83-
return to it later.
81+
Unlike documents processed at TeXLive.net, you may save your project
82+
in your Overleaf account and return to it later.
8483

8584
##### Use the TeXLive.net service
8685

0 commit comments

Comments
 (0)