The line below gives an example of how to compile solidity code from a jupyter notebook cell. Replaces the '--ast-json' with whatever options or output you like, and adjust the binary to where your solc is. The dash at the end is necessary to signify stdin.
%alias_magic solidity script -p "/home/jovyan/.solcx/solc-v0.6.7 --ast-json -"