This repository was archived by the owner on Jun 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -323,6 +323,11 @@ export default class Parsons extends RunestoneBase {
323323 depends =
324324 dependsString . length > 0 ? dependsString . split ( "," ) : [ ] ;
325325 }
326+ if ( textBlock . includes ( 'class="displaymath' ) ) {
327+ options [ "displaymath" ] = true ;
328+ } else {
329+ options [ "displaymath" ] = false ;
330+ }
326331 textBlock = textBlock . replace (
327332 / # ( p a i r e d | d i s t r a c t o r | t a g : .* ; .* ; ) / ,
328333 function ( mystring , arg1 ) {
@@ -332,12 +337,16 @@ export default class Parsons extends RunestoneBase {
332337 ) ;
333338 // Create lines
334339 var lines = [ ] ;
335- var split = textBlock . split ( "\n" ) ;
340+ if ( ! options [ "displaymath" ] ) {
341+ var split = textBlock . split ( "\n" ) ;
342+ } else {
343+ var split = [ textBlock ] ;
344+ }
336345 for ( var j = 0 ; j < split . length ; j ++ ) {
337346 var code = split [ j ] ;
338347 // discard blank rows
339348 if ( ! / ^ \s * $ / . test ( code ) ) {
340- var line = new ParsonsLine ( this , code ) ;
349+ var line = new ParsonsLine ( this , code , options [ "displaymath" ] ) ;
341350 lines . push ( line ) ;
342351 if ( options [ "paired" ] ) {
343352 line . distractor = true ;
Original file line number Diff line number Diff line change 1818// Initialize from codestring
1919
2020export default class ParsonsLine {
21- constructor ( problem , codestring ) {
21+ constructor ( problem , codestring , displaymath ) {
2222 this . problem = problem ;
2323 this . index = problem . lines . length ;
2424 var trimmed = codestring . replace ( / \s * $ / , "" ) ;
2525 this . text = trimmed . replace ( / ^ \s * / , "" ) ;
2626 this . indent = trimmed . length - this . text . length ;
2727 // Create the View
2828 var view ;
29+ // TODO: this does not work with display math... Perhaps with pretext we should have html as a language and do nothing?
30+
2931 if ( problem . options . language == "natural" || problem . options . language == "math" ) {
30- view = document . createElement ( "p" ) ;
32+ if ( ! displaymath ) {
33+ view = document . createElement ( "p" ) ;
34+ } else {
35+ view = document . createElement ( "div" ) ;
36+ }
3137 } else {
3238 view = document . createElement ( "code" ) ;
3339 $ ( view ) . addClass ( problem . options . prettifyLanguage ) ;
You can’t perform that action at this time.
0 commit comments