Vcsn issues
https://gitlab.lre.epita.fr/vcsn/vcsn/-/issues
2018-04-28T14:12:57+02:00
https://gitlab.lre.epita.fr/vcsn/vcsn/-/issues/114
Implement %%trie
2018-04-28T14:12:57+02:00
Akim Demaille
Implement %%trie
See the doc for automaton.compose: it would be nice to have a magic command %%trie to introduce a trie automaton.
See the doc for automaton.compose: it would be nice to have a magic command %%trie to introduce a trie automaton.
https://gitlab.lre.epita.fr/vcsn/vcsn/-/issues/110
D3Widget: Fix keyboard shortcuts
2018-04-28T14:12:57+02:00
Clément Gillard
D3Widget: Fix keyboard shortcuts
It seems the keyboard shortcuts in AutomatonD3Widget don't work anymore. They were :
- `Backspace` or `b`: delete selected state or transition
- `s`: fix selected state
- `i`/`f`: set as initial/final state
- `l`: create a loopin...
It seems the keyboard shortcuts in AutomatonD3Widget don't work anymore. They were :
- `Backspace` or `b`: delete selected state or transition
- `s`: fix selected state
- `i`/`f`: set as initial/final state
- `l`: create a looping transition
- `m`: not sure, but it seemed to be used to drag a state
https://gitlab.lre.epita.fr/vcsn/vcsn/-/issues/98
Fix the automaton GUI editor
2018-04-28T14:12:57+02:00
Akim Demaille
Fix the automaton GUI editor
Give a hand to @ClementGillard.
Give a hand to @ClementGillard.
3.0
https://gitlab.lre.epita.fr/vcsn/vcsn/-/issues/85
Mix SVG and MathJax
2018-04-28T14:12:57+02:00
Akim Demaille
Mix SVG and MathJax
Let's try a means to improve our rendering of decorated automaton (typically
derived-term) with MathJax rendering. Stackoverflow has hints on how we can
do that for SVG, but so far, I failed to adjust the output of dot.
I once trie...
Let's try a means to improve our rendering of decorated automaton (typically
derived-term) with MathJax rendering. Stackoverflow has hints on how we can
do that for SVG, but so far, I failed to adjust the output of dot.
I once tried to implement it, but to no avail. For the record (and maybe as a possible starting point) here is the commit of my failed attempt.
```
commit 249224fe1c2fe2507b6e78d5b371a5994ccc60bd
Author: Akim Demaille <akim@lrde.epita.fr>
Date: Mon May 26 10:49:07 2014 +0200
WIP: python: use MathJax inside GraphViz svg
* python/vcsn/automaton.py: here.
diff --git a/python/vcsn/automaton.py b/python/vcsn/automaton.py
index 3fdd936..bd482fe 100644
--- a/python/vcsn/automaton.py
+++ b/python/vcsn/automaton.py
@@ -2,7 +2,7 @@
## automaton. ##
## ----------- ##
-from IPython.display import display, SVG
+from IPython.display import display, HTML, SVG
from IPython.html.widgets import interact
import re
from vcsn_cxx import automaton, label, weight
@@ -25,6 +25,7 @@ automaton.__rmul__ = _left_mult
automaton.__str__ = lambda self: self.format('dot')
automaton.__sub__ = automaton.difference
automaton._repr_svg_ = lambda self: _dot_to_svg(self.dot())
+automaton._repr_html_ = lambda self: _automaton_html(self)
class _conjunction(object):
"""A proxy class that delays calls to the & operator in order
@@ -90,6 +91,37 @@ def _automaton_eval(self, w):
return self._eval(w)
automaton.eval = _automaton_eval
+def _automaton_html(self):
+ """Try to display `self` with SVG and MathJax together.
+ Does not work.
+ """
+ dot = self.dot()
+ print(0, dot)
+ dot = re.sub(r'(label = ")(.*?)(", shape = box)',
+ r'\1$\2$\3', dot)
+ print(0, dot)
+ svg = _dot_to_svg(dot)
+ print(svg)
+ svg = re.sub(r'>\$(.*?)\$<',
+ r'''><foreignObject>
+ <div xmlns="http://www.w3.org/1999/xhtml" style="font-family:Times; font-size:15px">
+ $\1$
+ </div>
+ </foreignObject><''', svg)
+ html = r'''<!DOCTYPE html>
+<html>
+<head>
+<title>MathJax in SVG diagram</title>
+<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG"></script>
+</head>
+<body>
+ {svg}
+</body>
+</html>
+'''.format(svg = svg)
+ print(html)
+ return html
+
def _automaton_load(file, format = "dot"):
return automaton(open(file, "r").read(), format)
automaton.load = staticmethod(_automaton_load)
```
3.0