daveagp / websheets

Online version of coding handouts with blanks
GNU Affero General Public License v3.0
9 stars 8 forks source link

Proposal: extra markup for importing externally developed tasks #14

Open dz0 opened 6 years ago

dz0 commented 6 years ago

WS backend is not the most convenient for developing tasks... I want to be able to define areas in fully working program, so I propose to use /**: and :**/ to hide ws stuff in the program, example:


#include <iostream>
using namespace std;

int main() {
//*:  \[  
   cout << "Hello, world!" << endl;

/**:   \show:
   cout << Hello, <<
   cout << world!
]\
:**/
   return 0;
}

and when pasting them to WS source-code (I use extra textarea) , these metacomments would be stripped:

    var code = $('textarea#smart-paste').val();
    // replace (delete) metacomments:  //*: ,    /**:     and       :**/
    code = code.replace( /\/\/\*\:/g, '');   //   //*:  
    code = code.replace( /\/\*\*\:/g, '');   //   /**:  
    code = code.replace( /\:\*\*\//g, '');  //   :**/
    // put into CM
    codemirrors[""+9].setValue(code);   // for CPP  9-th are is used
daveagp commented 6 years ago

I'm not actively developing but this sounds like a useful thing to push into the repo.

I don't understand the magic number 9 here or the comment, can you reiterate? And the ""+9?

dz0 commented 6 years ago

the magic number 9

9 is the number of widget for CPP input (it should depend on problem language/type), but I hardcoded it for my needs...

And the ""+9?

I copied pattern from code around (suspected it is some js workaround) -- but probably just 9 would be OK..

On Sat, Oct 21, 2017 at 9:21 PM, Dave Pritchard notifications@github.com wrote:

I'm not actively developing but this sounds like a useful thing to push into the repo.

I don't understand the magic number 9 here or the comment, can you reiterate? And the ""+9?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/daveagp/websheets/issues/14#issuecomment-338422290, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNfMz40Iut3bsNcow70fYIJ7Pb9_5NSks5sujYvgaJpZM4P_xWR .

-- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt

daveagp commented 6 years ago

I merged this in and cleaned up the magical bits with 2 follow up commits: https://github.com/daveagp/websheets/commits/master Can you see if it works for you?

The UI still could be improved. What if I change it to a button like "Delete / areas /" at the top and have it directly filter them out of the relevant editor?