Abjad / abjad-ext-ipython

Abjad IPython Extension
MIT License
2 stars 5 forks source link

In vscode notebook environment score svgs is displayed washed out. #10

Open kkibria opened 5 months ago

kkibria commented 5 months ago

Using following in vscode with a .ipynb file,

%load_ext abjadext.ipython
import abjad
staff = abjad.Staff("c'4 d'4 e'4 f'4")
abjad.show(staff)

the score looks washed out and hard to see.

So I had to write a stop-gap ipython extension containing following. This simply wraps the svg in a div and displays as html. This way the vscode notebook styling is propagated thru currentColor and it looks fine.

from abjad.io import Illustrator
from abjadext import ipython as ip

def load_ipython_extension(ipython):
    # override abjads show()
    ip.load_ipython_extension(ipython)
    Illustrator.open_output_path = render_svg

def render_svg(self, svgpath):
    from IPython.core.display import display_html
    with svgpath.open() as f:
        svg = f.read()
    display_html("<div>"+svg+"</div", raw=True)

I am proposing to incorporate this scheme in your extension directly, Many thanks.

trevorbaca commented 5 months ago

Hi,

I removed support for IPython notebooks a couple of years ago because I'm not using Abjad with notebooks, which means that such code went untested.

So I'd prefer not to add support for IPython again.

Trevor.

On Mon, Mar 11, 2024 at 12:41 AM kkibria @.***> wrote:

Using following in vscode with a .ipynb file,

%load_ext abjadext.ipython import abjad staff = abjad.Staff("c'4 d'4 e'4 f'4") abjad.show(staff)

the score looks washed and hard too see.

So I had to write a stop-gap ipython extension containing following. This simply wraps the svg in a div and displays as html. This way the vscode notebook styling is propagated thru currentColor and it looks fine.

from abjad.io import Illustrator from abjadext import ipython as ip

def load_ipython_extension(ipython):

override abjads show()

ip.load_ipython_extension(ipython)
Illustrator.open_output_path = render_svg

def render_svg(self, svgpath): from IPython.core.display import display_html with svgpath.open() as f: svg = f.read() display_html("

"+svg+"</div", raw=True)

I am proposing to incorporate this scheme in your extension directly, Many thanks.

— Reply to this email directly, view it on GitHub https://github.com/Abjad/abjad-ext-ipython/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMJFPMB4CG4MFABS6N7IGLYXVNY3AVCNFSM6AAAAABEPW2RCGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGE3TQMZUGM4DQNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Trevor Bača www.trevorbaca.com soundcloud.com/trevorbaca

kkibria commented 5 months ago

Is there any way I can help?