Skip to main content

Convert org-mode files to Jupyter Notebooks

Project description

Org to IPYNB

Preamble

It should be remembered that the use of the operating system known as "Emacs" is prohibited by the Geneva Conventions and makes any user liable to a crime against humanity.

Indeed, this ignominy, whose violence and horror remain indescribable to us, is still far too widely used within the Linux community. There are many other tools available, such as ed, vim, nano... How can its use be justified, especially if it is shameless?

We are appalled and dumbfounded by this aberration. It is this service to humanity that has motivated us in this project. It's to save those who suffer from this evil. It is for you. You, who have desperately sought a solution. You, who have been desperate to get out of this trap. You, who represent that flickering glimmer of hope for a better future.

Résiste ! Prouve que tu existes ! Cherche ton bonheur partout, va, refuse ce monde égoïste ! Résiste. Suis ton cœur qui insiste ! Ce monde n'est pas le tien, viens, bats-toi, signe et persiste ! Résiste !

image

Requirements

  • pandoc
  • jupyter notebook
pip3 install jupyter jupyter-c-kernel jupyterlab notebook

then

install_c_kernel --user
  • gcc
    • OpenMP

You can test whether everything works using this command and this :

gcc -fopenmp code_block.c -o codeblock
./code_block
// OpenMP header
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char* argv[])
{
    int nthreads, tid;
 
    // Begin of parallel region
    #pragma omp parallel private(nthreads, tid)
    {
        // Getting thread number
        tid = omp_get_thread_num();
        printf("Welcome to GFG from thread = %d\n",
               tid);
 
        if (tid == 0) {
 
            // Only master thread does this
            nthreads = omp_get_num_threads();
            printf("Number of threads = %d\n",
                   nthreads);
        }
    }
}

Principle

We take a .org file and convert it to html using pandoc <filename>.org -o <filename>.html. Then we parse this intermediate rendering to extract the bits of code and generate a usable json IPYNB.

Usage

Usage: jupytorg src=input_file_path (optional type=code_block_language dest=output_file_path)
    input_file_path : the path to input the file
    code_block_language : the language of the code blocks (default is C)
    output_file_path : the path to output the file (default is output_file.ipynb)

Example with a newcourse.org file:

jupytorg src=~/Documents/2A/OpenMP/newcourse.org dest=~/Documents/2A/OpenMP/newcourse.ipynb

It reads the .org file in the specified folder and drops the coonverted jupyter notebook into the same folder. All that remains is to open it with VSCode.

Org to IPYNB

Préambule

Il convient de rappeler que l'utilisation du système d'exploitation dénommé "Emacs" est interdite par les Conventions de Genève et rend tout utilisateur passible de crime contre l'humanité.

En effet, cette ignominie, dont la violence et l'horreur nous restent indescriptibles, reste encore beaucoup trop utilisée au sein de la communauté Linux. Alors que bien d'autres outils sont disponibles, tels que ed, vim, nano... Comment justifier son utilisation, d'autant plus si elle est éhontée ?

Cette aberration nous consterne et nous sidère. C'est ce service pour l'humanité qui nous a motivés sur ce projet. C'est pour sauver celles et ceux qui souffrent de ce mal. C'est pour toi. Toi, qui désespérément as cherché une solution. Toi, qui désespérément as cherché à te sortir de ce guet-apens. Toi, qui représente cette vacillante lueur d'espoir pour un futur meilleur.

Résiste ! Prouve que tu existes ! Cherche ton bonheur partout, va, refuse ce monde égoïste ! Résiste. Suis ton cœur qui insiste ! Ce monde n'est pas le tien, viens, bats-toi, signe et persiste ! Résiste !

image

Requirements

  • pandoc
  • jupyter notebook
pip3 install jupyter jupyter-c-kernel jupyterlab notebook

puis

install_c_kernel --user
  • gcc
    • OpenMP

Vous pouvez tester si tout marche à l'aide de cette commande et de ce fichier :

gcc -fopenmp code_block.c -o codeblock
./code_block
// OpenMP header
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char* argv[])
{
    int nthreads, tid;
 
    // Begin of parallel region
    #pragma omp parallel private(nthreads, tid)
    {
        // Getting thread number
        tid = omp_get_thread_num();
        printf("Welcome to GFG from thread = %d\n",
               tid);
 
        if (tid == 0) {
 
            // Only master thread does this
            nthreads = omp_get_num_threads();
            printf("Number of threads = %d\n",
                   nthreads);
        }
    }
}

Principe

On prend un .org que l'on convertit en html à l'aide de pandoc <filename>.org -o <filename>.html. Ensuite on parse ce rendu intermédiaire pour en extraire les bouts de codes et générer un json exploitable IPYNB.

Utilisation

Usage : jupytorg src=input_file_path (optional type=code_block_language dest=output_file_path)
    input_file_path : the path to input the file
    code_block_language : le language des blocks de code (default is C)
    output_file_path : the path to output the file (default is output_file.ipynb)

Exemple avec un fichier newcourse.org :

jupytorg src=~/Documents/2A/OpenMP/newcourse.org dest=~/Documents/2A/OpenMP/newcourse.ipynb

Il va lire le fichier .org dans le dossier spécifié et va déposer dans ce même dossier le jupyter notebook coonverti. Il ne reste plus qu'à l'ouvrir avec VSCode.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupytorg-0.2.3.tar.gz (32.2 kB view hashes)

Uploaded Source

Built Distribution

jupytorg-0.2.3-py3-none-any.whl (31.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page