Created
October 1, 2017 15:42
-
-
Save fairchild/fcaac3bb37844d1428448a17bab9f4d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import plantumlencoder | |
from IPython.core.magic import magics_class, cell_magic, Magics | |
from IPython.display import Image, SVG | |
@magics_class | |
class Plantuml(Magics): | |
@cell_magic | |
def plantuml(self, line, cell): | |
self.filename = line | |
self.code = "" | |
for line in cell.split('\n'): | |
newline = line.strip() | |
if newline: | |
self.code += newline + '\n' | |
uri = "http://www.plantuml.com/plantuml/svg/" + plantumlencoder.compress(self.code) | |
urllib.urlretrieve(uri, self.filename) | |
return SVG(filename=self.filename) | |
def load_ipython_extension(ipython): | |
ipython.register_magics(Plantuml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment