learnr icon indicating copy to clipboard operation
learnr copied to clipboard

setting the font size of ace editor

Open pokyah opened this issue 6 years ago • 3 comments

Hi !

I'm looking for a proper way to change the exercise editor (ace editor) font size as I need to use my tutorial in a classroom.

I've tried by adding this html code right after the YAML header of my rmarkdown document but with no success :

<style>
.ace_editor{
    font-size:18px/normal;
}

</style>

Any hint ?

many thanks for your support

pokyah avatar Oct 15 '18 13:10 pokyah

I'm not sure if this is the proper way, but this chunk of javascript might help :-)

$(function() {
   var editor;
   $('.ace_editor').each(function( index ) {
     editor = ace.edit(this);
     editor.setFontSize("18px");
   });
})

Other ace editor related actions can be found here: https://ace.c9.io/#nav=howto

annafergusson avatar Nov 19 '18 02:11 annafergusson

As simple as adding a bit of JS instead of css ;) I should have guess this ! Thanks @annafergusson

pokyah avatar Nov 20 '18 12:11 pokyah

Works like a charm!

For others landing here, you can put the code @annafergusson suggested above in a file with a .js extension in a directory called js/ (as suggested here) and then call it with

<script language="JavaScript" src="js/exercise-font-size.js"></script>

at the beginning of the R Markdown document.

Is there a more elegant way of doing this?

mine-cetinkaya-rundel avatar Jun 13 '20 09:06 mine-cetinkaya-rundel