Skip to content

Commit 6b6f38f

Browse files
Integrating codemirror 6 (#230)
* testing.. * reset to texlive.net * first attempt at cm6 * unified ace/cm6 line selection * handle automatic preamble insertion via codemirror * enable dark theme option * enable dark theme option 2 * remove ace API calls in more-15 * resync preamble addition code * lose red debug border, reset lesson 3 editor * support runlatex.editorlines * Gemfile.lock * keep cm6 bundle out of git for now * translation for cm6 setting * adjust help page * add codemirror link in all help pages (except mr) * add codemirror link in all settings pages (except mr) * correction to cm6 theme selector * CodeMirror not Codemirror
1 parent 93f6963 commit 6b6f38f

38 files changed

Lines changed: 823 additions & 111 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ vendor
2424
_site
2525
package.json
2626
.ruby-version
27+
Gemfile.lock

_includes/cm6-editor.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% if page.path contains "-" or page.path contains "help" %}
2+
<script src="https://texlive.net/cm6-test/cm6.bundle.min.js"></script>
3+
{% endif %}
4+
<script src="includes/buttons.js"></script>

_includes/settings-cm6theme.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
<!-- {% raw %} -->
3+
<select id="cm6-theme"></select>
4+
5+
<script>
6+
var cm6themesel=document.getElementById('cm6-theme');
7+
cm6themesel.disabled=!rlallowcookies;
8+
var cm6themes=[
9+
["Bright",
10+
['default']],
11+
["Dark",
12+
['oneDark']]
13+
];
14+
var cm6sel="";
15+
for (let g=0;g<cm6themes.length;g++) {
16+
cm6sel=cm6sel+"<optgroup label=\"" + cm6themes[g][0] + "\">" ;
17+
var values=cm6themes[g][1];
18+
for(let i = 0; i < values.length; i++) {
19+
var v=values[i];
20+
if (v == "default") v = "";
21+
cm6sel=cm6sel+"<option value=\"" + v + "\"" +
22+
(v==rlcm6theme ? " selected>" : ">") +
23+
values[i] + "</option>";
24+
}
25+
cm6sel=cm6sel+"</optgroup>";
26+
}
27+
cm6themesel.innerHTML=cm6sel;
28+
cm6themesel.addEventListener('change', function() {
29+
createCookie('runlatex-cm6theme',cm6themesel.options[cm6themesel.selectedIndex].value,100);
30+
});
31+
</script>
32+
<!-- {% endraw %} -->

_layouts/lesson.html

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!DOCTYPE html>
55
<html lang="{{ page.lang | default: site.lang | default: 'en' }}">
66
<head>
7-
<meta charset="utf-8">
7+
<meta id="xxx" charset="utf-8">
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<meta name="referrer" content="no-referrer">
1010
{% if site.title and site.title == page.title %}
@@ -26,18 +26,40 @@
2626

2727
<link rel="canonical" href="https://www.learnlatex.org/{{ page.lang }}/">
2828

29+
{% if page.lang =="mr" or page.lang == "hi" %}
30+
{% assign editor = "cm6" %}
31+
{% else %}
32+
{% assign editor = "ace" %}
33+
{% endif %}
34+
{% if page.editor %}
35+
{% assign editor = page.editor %}
36+
{% endif %}
37+
38+
39+
{% if editor == "cm6" %}
2940
<!-- script to run latex start -->
30-
<script src="{{ "/assets/scripts/runlatex.js" | relative_url}}"></script>
41+
<script src="{{ "/assets/scripts/runlatex-cm6.js" | relative_url}}"></script>
3142
<!-- script to run latex end -->
3243

33-
<!-- adding anchors to headings start 1/2 -->
34-
<script src="{{ "/assets/scripts/anchor.min.js" | relative_url }}"></script>
35-
<!-- adding anchors to headings end 1/2 -->
44+
<!-- ace editor and buttons start -->
45+
{% include cm6-editor.html %}
46+
<!-- ace editor and buttons end -->
47+
48+
{% else %}
49+
<!-- script to run latex start -->
50+
<script src="{{ "/assets/scripts/runlatex.js" | relative_url}}"></script>
51+
<!-- script to run latex end -->
3652

3753
<!-- ace editor and buttons start -->
3854
{% include ace-editor.html %}
3955
<!-- ace editor and buttons end -->
4056

57+
{% endif %}
58+
59+
<!-- adding anchors to headings start 1/2 -->
60+
<script src="{{ "/assets/scripts/anchor.min.js" | relative_url }}"></script>
61+
<!-- adding anchors to headings end 1/2 -->
62+
4163
<script>
4264
{% if site.title and site.title == page.title %}
4365
function switchlang(e) {

_layouts/page.html

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,43 @@
2323

2424
<link rel="canonical" href="https://www.learnlatex.org/">
2525

26+
27+
{% if page.lang =="mr" or page.lang == "hi" %}
28+
{% assign editor = "cm6" %}
29+
{% else %}
30+
{% assign editor = "ace" %}
31+
{% endif %}
32+
{% if page.editor %}
33+
{% assign editor = page.editor %}
34+
{% endif %}
35+
36+
37+
{% if editor == "cm6" %}
38+
<!-- script to run latex start -->
39+
<script src="{{ "/assets/scripts/runlatex-cm6.js" | relative_url}}"></script>
40+
<!-- script to run latex end -->
41+
42+
<!-- ace editor and buttons start -->
43+
{% include cm6-editor.html %}
44+
<!-- ace editor and buttons end -->
45+
46+
{% else %}
2647
<!-- script to run latex start -->
2748
{% if page.path contains "/" or page.path contains "help" %}
2849
<script src="{{ "/assets/scripts/runlatex.js" | relative_url}}"></script>
2950
{% endif %}
3051
<!-- script to run latex end -->
3152

32-
<!-- adding anchors to headings start 1/2 -->
33-
<script src="{{ "/assets/scripts/anchor.min.js" | relative_url }}"></script>
34-
<!-- adding anchors to headings end 1/2 -->
35-
3653
<!-- ace editor and buttons start -->
3754
{% include ace-editor.html %}
3855
<!-- ace editor and buttons end -->
3956

57+
{% endif %}
58+
59+
<!-- adding anchors to headings start 1/2 -->
60+
<script src="{{ "/assets/scripts/anchor.min.js" | relative_url }}"></script>
61+
<!-- adding anchors to headings end 1/2 -->
62+
4063
<script>
4164
{% if site.title and site.title == page.title %}
4265
function switchlang(e) {

0 commit comments

Comments
 (0)